Inline base-ci-job YAML anchor and remove unused anchors

This commit is contained in:
Jakub Beránek 2024-04-24 15:00:42 +02:00
parent 144bdf5bf1
commit 744dc2aa1d
No known key found for this signature in database
GPG Key ID: 909CD0D26483516B
2 changed files with 93 additions and 175 deletions

View File

@ -51,6 +51,11 @@ jobs:
name: "${{ matrix.name }}" name: "${{ matrix.name }}"
needs: needs:
- calculate_matrix - calculate_matrix
runs-on: "${{ matrix.os }}"
defaults:
run:
shell: "${{ contains(matrix.os, 'windows') && 'msys2 {0}' || 'bash' }}"
timeout-minutes: 600
env: env:
CI_JOB_NAME: "${{ matrix.image }}" CI_JOB_NAME: "${{ matrix.image }}"
CARGO_REGISTRIES_CRATES_IO_PROTOCOL: sparse CARGO_REGISTRIES_CRATES_IO_PROTOCOL: sparse
@ -64,11 +69,6 @@ jobs:
matrix: matrix:
include: "${{ fromJSON(needs.calculate_matrix.outputs.jobs) }}" include: "${{ fromJSON(needs.calculate_matrix.outputs.jobs) }}"
if: "fromJSON(needs.calculate_matrix.outputs.jobs)[0] != null" if: "fromJSON(needs.calculate_matrix.outputs.jobs)[0] != null"
defaults:
run:
shell: "${{ contains(matrix.os, 'windows') && 'msys2 {0}' || 'bash' }}"
timeout-minutes: 600
runs-on: "${{ matrix.os }}"
steps: steps:
- if: "contains(matrix.os, 'windows')" - if: "contains(matrix.os, 'windows')"
uses: msys2/setup-msys2@v2.22.0 uses: msys2/setup-msys2@v2.22.0

View File

@ -29,91 +29,107 @@
# The expand-yaml-anchors tool will automatically remove this block from the # The expand-yaml-anchors tool will automatically remove this block from the
# output YAML file. # output YAML file.
x--expand-yaml-anchors--remove: x--expand-yaml-anchors--remove:
- &shared-ci-variables # These snippets are used by the try-success, try-failure, auto-success and auto-failure jobs.
CI_JOB_NAME: ${{ matrix.name }} # Check out their documentation for more information on why they're needed.
CARGO_REGISTRIES_CRATES_IO_PROTOCOL: sparse
# commit of PR sha or commit sha. `GITHUB_SHA` is not accurate for PRs.
HEAD_SHA: ${{ github.event.pull_request.head.sha || github.sha }}
DOCKER_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- &public-variables - &base-outcome-job
SCCACHE_BUCKET: rust-lang-ci-sccache2 name: bors build finished
TOOLSTATE_REPO: https://github.com/rust-lang-nursery/rust-toolstate runs-on: ubuntu-latest
CACHE_DOMAIN: ci-caches.rust-lang.org
- &prod-variables - &base-success-job
SCCACHE_BUCKET: rust-lang-ci-sccache2 steps:
DEPLOY_BUCKET: rust-lang-ci2 - name: mark the job as a success
TOOLSTATE_REPO: https://github.com/rust-lang-nursery/rust-toolstate run: exit 0
TOOLSTATE_ISSUES_API_URL: https://api.github.com/repos/rust-lang/rust/issues shell: bash
TOOLSTATE_PUBLISH: 1 <<: *base-outcome-job
# AWS_SECRET_ACCESS_KEYs are stored in GitHub's secrets storage, named
# AWS_SECRET_ACCESS_KEY_<keyid>. Including the key id in the name allows to
# rotate them in a single branch while keeping the old key in another
# branch, which wouldn't be possible if the key was named with the kind
# (caches, artifacts...).
CACHES_AWS_ACCESS_KEY_ID: AKIA46X5W6CZI5DHEBFL
ARTIFACTS_AWS_ACCESS_KEY_ID: AKIA46X5W6CZN24CBO55
AWS_REGION: us-west-1
CACHE_DOMAIN: ci-caches.rust-lang.org
- &dummy-variables - &base-failure-job
SCCACHE_BUCKET: rust-lang-gha-caches steps:
DEPLOY_BUCKET: rust-lang-gha - name: mark the job as a failure
TOOLSTATE_REPO: https://github.com/pietroalbini/rust-toolstate run: exit 1
TOOLSTATE_ISSUES_API_URL: https://api.github.com/repos/pietroalbini/rust-toolstate/issues shell: bash
TOOLSTATE_PUBLISH: 1 <<: *base-outcome-job
# AWS_SECRET_ACCESS_KEYs are stored in GitHub's secrets storage, named
# AWS_SECRET_ACCESS_KEY_<keyid>. Including the key id in the name allows to
# rotate them in a single branch while keeping the old key in another
# branch, which wouldn't be possible if the key was named with the kind
# (caches, artifacts...).
CACHES_AWS_ACCESS_KEY_ID: AKIA46X5W6CZOMUQATD5
ARTIFACTS_AWS_ACCESS_KEY_ID: AKIA46X5W6CZH5AYXDVF
AWS_REGION: us-west-1
CACHE_DOMAIN: ci-caches-gha.rust-lang.org
- &base-job ###########################
env: {} # Builders definition #
###########################
- &job-linux-4c name: CI
os: ubuntu-20.04-4core-16gb on:
<<: *base-job push:
branches:
- auto
- try
- try-perf
- automation/bors/try
- master
pull_request:
branches:
- "**"
- &job-linux-8c permissions:
os: ubuntu-20.04-8core-32gb contents: read
<<: *base-job packages: write
- &job-linux-16c defaults:
os: ubuntu-20.04-16core-64gb run:
<<: *base-job # On Linux, macOS, and Windows, use the system-provided bash as the default
# shell. (This should only make a difference on Windows, where the default
# shell is PowerShell.)
shell: bash
- &job-macos-xl concurrency:
os: macos-13 # We use the standard runner for now # For a given workflow, if we push to the same branch, cancel all previous builds on that branch.
<<: *base-job # We add an exception for try builds (try branch) and unrolled rollup builds (try-perf), which
# are all triggered on the same branch, but which should be able to run concurrently.
group: ${{ github.workflow }}-${{ ((github.ref == 'refs/heads/try' || github.ref == 'refs/heads/try-perf') && github.sha) || github.ref }}
cancel-in-progress: true
- &job-macos-m1 jobs:
os: macos-14 # The job matrix for `calculate_matrix` is defined in src/ci/github-actions/jobs.yml.
<<: *base-job # It calculates which jobs should be executed, based on the data of the ${{ github }} context.
# If you want to modify CI jobs, take a look at src/ci/github-actions/jobs.yml.
- &job-windows-8c calculate_matrix:
os: windows-2019-8core-32gb name: Calculate job matrix
<<: *base-job runs-on: ubuntu-latest
outputs:
- &job-windows-16c jobs: ${{ steps.jobs.outputs.jobs }}
os: windows-2019-16core-64gb steps:
<<: *base-job - name: Checkout the source code
uses: actions/checkout@v4
- &job-aarch64-linux - name: Calculate the CI job matrix
os: [self-hosted, ARM64, linux] run: python3 src/ci/github-actions/calculate-job-matrix.py >> $GITHUB_OUTPUT
id: jobs
- &base-ci-job job:
name: ${{ matrix.name }}
needs: [ calculate_matrix ]
runs-on: "${{ matrix.os }}"
defaults: defaults:
run: run:
shell: ${{ contains(matrix.os, 'windows') && 'msys2 {0}' || 'bash' }} shell: ${{ contains(matrix.os, 'windows') && 'msys2 {0}' || 'bash' }}
timeout-minutes: 600 timeout-minutes: 600
runs-on: "${{ matrix.os }}" env:
env: *shared-ci-variables CI_JOB_NAME: ${{ matrix.image }}
CARGO_REGISTRIES_CRATES_IO_PROTOCOL: sparse
# commit of PR sha or commit sha. `GITHUB_SHA` is not accurate for PRs.
HEAD_SHA: ${{ github.event.pull_request.head.sha || github.sha }}
DOCKER_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SCCACHE_BUCKET: rust-lang-ci-sccache2
TOOLSTATE_REPO: https://github.com/rust-lang-nursery/rust-toolstate
CACHE_DOMAIN: ci-caches.rust-lang.org
continue-on-error: ${{ matrix.continue_on_error || false }}
strategy:
matrix:
# Check the `calculate_matrix` job to see how is the matrix defined.
include: ${{ fromJSON(needs.calculate_matrix.outputs.jobs) }}
# GitHub Actions fails the workflow if an empty list of jobs is provided to
# the workflow, so we need to skip this job if nothing was produced by
# the Python script.
#
# Unfortunately checking whether a list is empty is not possible in a nice
# way due to GitHub Actions expressions limits.
# This hack is taken from https://github.com/ferrocene/ferrocene/blob/d43edc6b7697cf1719ec1c17c54904ab94825763/.github/workflows/release.yml#L75-L82
if: fromJSON(needs.calculate_matrix.outputs.jobs)[0] != null
steps: steps:
- if: contains(matrix.os, 'windows') - if: contains(matrix.os, 'windows')
uses: msys2/setup-msys2@v2.22.0 uses: msys2/setup-msys2@v2.22.0
@ -253,104 +269,6 @@ x--expand-yaml-anchors--remove:
# erroring about invalid credentials instead. # erroring about invalid credentials instead.
if: success() && (github.event_name == 'push' || env.DEPLOY == '1' || env.DEPLOY_ALT == '1') if: success() && (github.event_name == 'push' || env.DEPLOY == '1' || env.DEPLOY_ALT == '1')
# These snippets are used by the try-success, try-failure, auto-success and auto-failure jobs.
# Check out their documentation for more information on why they're needed.
- &base-outcome-job
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
###########################
# Builders definition #
###########################
name: CI
on:
push:
branches:
- auto
- try
- try-perf
- automation/bors/try
- master
pull_request:
branches:
- "**"
permissions:
contents: read
packages: write
defaults:
run:
# On Linux, macOS, and Windows, use the system-provided bash as the default
# shell. (This should only make a difference on Windows, where the default
# shell is PowerShell.)
shell: bash
concurrency:
# For a given workflow, if we push to the same branch, cancel all previous builds on that branch.
# We add an exception for try builds (try branch) and unrolled rollup builds (try-perf), which
# are all triggered on the same branch, but which should be able to run concurrently.
group: ${{ github.workflow }}-${{ ((github.ref == 'refs/heads/try' || github.ref == 'refs/heads/try-perf') && github.sha) || github.ref }}
cancel-in-progress: true
jobs:
# The job matrix for `calculate_matrix` is defined in src/ci/github-actions/jobs.yml.
# It calculates which jobs should be executed, based on the data of the ${{ github }} context.
# If you want to modify CI jobs, take a look at src/ci/github-actions/jobs.yml.
calculate_matrix:
name: Calculate job matrix
runs-on: ubuntu-latest
outputs:
jobs: ${{ steps.jobs.outputs.jobs }}
steps:
- name: Checkout the source code
uses: actions/checkout@v4
- name: Calculate the CI job matrix
run: python3 src/ci/github-actions/calculate-job-matrix.py >> $GITHUB_OUTPUT
id: jobs
job:
<<: *base-ci-job
name: ${{ matrix.name }}
needs: [ calculate_matrix ]
env:
CI_JOB_NAME: ${{ matrix.image }}
CARGO_REGISTRIES_CRATES_IO_PROTOCOL: sparse
# commit of PR sha or commit sha. `GITHUB_SHA` is not accurate for PRs.
HEAD_SHA: ${{ github.event.pull_request.head.sha || github.sha }}
DOCKER_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SCCACHE_BUCKET: rust-lang-ci-sccache2
TOOLSTATE_REPO: https://github.com/rust-lang-nursery/rust-toolstate
CACHE_DOMAIN: ci-caches.rust-lang.org
continue-on-error: ${{ matrix.continue_on_error || false }}
strategy:
matrix:
# Check the `calculate_matrix` job to see how is the matrix defined.
include: ${{ fromJSON(needs.calculate_matrix.outputs.jobs) }}
# GitHub Actions fails the workflow if an empty list of jobs is provided to
# the workflow, so we need to skip this job if nothing was produced by
# the Python script.
#
# Unfortunately checking whether a list is empty is not possible in a nice
# way due to GitHub Actions expressions limits.
# This hack is taken from https://github.com/ferrocene/ferrocene/blob/d43edc6b7697cf1719ec1c17c54904ab94825763/.github/workflows/release.yml#L75-L82
if: fromJSON(needs.calculate_matrix.outputs.jobs)[0] != null
# These jobs don't actually test anything, but they're used to tell bors the # 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 # build completed, as there is no practical way to detect when a workflow is
# successful listening to webhooks only. # successful listening to webhooks only.