CI: use self-hosted runners for Linux build jobs (#33321)

* CI: use self-hosted runners for Linux build jobs

Signed-off-by: Delan Azabani <dazabani@igalia.com>

* Set ccache and incremental env variables when not self-hosted

Signed-off-by: Delan Azabani <dazabani@igalia.com>

* Force GitHub-hosted runner when in upload mode

Signed-off-by: Delan Azabani <dazabani@igalia.com>

* Revert s/python/python3/ now that our image has python

Signed-off-by: Delan Azabani <dazabani@igalia.com>

* Remove stray comment in timeout workflow

Signed-off-by: Delan Azabani <dazabani@igalia.com>

* Update description of runner-select job

Signed-off-by: Delan Azabani <dazabani@igalia.com>

* Apply suggestions from code review

Address couple minor naming / formatting nits

Signed-off-by: Martin Robinson <mrobinson@igalia.com>

---------

Signed-off-by: Delan Azabani <dazabani@igalia.com>
Signed-off-by: Martin Robinson <mrobinson@igalia.com>
Co-authored-by: Martin Robinson <mrobinson@igalia.com>
This commit is contained in:
Delan Azabani 2024-09-08 23:06:44 +08:00 committed by GitHub
parent e70507ca40
commit 8bb739b818
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 207 additions and 104 deletions

View file

@ -59,43 +59,89 @@ on:
env:
RUST_BACKTRACE: 1
SHELL: /bin/bash
SCCACHE_GHA_ENABLED: "true"
RUSTC_WRAPPER: "sccache"
CCACHE: "sccache"
CARGO_INCREMENTAL: 0
jobs:
# Runs the underlying job (“workload”) on a self-hosted runner if available,
# with the help of a `runner-select` job and a `runner-timeout` job.
runner-select:
uses: ./.github/workflows/self-hosted-runner-select.yml
secrets: inherit
with:
# Ubuntu 22.04 has glibc 2.34 so the binaries produced
# won't run on systems with older glibc e.g wpt.fyi
# runners which still use 20.04.
github-hosted-runner-label: ubuntu-${{ inputs.upload && '20.04' || '22.04' }}
self-hosted-image-name: servo-ubuntu2204
force-github-hosted-runner: ${{ inputs.upload }}
runner-timeout:
needs:
- runner-select
uses: ./.github/workflows/self-hosted-runner-timeout.yml
secrets: inherit
with:
selected-runner-label: ${{ needs.runner-select.outputs.selected-runner-label }}
is-self-hosted: ${{ fromJSON(needs.runner-select.outputs.is-self-hosted) }}
build:
name: Linux Build
# Ubuntu 22.04 has glibc 2.34 so the binaries produced
# won't run on systems with older glibc e.g wpt.fyi
# runners which still use 20.04.
runs-on: ubuntu-${{ inputs.upload && '20.04' || '22.04' }}
needs:
- runner-select
name: Linux Build [${{ needs.runner-select.outputs.unique-id }}]
runs-on: ${{ needs.runner-select.outputs.selected-runner-label }}
steps:
- if: ${{ ! fromJSON(needs.runner-select.outputs.is-self-hosted) }}
run: |
echo SCCACHE_GHA_ENABLED=true >> $GITHUB_ENV
echo RUSTC_WRAPPER=sccache >> $GITHUB_ENV
echo CCACHE=sccache >> $GITHUB_ENV
echo CARGO_INCREMENTAL=0 >> $GITHUB_ENV
- uses: actions/checkout@v4
if: github.event_name != 'pull_request_target'
if: ${{ ! fromJSON(needs.runner-select.outputs.is-self-hosted) && github.event_name != 'pull_request_target' }}
# This is necessary to checkout the pull request if this run was triggered via a
# `pull_request_target` event.
- uses: actions/checkout@v4
if: github.event_name == 'pull_request_target'
if: ${{ ! fromJSON(needs.runner-select.outputs.is-self-hosted) && github.event_name == 'pull_request_target' }}
with:
ref: ${{ github.event.pull_request.head.sha }}
# Faster checkout for self-hosted runner that uses prebaked repo.
- if: ${{ fromJSON(needs.runner-select.outputs.is-self-hosted) && github.event_name != 'pull_request_target' }}
run: git fetch --depth=1 origin $env:GITHUB_SHA
- if: ${{ fromJSON(needs.runner-select.outputs.is-self-hosted) && github.event_name == 'pull_request_target' }}
run: git fetch --depth=1 origin refs/pull/${{ github.event_number }}/head
- if: ${{ fromJSON(needs.runner-select.outputs.is-self-hosted) }}
# Same as `git switch --detach FETCH_HEAD`, but fixes up dirty working
# trees, in case the runner image was baked with a dirty working tree.
run: |
git switch --detach
git reset --hard FETCH_HEAD
# Install missing tools in a GitHub-hosted runner.
- name: Run sccache-cache
if: ${{ ! fromJSON(needs.runner-select.outputs.is-self-hosted) }}
uses: mozilla-actions/sccache-action@v0.0.4
- name: Set LIBCLANG_PATH env # needed for bindgen in mozangle
if: ${{ !inputs.upload }} # not needed on ubuntu 20.04 used for nightly
if: ${{ ! fromJSON(needs.runner-select.outputs.is-self-hosted) && !inputs.upload }} # not needed on ubuntu 20.04 used for nightly
run: echo "LIBCLANG_PATH=/usr/lib/llvm-14/lib" >> $GITHUB_ENV
- uses: actions/setup-python@v5
if: ${{ ! fromJSON(needs.runner-select.outputs.is-self-hosted) }}
with:
python-version: '3.10'
- name: Install crown
run: cargo install --path support/crown
- name: Bootstrap Python
if: ${{ ! fromJSON(needs.runner-select.outputs.is-self-hosted) }}
run: python3 -m pip install --upgrade pip
- name: Bootstrap dependencies
if: ${{ ! fromJSON(needs.runner-select.outputs.is-self-hosted) }}
run: |
sudo apt update
python3 ./mach bootstrap --skip-lints
# Always install crown, even on self-hosted runners, because it is tightly
# coupled to the rustc version, and we may have the wrong version if the
# commit we are building uses a different rustc version.
- name: Install crown
run: cargo install --path support/crown
- name: Build (${{ inputs.profile }})
run: |
python3 ./mach build --use-crown --locked --${{ inputs.profile }}