Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 27 additions & 4 deletions .github/workflows/recommend-integration-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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: |
Expand All @@ -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 = {
Expand All @@ -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({
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/status-checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down