mirror of
https://github.com/servo/servo.git
synced 2025-07-23 15:23:42 +01:00
Mark skipped CI workflows as successful (#30001)
When the decision job decides that a workflow should be skipped because an identical one has already run, that workflow should be marked as successful and not unsuccessful. Signed-off-by: Martin Robinson <mrobinson@igalia.com>
This commit is contained in:
parent
e65f65a943
commit
4c8b47adbb
1 changed files with 41 additions and 15 deletions
56
.github/workflows/main.yml
vendored
56
.github/workflows/main.yml
vendored
|
@ -17,39 +17,61 @@ jobs:
|
||||||
decision:
|
decision:
|
||||||
name: Decision
|
name: Decision
|
||||||
runs-on: ubuntu-20.04
|
runs-on: ubuntu-20.04
|
||||||
|
outputs:
|
||||||
|
skipped: ${{ steps.skipDecision.outputs.result }}
|
||||||
|
platforms: ${{ steps.platformDecision.outputs.result }}
|
||||||
steps:
|
steps:
|
||||||
# If an identical build exists that suceeded, skip this workflow run. We don't do
|
- name: Skip Decision
|
||||||
# this check for pull_request and merge_group events, out of caution.
|
id: skipDecision
|
||||||
- name: Skip previous identical builds
|
|
||||||
if: ${{ github.event_name != 'pull_request' && github.event_name != 'merge_group' }}
|
|
||||||
uses: actions/github-script@v6
|
uses: actions/github-script@v6
|
||||||
with:
|
with:
|
||||||
|
result-encoding: string
|
||||||
script: |
|
script: |
|
||||||
|
// Never skip workflow runs for pull requests or merge groups, which might
|
||||||
|
// need to actually run / retry WPT tests.
|
||||||
|
if (context.eventName == "pull_request" || context.eventName == "merge_group") {
|
||||||
|
return "run";
|
||||||
|
}
|
||||||
|
// Skip the run if an identical run already exists. This helps to avoid running
|
||||||
|
// the workflow over and over again for the same commit hash.
|
||||||
if ((await github.rest.actions.listWorkflowRuns({
|
if ((await github.rest.actions.listWorkflowRuns({
|
||||||
owner: context.repo.owner,
|
owner: context.repo.owner,
|
||||||
repo: context.repo.repo,
|
repo: context.repo.repo,
|
||||||
workflow_id: "main.yml",
|
workflow_id: "main.yml",
|
||||||
head_sha: context.sha,
|
head_sha: context.sha,
|
||||||
status: "success",
|
status: "success",
|
||||||
})).data.workflow_runs.length > 0)
|
})).data.workflow_runs.length > 0) {
|
||||||
await github.rest.actions.cancelWorkflowRun({
|
return "skip"
|
||||||
owner: context.repo.owner,
|
} else {
|
||||||
repo: context.repo.repo,
|
return "run"
|
||||||
run_id: context.runId,
|
}
|
||||||
});
|
- name: Platform Decision
|
||||||
|
id: platformDecision
|
||||||
|
uses: actions/github-script@v6
|
||||||
|
with:
|
||||||
|
result-encoding: string
|
||||||
|
script: |
|
||||||
|
if ("${{ steps.skipDecision.outputs.result }}" == "skip") {
|
||||||
|
return "none";
|
||||||
|
}
|
||||||
|
if (context.eventName == "push" || context.eventName == "merge_group") {
|
||||||
|
return "all";
|
||||||
|
}
|
||||||
|
return "linux"
|
||||||
|
|
||||||
|
|
||||||
build-win:
|
build-win:
|
||||||
name: Windows
|
name: Windows
|
||||||
if: ${{ github.event_name == 'push' || github.event_name == 'merge_group' }}
|
|
||||||
needs: ["decision"]
|
needs: ["decision"]
|
||||||
|
if: ${{ needs.decision.outputs.platforms == 'all' }}
|
||||||
uses: ./.github/workflows/windows.yml
|
uses: ./.github/workflows/windows.yml
|
||||||
with:
|
with:
|
||||||
unit-tests: true
|
unit-tests: true
|
||||||
|
|
||||||
build-mac:
|
build-mac:
|
||||||
name: Mac
|
name: Mac
|
||||||
if: ${{ github.event_name == 'push' || github.event_name == 'merge_group' }}
|
|
||||||
needs: ["decision"]
|
needs: ["decision"]
|
||||||
|
if: ${{ needs.decision.outputs.platforms == 'all' }}
|
||||||
uses: ./.github/workflows/mac.yml
|
uses: ./.github/workflows/mac.yml
|
||||||
with:
|
with:
|
||||||
unit-tests: true
|
unit-tests: true
|
||||||
|
@ -57,13 +79,14 @@ jobs:
|
||||||
build-linux:
|
build-linux:
|
||||||
name: Linux
|
name: Linux
|
||||||
needs: ["decision"]
|
needs: ["decision"]
|
||||||
|
if: ${{ needs.decision.outputs.platforms == 'all' || needs.decision.outputs.platforms == 'linux' }}
|
||||||
uses: ./.github/workflows/linux.yml
|
uses: ./.github/workflows/linux.yml
|
||||||
with:
|
with:
|
||||||
wpt: 'test'
|
wpt: 'test'
|
||||||
layout: ${{ (github.event_name == 'push' || github.event_name == 'merge_group') && 'all' || 'none' }}
|
layout: ${{ (github.event_name == 'push' || github.event_name == 'merge_group') && 'all' || 'none' }}
|
||||||
unit-tests: ${{ github.event_name == 'push' || github.event_name == 'merge_group' }}
|
unit-tests: ${{ github.event_name == 'push' || github.event_name == 'merge_group' }}
|
||||||
|
|
||||||
build_result:
|
build-result:
|
||||||
name: Result
|
name: Result
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
if: always()
|
if: always()
|
||||||
|
@ -75,9 +98,12 @@ jobs:
|
||||||
- "build-linux"
|
- "build-linux"
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Mark the job as successful
|
- name: Mark skipped jobs as successful
|
||||||
|
if: ${{ needs.decision.outputs.skipped == 'skip' }}
|
||||||
run: exit 0
|
run: exit 0
|
||||||
|
- name: Mark the job as successful
|
||||||
if: ${{ !contains(join(needs.*.result, ','), 'failure') && !contains(join(needs.*.result, ','), 'cancelled') }}
|
if: ${{ !contains(join(needs.*.result, ','), 'failure') && !contains(join(needs.*.result, ','), 'cancelled') }}
|
||||||
|
run: exit 0
|
||||||
- name: Mark the job as unsuccessful
|
- name: Mark the job as unsuccessful
|
||||||
run: exit 1
|
|
||||||
if: contains(join(needs.*.result, ','), 'failure') || contains(join(needs.*.result, ','), 'cancelled')
|
if: contains(join(needs.*.result, ','), 'failure') || contains(join(needs.*.result, ','), 'cancelled')
|
||||||
|
run: exit 1
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue