Unify outcome jobs
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index d691b72..cfcbb86 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -152,49 +152,25 @@
AWS_ACCESS_KEY_ID: "${{ env.ARTIFACTS_AWS_ACCESS_KEY_ID }}"
AWS_SECRET_ACCESS_KEY: "${{ secrets[format('AWS_SECRET_ACCESS_KEY_{0}', env.ARTIFACTS_AWS_ACCESS_KEY_ID)] }}"
if: "success() && (github.event_name == 'push' || env.DEPLOY == '1' || env.DEPLOY_ALT == '1')"
- try-success:
- needs:
- - job
- if: "success() && github.event_name == 'push' && (github.ref == 'refs/heads/try' || github.ref == 'refs/heads/try-perf') && github.repository == 'rust-lang-ci/rust'"
- steps:
- - name: mark the job as a success
- run: exit 0
- shell: bash
+ outcome:
name: bors build finished
runs-on: ubuntu-latest
- try-failure:
needs:
- job
- if: "!success() && github.event_name == 'push' && (github.ref == 'refs/heads/try' || github.ref == 'refs/heads/try-perf') && github.repository == 'rust-lang-ci/rust'"
- steps:
- - name: mark the job as a failure
- run: exit 1
- shell: bash
- name: bors build finished
- runs-on: ubuntu-latest
- auto-success:
- needs:
- - job
- if: "success() && github.event_name == 'push' && github.ref == 'refs/heads/auto' && github.repository == 'rust-lang-ci/rust'"
+ if: "!cancelled() && github.event_name == 'push'"
steps:
- name: checkout the source code
uses: actions/checkout@v4
with:
fetch-depth: 2
+ - name: calculate the correct exit status
+ id: status
+ run: "jq --exit-status 'all(.result == \"success\" or .result == \"skipped\")' <<< '${{ toJson(needs) }}'\necho \"status=$?\" >> $GITHUB_OUTPUT\n"
- name: publish toolstate
run: src/ci/publish_toolstate.sh
shell: bash
+ if: "steps.outputs.status == 0 && github.event_name == 'push' && github.ref == 'refs/heads/auto' && github.repository == 'rust-lang-ci/rust'"
env:
TOOLSTATE_REPO_ACCESS_TOKEN: "${{ secrets.TOOLSTATE_REPO_ACCESS_TOKEN }}"
- name: bors build finished
- runs-on: ubuntu-latest
- auto-failure:
- needs:
- - job
- if: "!success() && github.event_name == 'push' && github.ref == 'refs/heads/auto' && github.repository == 'rust-lang-ci/rust'"
- steps:
- - name: mark the job as a failure
- run: exit 1
- shell: bash
- name: bors build finished
- runs-on: ubuntu-latest
+ - name: set the correct exit status
+ run: "exit ${{ steps.outputs.status == 0 }}"
diff --git a/src/ci/github-actions/ci.yml b/src/ci/github-actions/ci.yml
index 95d2225..4ca7b52 100644
--- a/src/ci/github-actions/ci.yml
+++ b/src/ci/github-actions/ci.yml
@@ -270,33 +270,32 @@
# erroring about invalid credentials instead.
if: success() && (github.event_name == 'push' || env.DEPLOY == '1' || env.DEPLOY_ALT == '1')
- # These jobs don't actually test anything, but they're used to tell bors the
- # build completed, as there is no practical way to detect when a workflow is
- # successful listening to webhooks only.
- try-success:
+ # This job isused to tell bors the final status of the build, as there is no practical way to detect
+ # when a workflow is successful listening to webhooks only in our current bors implementation (homu).
+ outcome:
+ name: bors build finished
+ runs-on: ubuntu-latest
needs: [ job ]
- if: "success() && github.event_name == 'push' && (github.ref == 'refs/heads/try' || github.ref == 'refs/heads/try-perf') && github.repository == 'rust-lang-ci/rust'"
- <<: *base-success-job
- try-failure:
- needs: [ job ]
- if: "!success() && github.event_name == 'push' && (github.ref == 'refs/heads/try' || github.ref == 'refs/heads/try-perf') && github.repository == 'rust-lang-ci/rust'"
- <<: *base-failure-job
- auto-success:
- needs: [ job ]
- if: "success() && github.event_name == 'push' && github.ref == 'refs/heads/auto' && github.repository == 'rust-lang-ci/rust'"
- <<: *base-outcome-job
+ # !cancelled() executes the job regardless of whether the previous jobs passed or failed
+ if: "!cancelled() && github.event_name == 'push'"
steps:
- name: checkout the source code
uses: actions/checkout@v4
with:
fetch-depth: 2
+ # Calculate the exit status of the whole CI workflow (0 if all dependent jobs were either successful
+ # or skipped, otherwise 1).
+ - name: calculate the correct exit status
+ id: status
+ run: |
+ jq --exit-status 'all(.result == "success" or .result == "skipped")' <<< '${{ toJson(needs) }}'
+ echo "status=$?" >> $GITHUB_OUTPUT
+ # Publish the toolstate if an auto build succeeds (just before push to master)
- name: publish toolstate
run: src/ci/publish_toolstate.sh
shell: bash
+ if: steps.outputs.status == 0 && github.event_name == 'push' && github.ref == 'refs/heads/auto' && github.repository == 'rust-lang-ci/rust'
env:
TOOLSTATE_REPO_ACCESS_TOKEN: ${{ secrets.TOOLSTATE_REPO_ACCESS_TOKEN }}
-
- auto-failure:
- needs: [ job ]
- if: "!success() && github.event_name == 'push' && github.ref == 'refs/heads/auto' && github.repository == 'rust-lang-ci/rust'"
- <<: *base-failure-job
+ - name: set the correct exit status
+ run: exit ${{ steps.outputs.status }}