about summary refs log tree commit diff
path: root/src/ci/github-actions
diff options
context:
space:
mode:
authorJakub Beránek <berykubik@gmail.com>2024-04-25 11:04:49 +0200
committerJakub Beránek <berykubik@gmail.com>2024-04-29 21:28:52 +0200
commit23341500a619b61fab3bae82c01d18e6407def0a (patch)
tree23db778d673e2ad81b2b5d6964bb4436cb468124 /src/ci/github-actions
parente27af2917b80487e9c0de00118fdcb9ccb1177f9 (diff)
downloadrust-23341500a619b61fab3bae82c01d18e6407def0a.tar.gz
rust-23341500a619b61fab3bae82c01d18e6407def0a.zip
Unify outcome jobs
Diffstat (limited to 'src/ci/github-actions')
-rw-r--r--src/ci/github-actions/ci.yml37
1 files changed, 18 insertions, 19 deletions
diff --git a/src/ci/github-actions/ci.yml b/src/ci/github-actions/ci.yml
index 95d2225a6b1..4ca7b52bc02 100644
--- a/src/ci/github-actions/ci.yml
+++ b/src/ci/github-actions/ci.yml
@@ -270,33 +270,32 @@ jobs:
         # 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:
-    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:
+  # 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/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 }}