diff --git a/.github/workflows/recommend-integration-tests.yml b/.github/workflows/recommend-integration-tests.yml index 5790c18c436..85a8e46553c 100644 --- a/.github/workflows/recommend-integration-tests.yml +++ b/.github/workflows/recommend-integration-tests.yml @@ -20,7 +20,13 @@ jobs: - name: Get source files changes id: source-files run: | - DIFF=$(git diff --name-only origin/main | grep 'packages/react' | grep -Ev '.stories.tsx|.stories.module.css|.docs.json' || true) + # Include @primer/react, e2e snapshots, and the local packages that can affect its generated runtime output. + DIFF=$(git diff --name-only origin/main -- \ + .playwright/snapshots \ + packages/react \ + packages/postcss-preset-primer \ + packages/rollup-plugin-import-css \ + | grep -Ev '\.stories\.tsx$|\.stories\.module\.css$|\.docs\.json$' || true) if [ -z "$DIFF" ]; then echo "diff=" >> $GITHUB_OUTPUT else @@ -31,8 +37,9 @@ jobs: run: echo ${{ steps.source-files.outputs.diff != '' }} - name: Add label and comment - if: ${{ steps.source-files.outputs.diff != '' }} uses: actions/github-script@5c56fde4671bc2d3592fb0f2c5b5bab9ddae03b1 + env: + HAS_RELEVANT_DIFF: ${{ steps.source-files.outputs.diff != '' }} with: github-token: ${{ secrets.GITHUB_TOKEN }} script: | @@ -41,7 +48,8 @@ jobs: skipped: 'integration-tests: skipped manually', recommended: 'integration-tests: recommended', failing: 'integration-tests: failing', - passing: 'integration-tests: passing' + passing: 'integration-tests: passing', + ignored: 'integration-tests: ignored' } const issue = { @@ -53,8 +61,23 @@ jobs: const labels = await github.paginate(github.rest.issues.listLabelsOnIssue, issue); const integrationLabels = labels.filter(label => label.name.startsWith('integration-tests')) const hasPassingLabel = integrationLabels.find(label => label.name === INTEGRATION_LABEL_NAMES.passing) + const hasIgnoredLabel = integrationLabels.find(label => label.name === INTEGRATION_LABEL_NAMES.ignored) + const hasOnlyIgnoredLabel = + integrationLabels.length === 1 && integrationLabels[0].name === INTEGRATION_LABEL_NAMES.ignored + const hasRelevantDiff = process.env.HAS_RELEVANT_DIFF === 'true' - if (integrationLabels.length === 0) { + if (!hasRelevantDiff) { + if (!hasIgnoredLabel) { + await github.rest.issues.addLabels({...issue, labels: [INTEGRATION_LABEL_NAMES.ignored]}) + } + return + } + + if (hasIgnoredLabel) { + await github.rest.issues.removeLabel({...issue, name: INTEGRATION_LABEL_NAMES.ignored}) + } + + if (integrationLabels.length === 0 || hasOnlyIgnoredLabel) { // recommend integration tests await github.rest.issues.addLabels({...issue, labels: [INTEGRATION_LABEL_NAMES.recommended]}) await github.rest.issues.createComment({ diff --git a/.github/workflows/status-checks.yml b/.github/workflows/status-checks.yml index 5079b1682a8..274cf06577b 100644 --- a/.github/workflows/status-checks.yml +++ b/.github/workflows/status-checks.yml @@ -17,7 +17,7 @@ permissions: jobs: github-ui: runs-on: ubuntu-latest - if: "${{ (github.event_name == 'pull_request' && contains(github.event.pull_request.labels.*.name, 'integration-tests: skipped manually')) || github.event_name == 'merge_group' || (github.event_name == 'issue_comment' && github.event.issue.pull_request != null) }}" + if: "${{ (github.event_name == 'pull_request' && (contains(github.event.pull_request.labels.*.name, 'integration-tests: skipped manually') || contains(github.event.pull_request.labels.*.name, 'integration-tests: ignored'))) || github.event_name == 'merge_group' || (github.event_name == 'issue_comment' && github.event.issue.pull_request != null) }}" steps: - name: Generate token for primer id: generate_primer_token @@ -35,7 +35,7 @@ jobs: run: | # Get the timeline event ID for the label being added EVENT_ID=$(gh api "/repos/primer/react/issues/$PR_NUMBER/timeline" \ - --jq '.[] | select(.event == "labeled" and .label.name == "integration-tests: skipped manually") | .id' \ + --jq '.[] | select(.event == "labeled" and (.label.name == "integration-tests: skipped manually" or .label.name == "integration-tests: ignored")) | .id' \ | tail -n 1) # Construct the HTML URL from the event ID