From 45ae5a2995ebabb72fb301687d05a03e11a04b8c Mon Sep 17 00:00:00 2001 From: Saroj <43822041+sarojsarab@users.noreply.github.com> Date: Tue, 27 Jun 2023 22:25:44 +0530 Subject: [PATCH] ci: Get the newly added files from the PR branch for ts check (#24825) ## Description - Get the newly added files from the PR branch instead of commits for ts check - CI improvements, now added cypress dashboard link with the comments in PR - CI improvements removed the steps which saves un-necessary cache #### Type of change - Workflow file changes ## Testing > #### How Has This Been Tested? - Workflow run --- .github/workflows/ci-test.yml | 47 +++++++------ .github/workflows/client-build.yml | 69 ++++++++++--------- .../workflows/integration-tests-command.yml | 33 +++++---- 3 files changed, 78 insertions(+), 71 deletions(-) diff --git a/.github/workflows/ci-test.yml b/.github/workflows/ci-test.yml index 374ea18438..871a27f05e 100644 --- a/.github/workflows/ci-test.yml +++ b/.github/workflows/ci-test.yml @@ -66,7 +66,7 @@ jobs: # In case this is second attempt try restoring status of the prior attempt from cache - name: Restore the previous run result id: cache-appsmith - uses: martijnhols/actions-cache@v3.0.2 + uses: actions/cache@v3 with: path: | ~/run_result @@ -79,7 +79,7 @@ jobs: id: run_result run: | run_result_env=$(cat ~/run_result) - echo "::set-output name=run_result::$run_result_env" + echo "run_result=$run_result_env" >> $GITHUB_OUTPUT - name: Dump steps context env: @@ -281,6 +281,7 @@ jobs: - name: Run the cypress test if: steps.run_result.outputs.run_result != 'success' && steps.run_result.outputs.run_result != 'failedtest' + id: cypress_test uses: cypress-io/github-action@v5 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} @@ -360,6 +361,7 @@ jobs: # In case of second attempt only run failed specs - name: Run the cypress test with failed tests if: steps.run_result.outputs.run_result == 'failedtest' + id: cypress_test_failedtest uses: cypress-io/github-action@v5 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} @@ -436,7 +438,7 @@ jobs: - name: Set fail if there are test failures if: failure() run: | - echo "::set-output name=run_result::failedtest" + echo "run_result=failedtest" >> $GITHUB_OUTPUT echo "failedtest" > ~/run_result # Create a directory ~/failed_spec_ci and add a dummy file @@ -471,33 +473,30 @@ jobs: # Force store previous run result to cache - name: Store the previous run result if: failure() - uses: martijnhols/actions-cache/save@v3 + uses: actions/cache/save@v3 with: path: | ~/run_result key: ${{ github.run_id }}-${{ github.job }}-${{ matrix.job }} - restore-keys: | - ${{ github.run_id }}-${{ github.job }}-${{ matrix.job }} + + - name: get cypress url dashboard url + id: dashboard_url + if: always() + run: | + if [[ "${{steps.run_result.outputs.run_result }}" != "success" && "${{steps.run_result.outputs.run_result }}" != "failedtest" ]]; then + echo "cypress_url=${{ steps.cypress_test.outputs.resultsUrl }}" >> ~/cypress_url + elif [[ "${{steps.run_result.outputs.run_result }}" == "failedtest" ]]; then + echo "cypress_url=${{ steps.cypress_test_failedtest.outputs.resultsUrl }}" >> ~/cypress_url + fi - # Force store previous failed test list to cache - - name: Store the previous failed test result - if: failure() - uses: martijnhols/actions-cache/save@v3 + # Force store previous run result to cache + - name: Store the previous run result + if: success() + uses: actions/cache/save@v3 with: path: | - ~/failed_spec_ci - key: ${{ github.run_id }}-${{ github.job }}-${{ matrix.job }} - restore-keys: | - ${{ github.run_id }}-${{ github.job }}-${{ matrix.job }} - - - name: Restore the previous bundle - uses: actions/cache@v3 - with: - path: | - app/client/cypress/snapshots/ - key: ${{ github.run_id }}-${{ github.job }}-${{ matrix.job }} - restore-keys: | - ${{ github.run_id }}-${{ github.job }}-${{ matrix.job }} + ~/cypress_url + key: ${{ github.run_id }}-dashboard-url-${{ github.run_number }} # Upload the log artifact so that it can be used by the test & deploy job in the workflow - name: Upload server logs bundle on failure @@ -510,5 +509,5 @@ jobs: # Set status = success - name: Save the status of the run run: | - echo "::set-output name=run_result::success" + echo "run_result=success" >> $GITHUB_OUTPUT echo "success" > ~/run_result diff --git a/.github/workflows/client-build.yml b/.github/workflows/client-build.yml index 6ee4c204dc..f8cc5226d4 100644 --- a/.github/workflows/client-build.yml +++ b/.github/workflows/client-build.yml @@ -66,42 +66,43 @@ jobs: with: fetch-depth: 0 - # # get all the files changes in the cypress/e2e folder - # - name: Get changed files in the cypress/e2e folder - # if: inputs.check-test-files == 'true' - # id: files - # uses: tj-actions/changed-files@v36 - # with: - # base_sha: ${{ github.event.client_payload.pull_request.base.sha }} - # files: app/client/cypress/e2e + # get all the files changes in the cypress/e2e folder + - name: Get added files in cypress/e2e folder + if: inputs.pr != 0 + id: files + uses: umani/changed-files@v4.0.0 + with: + repo-token: ${{ secrets.APPSMITH_CI_TEST_PAT }} + pattern: 'app/client/cypress/e2e/.*' + pr-number: ${{ inputs.pr }} - # # Check all the newly added files are in ts - # - name: Check the newly added files are written in ts - # if: inputs.check-test-files == 'true' - # id: check_files - # run: | - # files=(${{steps.files.outputs.added_files}}) - # non_ts_files=() - # for file in "${files[@]}"; do - # if [[ $file != *.ts ]]; then - # non_ts_files+=("