Skip to content

Collapse -success and -failure jobs into an -outcome job #124014

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
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
38 changes: 8 additions & 30 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -753,43 +753,21 @@ jobs:
env:
TOOLSTATE_REPO_ACCESS_TOKEN: "${{ secrets.TOOLSTATE_REPO_ACCESS_TOKEN }}"
if: success() && !env.SKIP_JOB
try-success:
try-outcome:
needs:
- try
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
if: "!cancelled() && github.event_name == 'push' && (github.ref == 'refs/heads/try' || github.ref == 'refs/heads/try-perf') && github.repository == 'rust-lang-ci/rust'"
name: bors build finished
runs-on: ubuntu-latest
try-failure:
needs:
- try
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:
- name: set the correct exit status
run: "jq --exit-status 'all(.result == \"success\" or .result == \"skipped\")' <<< '${{ toJson(needs) }}'"
auto-outcome:
needs:
- auto
if: "success() && github.event_name == 'push' && github.ref == 'refs/heads/auto' && github.repository == 'rust-lang-ci/rust'"
steps:
- name: mark the job as a success
run: exit 0
shell: bash
if: "!cancelled() && github.event_name == 'push' && github.ref == 'refs/heads/auto' && github.repository == 'rust-lang-ci/rust'"
name: bors build finished
runs-on: ubuntu-latest
auto-failure:
needs:
- auto
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: "jq --exit-status 'all(.result == \"success\" or .result == \"skipped\")' <<< '${{ toJson(needs) }}'"
39 changes: 12 additions & 27 deletions src/ci/github-actions/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -290,20 +290,11 @@ x--expand-yaml-anchors--remove:
- &base-outcome-job
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment above this isn't updated (it still mentions try-success etc.)

name: bors build finished
runs-on: ubuntu-latest

- &base-success-job
steps:
- name: mark the job as a success
run: exit 0
shell: bash
<<: *base-outcome-job

- &base-failure-job
steps:
- name: mark the job as a failure
run: exit 1
shell: bash
<<: *base-outcome-job
# Set the exit status to 0 if all dependency jobs were either successful
# or skipped, otherwise set it to 1.
- name: set the correct exit status
run: jq --exit-status 'all(.result == "success" or .result == "skipped")' <<< '${{ toJson(needs) }}'

###########################
# Builders definition #
Expand Down Expand Up @@ -790,19 +781,13 @@ jobs:
# 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: [try]
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:
try-outcome:
needs: [try]
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: [auto]
if: "success() && github.event_name == 'push' && github.ref == 'refs/heads/auto' && github.repository == 'rust-lang-ci/rust'"
<<: *base-success-job
auto-failure:
# !cancelled() executes the job regardless of whether it passed or failed
if: "!cancelled() && github.event_name == 'push' && (github.ref == 'refs/heads/try' || github.ref == 'refs/heads/try-perf') && github.repository == 'rust-lang-ci/rust'"
Copy link
Contributor

@Kobzol Kobzol Apr 16, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just thinking out loud: do we actually need this if (more specifically, the github.XXX parts? Shouldn't this job be skipped automatically if try (which it needs) is skipped?

<<: *base-outcome-job
auto-outcome:
needs: [auto]
if: "!success() && github.event_name == 'push' && github.ref == 'refs/heads/auto' && github.repository == 'rust-lang-ci/rust'"
<<: *base-failure-job
# !cancelled() executes the job regardless of whether it passed or failed
if: "!cancelled() && github.event_name == 'push' && github.ref == 'refs/heads/auto' && github.repository == 'rust-lang-ci/rust'"
<<: *base-outcome-job
Loading