From 35774bb4f67c7421d45fd22a5e7416327e4658ea Mon Sep 17 00:00:00 2001 From: Shrikant Sharat Kandula Date: Tue, 21 May 2024 11:21:15 +0530 Subject: [PATCH] ci: Remove inert ADS compliance check (#33603) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The ADS compliance check relies on the condition `github.pull_request.base.ref == 'true'`, but this variable just doesn't exist. There's no `pull_request` under the `github` context, so this ADS compliance check never worked. If we want this check, we can add it later as part of the `client-build.compliance.js` script. Here's a PoC for the record, based on the intention I interpreted: ```javascript function doADSCheck({core, github, context, affectedFiles}) { const filesForADSCheck = affectedFiles.filter(f => (f.status === "added" || f.status === "modified") && f.filename.startsWith("app/client/src/")); const violatedFiles = new Set(); for (const f of filesForADSCheck) { const content = fs.readFileSync(f.filename, "utf8"); if (content.match(/(color|Color).*#|border.*#|(color|Color).*"/)) { violatedFiles.add(f.filename); } } if (violatedFiles.size === 0) { return; } const body = [ "🔴 Below files are not compliant with ADS. Please fix and re-trigger ok-to-test", ...Array.from(violatedFiles).sort().map(f => "1. " + f), ].join("\n"); github.rest.issues.createComment({ owner: context.repo.owner, repo: context.repo.repo, issue_number: prNumber, body, }); } ``` /test sanity --- .github/workflows/client-build.yml | 41 +----------------------------- 1 file changed, 1 insertion(+), 40 deletions(-) diff --git a/.github/workflows/client-build.yml b/.github/workflows/client-build.yml index 48b0f8fa26..01cb4bd967 100644 --- a/.github/workflows/client-build.yml +++ b/.github/workflows/client-build.yml @@ -70,6 +70,7 @@ jobs: uses: actions/checkout@v4 with: fetch-tags: true + - name: Get changed files in the client folder id: changed-files-specific uses: tj-actions/changed-files@v41 @@ -94,46 +95,6 @@ jobs: script: | await require("client-build-compliance.js")({core, github, context}) - - name: Get all the added or changed files in client/src folder - if: inputs.ads-compliant-check == 'true' && inputs.pr != 0 && github.pull_request.base.ref == 'release' && (steps.changed-files-specific.outputs.any_changed == 'true' || github.event_name == 'push' || github.event_name == 'workflow_dispatch' || github.event_name == 'schedule') - id: client_files - uses: umani/changed-files@v4.1.0 - with: - repo-token: ${{ secrets.APPSMITH_CI_TEST_PAT }} - pattern: "app/client/src/.*" - pr-number: ${{ inputs.pr }} - - # Check all the newly added files are in ts - - name: ADS compliant check - if: inputs.ads-compliant-check == 'true' && inputs.pr != 0 && github.pull_request.base.ref == 'release' && (steps.changed-files-specific.outputs.any_changed == 'true' || github.event_name == 'push' || github.event_name == 'workflow_dispatch' || github.event_name == 'schedule') - id: ads_check - run: | - comment_files="" - files=(${{steps.client_files.outputs.files_created}}${{steps.client_files.outputs.files_updated}}) - for file in "${files[@]}"; do - while IFS= read -r line; do - if echo "$line" | grep -q -E '(color|Color).*#|border.*#|(color|Color).*"'; then - comment_files+=("$file") - break - fi - done < ${file#app/client/} - done - unique_files=$(echo "${comment_files[@]}" | sort -u | sed '/^[[:space:]]*$/d' | sed 's/ /
  • /g') - echo "ads_non_compliant_files=$unique_files" >> $GITHUB_OUTPUT - echo "ads_non_compliant_count=${#unique_files[@]}" >> $GITHUB_OUTPUT - - # Comment in PR if test files are not written in ts and fail the workflow - - name: Comment in PR if test files are not written in ts - if: steps.ads_check.outputs.ads_non_compliant_count != 0 && inputs.ads-compliant-check == 'true' && inputs.pr != 0 && github.pull_request.base.ref == 'release' && (steps.changed-files-specific.outputs.any_changed == 'true' || github.event_name == 'push' || github.event_name == 'workflow_dispatch' || github.event_name == 'schedule') - uses: peter-evans/create-or-update-comment@v3 - with: - issue-number: ${{ inputs.pr }} - body: | - 🔴 Below files are not compliant with ADS. Please fix and re-trigger ok-to-test -
      ${{steps.ads_check.outputs.ads_non_compliant_files}}
    - - if: steps.ads_check.outputs.ads_non_compliant_count != 0 && inputs.ads-compliant-check == 'true' && inputs.pr != 0 && github.pull_request.base.ref == 'release' - run: exit 1 - # In case this is second attempt try restoring status of the prior attempt from cache - name: Restore the previous run result if: steps.changed-files-specific.outputs.any_changed == 'true' || github.event_name == 'push' || github.event_name == 'workflow_dispatch' || github.event_name == 'schedule'