mirror of
https://github.com/servo/servo
synced 2026-04-25 17:15:48 +02:00
Follow-up to #39812, using nextests builtin retry feature to rerun flaky unit-tests. This also adds a per-test timeout, replacing the global timeout set for the retry action. We could also add a global timeout for nextest tests, but per-test timeouts should be sufficient and noticably speedup CI when individual unit tests get stuck. Testing: [mach try](https://github.com/servo/servo/actions/runs/18519094535) running the unit-tests with retries in CI. --------- Signed-off-by: Jonathan Schwender <schwenderjonathan@gmail.com>
445 lines
16 KiB
YAML
445 lines
16 KiB
YAML
name: Linux
|
|
on:
|
|
workflow_call:
|
|
inputs:
|
|
profile:
|
|
required: false
|
|
default: "release"
|
|
type: string
|
|
build-args:
|
|
default: ""
|
|
required: false
|
|
type: string
|
|
wpt-args:
|
|
default: ""
|
|
required: false
|
|
type: string
|
|
wpt-sync-from-upstream:
|
|
required: false
|
|
default: false
|
|
type: boolean
|
|
wpt:
|
|
required: false
|
|
type: boolean
|
|
number-of-wpt-chunks:
|
|
default: 20
|
|
required: false
|
|
type: number
|
|
unit-tests:
|
|
required: false
|
|
default: false
|
|
type: boolean
|
|
build-libservo:
|
|
required: false
|
|
default: false
|
|
type: boolean
|
|
upload:
|
|
required: false
|
|
default: false
|
|
type: boolean
|
|
github-release-id:
|
|
required: false
|
|
type: string
|
|
force-github-hosted-runner:
|
|
required: false
|
|
type: boolean
|
|
default: false
|
|
bencher:
|
|
required: false
|
|
default: false
|
|
type: boolean
|
|
coverage:
|
|
required: false
|
|
default: false
|
|
type: boolean
|
|
workflow_dispatch:
|
|
inputs:
|
|
profile:
|
|
required: false
|
|
default: "release"
|
|
type: choice
|
|
options: ["release", "debug", "production"]
|
|
wpt-args:
|
|
default: ""
|
|
required: false
|
|
type: string
|
|
wpt-sync-from-upstream:
|
|
default: false
|
|
required: false
|
|
type: boolean
|
|
wpt:
|
|
required: false
|
|
type: boolean
|
|
number-of-wpt-chunks:
|
|
default: 20
|
|
required: false
|
|
type: number
|
|
unit-tests:
|
|
required: false
|
|
default: false
|
|
type: boolean
|
|
build-libservo:
|
|
required: false
|
|
default: false
|
|
type: boolean
|
|
upload:
|
|
required: false
|
|
default: false
|
|
type: boolean
|
|
force-github-hosted-runner:
|
|
required: false
|
|
type: boolean
|
|
default: false
|
|
bencher:
|
|
required: false
|
|
default: false
|
|
type: boolean
|
|
|
|
env:
|
|
RUST_BACKTRACE: 1
|
|
SHELL: /bin/bash
|
|
|
|
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:
|
|
runs-on: ubuntu-22.04
|
|
outputs:
|
|
unique-id: ${{ steps.select.outputs.unique-id }}
|
|
selected-runner-label: ${{ steps.select.outputs.selected-runner-label }}
|
|
runner-type-label: ${{ steps.select.outputs.runner-type-label }}
|
|
is-self-hosted: ${{ steps.select.outputs.is-self-hosted }}
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
with:
|
|
sparse-checkout: '.github'
|
|
- name: Runner select
|
|
id: select
|
|
uses: ./.github/actions/runner-select
|
|
with:
|
|
monitor-api-token: ${{ secrets.SERVO_CI_MONITOR_API_TOKEN }}
|
|
# Before updating the GH action runner image for the nightly job, ensure
|
|
# that the system has a glibc version that is compatible with the one
|
|
# used by the wpt.fyi runners.
|
|
github-hosted-runner-label: ubuntu-22.04
|
|
self-hosted-image-name: servo-ubuntu2204
|
|
# You can disable self-hosted runners globally by creating a repository variable named
|
|
# NO_SELF_HOSTED_RUNNERS with any non-empty value.
|
|
# <https://github.com/servo/servo/settings/variables/actions>
|
|
NO_SELF_HOSTED_RUNNERS: ${{ vars.NO_SELF_HOSTED_RUNNERS }}
|
|
# Any other boolean conditions that disable self-hosted runners go here.
|
|
force-github-hosted-runner: ${{ inputs.upload || inputs.force-github-hosted-runner }}
|
|
runner-timeout:
|
|
needs:
|
|
- runner-select
|
|
if: ${{ fromJSON(needs.runner-select.outputs.is-self-hosted) }}
|
|
runs-on: ubuntu-22.04
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
with:
|
|
sparse-checkout: '.github'
|
|
- name: Runner timeout
|
|
uses: ./.github/actions/runner-timeout
|
|
with:
|
|
github_token: '${{ secrets.GITHUB_TOKEN }}'
|
|
unique-id: '${{ needs.runner-select.outputs.unique-id }}'
|
|
|
|
build:
|
|
needs:
|
|
- runner-select
|
|
name: Linux Build [${{ needs.runner-select.outputs.unique-id }}]
|
|
runs-on: ${{ needs.runner-select.outputs.selected-runner-label }}
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
if: ${{ runner.environment != '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: ${{ runner.environment != '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: ${{ runner.environment == 'self-hosted' && github.event_name != 'pull_request_target' }}
|
|
run: git fetch --depth=1 origin $GITHUB_SHA
|
|
- if: ${{ runner.environment == 'self-hosted' && github.event_name == 'pull_request_target' }}
|
|
run: git fetch --depth=1 origin ${{ github.event.pull_request.head.sha }}
|
|
- if: ${{ runner.environment == '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
|
|
- name: Free Disk Space (Ubuntu)
|
|
uses: jlumbroso/free-disk-space@main
|
|
if: ${{ runner.environment != 'self-hosted' }}
|
|
with:
|
|
tool-cache: false
|
|
large-packages: false
|
|
swap-storage: false
|
|
- name: Set LIBCLANG_PATH env # needed for bindgen in mozangle
|
|
if: ${{ runner.environment != 'self-hosted' }}
|
|
run: echo "LIBCLANG_PATH=/usr/lib/llvm-14/lib" >> $GITHUB_ENV
|
|
- name: Setup Python
|
|
if: ${{ runner.environment != 'self-hosted' }}
|
|
uses: ./.github/actions/setup-python
|
|
- name: Change Mirror Priorities
|
|
if: ${{ runner.environment != 'self-hosted' }}
|
|
uses: ./.github/actions/apt-mirrors
|
|
- uses: taiki-e/install-action@v2
|
|
with:
|
|
tool: nextest
|
|
- name: Bootstrap dependencies
|
|
if: ${{ runner.environment != 'self-hosted' }}
|
|
timeout-minutes: 10
|
|
run: |
|
|
sudo apt update
|
|
./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: |
|
|
./mach build --use-crown --locked --${{ inputs.profile }} ${{ inputs.build-args }}
|
|
cp -r target/cargo-timings target/cargo-timings-linux
|
|
- name: Smoketest
|
|
run: xvfb-run ./mach smoketest --${{ inputs.profile }}
|
|
- name: Script tests
|
|
run: ./mach test-scripts
|
|
- name: Unit tests
|
|
if: ${{ inputs.unit-tests }}
|
|
env:
|
|
NEXTEST_RETRIES: 2 # https://github.com/servo/servo/issues/30683
|
|
run: ./mach test-unit --${{ inputs.profile }}
|
|
- name: Devtools tests
|
|
if: ${{ inputs.unit-tests }}
|
|
run: ./mach test-devtools --${{ inputs.profile }}
|
|
- name: Archive build timing
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: cargo-timings-linux-${{ inputs.profile }}
|
|
# Using a wildcard here ensures that the archive includes the path.
|
|
path: target/cargo-timings-*
|
|
- name: Build mach package
|
|
run: ./mach package --${{ inputs.profile }}
|
|
- name: Upload artifact for mach package
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: linux-${{ inputs.profile }}
|
|
path: target/${{ inputs.profile }}/servo-tech-demo.tar.gz
|
|
- name: Upload nightly
|
|
if: ${{ inputs.upload }}
|
|
run: |
|
|
./mach upload-nightly linux \
|
|
--secret-from-environment \
|
|
--github-release-id ${{ inputs.github-release-id }}
|
|
env:
|
|
S3_UPLOAD_CREDENTIALS: ${{ secrets.S3_UPLOAD_CREDENTIALS }}
|
|
NIGHTLY_REPO_TOKEN: ${{ secrets.NIGHTLY_REPO_TOKEN }}
|
|
NIGHTLY_REPO: ${{ github.repository_owner }}/servo-nightly-builds
|
|
- name: Build package for target
|
|
run: tar -czf target.tar.gz target/${{ inputs.profile }}/servo resources
|
|
- name: Upload artifact for target
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: ${{ inputs.profile }}-binary-linux
|
|
path: target.tar.gz
|
|
|
|
wpt-2020:
|
|
if: ${{ inputs.wpt }}
|
|
name: Linux WPT
|
|
needs: ["build"]
|
|
uses: ./.github/workflows/linux-wpt.yml
|
|
with:
|
|
wpt-args: ${{ inputs.wpt-args }}
|
|
profile: ${{ inputs.profile }}
|
|
wpt-sync-from-upstream: ${{ inputs.wpt-sync-from-upstream }}
|
|
number-of-wpt-chunks: ${{ inputs. number-of-wpt-chunks }}
|
|
secrets: inherit
|
|
|
|
bencher:
|
|
needs: ["build"]
|
|
if: ${{ inputs.bencher && inputs.profile != 'debug' && github.event_name != 'workflow_dispatch' && github.event_name != 'merge_group' }}
|
|
uses: ./.github/workflows/bencher.yml
|
|
with:
|
|
target: 'linux'
|
|
profile: ${{ inputs.profile }}
|
|
compressed-file-path: ${{ inputs.profile }}-binary-linux/target.tar.gz
|
|
binary-path: target/${{ inputs.profile }}/servo
|
|
file-size: true
|
|
# We only evaluate speedometer and dromaeo score in release
|
|
speedometer: ${{ inputs.profile == 'release' }}
|
|
dromaeo: ${{ inputs.profile == 'release' }}
|
|
secrets: inherit
|
|
|
|
build-libservo:
|
|
if: ${{ inputs.build-libservo }}
|
|
name: Build libservo and MSRV check
|
|
runs-on: ubuntu-22.04
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
if: github.event_name != 'pull_request_target'
|
|
with:
|
|
fetch-depth: 1
|
|
# 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'
|
|
with:
|
|
ref: ${{ github.event.pull_request.head.sha }}
|
|
fetch-depth: 1
|
|
- name: Set LIBCLANG_PATH env # needed for bindgen in mozangle
|
|
run: echo "LIBCLANG_PATH=/usr/lib/llvm-14/lib" >> $GITHUB_ENV
|
|
- name: Setup Python
|
|
uses: ./.github/actions/setup-python
|
|
- name: Determine MSRV
|
|
id: msrv
|
|
uses: ./.github/actions/parse_msrv
|
|
- name: Install MSRV
|
|
uses: dtolnay/rust-toolchain@master
|
|
with:
|
|
toolchain: ${{ steps.msrv.outputs.rust_version }}
|
|
- name: Compile libservo with MSRV
|
|
run: |
|
|
cargo +${{ steps.msrv.outputs.rust_version }} build -p libservo --locked --all-targets
|
|
|
|
# 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-coverage:
|
|
if: inputs.coverage
|
|
runs-on: ubuntu-22.04
|
|
outputs:
|
|
unique-id: ${{ steps.select.outputs.unique-id }}
|
|
selected-runner-label: ${{ steps.select.outputs.selected-runner-label }}
|
|
is-self-hosted: ${{ steps.select.outputs.is-self-hosted }}
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
with:
|
|
sparse-checkout: '.github'
|
|
- name: Runner select
|
|
id: select
|
|
uses: ./.github/actions/runner-select
|
|
with:
|
|
monitor-api-token: ${{ secrets.SERVO_CI_MONITOR_API_TOKEN }}
|
|
# Before updating the GH action runner image for the nightly job, ensure
|
|
# that the system has a glibc version that is compatible with the one
|
|
# used by the wpt.fyi runners.
|
|
github-hosted-runner-label: ubuntu-22.04
|
|
self-hosted-image-name: servo-ubuntu2204
|
|
# You can disable self-hosted runners globally by creating a repository variable named
|
|
# NO_SELF_HOSTED_RUNNERS with any non-empty value.
|
|
# <https://github.com/servo/servo/settings/variables/actions>
|
|
NO_SELF_HOSTED_RUNNERS: ${{ vars.NO_SELF_HOSTED_RUNNERS }}
|
|
# Any other boolean conditions that disable self-hosted runners go here.
|
|
force-github-hosted-runner: ${{ inputs.force-github-hosted-runner }}
|
|
runner-timeout-coverage:
|
|
needs:
|
|
- runner-select-coverage
|
|
if: inputs.coverage && fromJSON(needs.runner-select-coverage.outputs.is-self-hosted)
|
|
runs-on: ubuntu-22.04
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
with:
|
|
sparse-checkout: '.github'
|
|
- name: Runner timeout
|
|
uses: ./.github/actions/runner-timeout
|
|
with:
|
|
github_token: '${{ secrets.GITHUB_TOKEN }}'
|
|
unique-id: '${{ needs.runner-select-coverage.outputs.unique-id }}'
|
|
|
|
unit-test-coverage:
|
|
if: inputs.coverage
|
|
needs: runner-select-coverage
|
|
name: Unit Test Coverage [${{ needs.runner-select-coverage.outputs.unique-id }}]
|
|
runs-on: ${{ needs.runner-select-coverage.outputs.selected-runner-label }}
|
|
continue-on-error: true
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
if: ${{ runner.environment != '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: ${{ runner.environment != '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: ${{ runner.environment == 'self-hosted' && github.event_name != 'pull_request_target' }}
|
|
run: git fetch --depth=1 origin $GITHUB_SHA
|
|
- if: ${{ runner.environment == 'self-hosted' && github.event_name == 'pull_request_target' }}
|
|
run: git fetch --depth=1 origin ${{ github.event.pull_request.head.sha }}
|
|
- if: ${{ runner.environment == '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
|
|
- name: Free Disk Space (Ubuntu)
|
|
uses: jlumbroso/free-disk-space@main
|
|
if: ${{ runner.environment != 'self-hosted' }}
|
|
with:
|
|
tool-cache: false
|
|
large-packages: false
|
|
swap-storage: false
|
|
- name: Set LIBCLANG_PATH env # needed for bindgen in mozangle
|
|
shell: bash
|
|
if: ${{ runner.environment != 'self-hosted' }}
|
|
run: echo "LIBCLANG_PATH=/usr/lib/llvm-14/lib" >> $GITHUB_ENV
|
|
- name: Setup Python
|
|
if: ${{ runner.environment != 'self-hosted' }}
|
|
uses: ./.github/actions/setup-python
|
|
- name: Change Mirror Priorities
|
|
if: ${{ runner.environment != 'self-hosted' }}
|
|
uses: ./.github/actions/apt-mirrors
|
|
- name: Install cargo-llvm-cov
|
|
uses: taiki-e/install-action@v2
|
|
with:
|
|
tool: cargo-llvm-cov
|
|
- name: Bootstrap dependencies
|
|
if: ${{ runner.environment != 'self-hosted' }}
|
|
shell: bash
|
|
run: |
|
|
sudo apt update
|
|
./mach bootstrap --skip-lints
|
|
- name: Determine options
|
|
id: options
|
|
run: |
|
|
if [[ ${{ runner.environment }} == 'self-hosted' ]];
|
|
then
|
|
CARGO_PROFILE=dev
|
|
else
|
|
# github hosted runners don't have enough diskspace for the dev profile.
|
|
CARGO_PROFILE=coverage
|
|
fi
|
|
echo "cargo_profile=${CARGO_PROFILE}" | tee $GITHUB_OUTPUT
|
|
# We can remove this after upgrading to Rust 1.90, but for now
|
|
# installing lld is the easiest way to get it in path.
|
|
- name: install lld
|
|
run: sudo apt-get install -y lld
|
|
- name: Run unit-tests with coverage
|
|
shell: bash
|
|
env:
|
|
RUSTC_BOOTSTRAP: "1"
|
|
# lld seems to use less memory and prevents OOM errors during linking.
|
|
# We can remove this after upgrading to Rust 1.90, where lld will be the default.
|
|
RUSTFLAGS: "-Z linker-features=+lld"
|
|
run: |
|
|
./mach test-unit --code-coverage \
|
|
--profile=${{ steps.options.outputs.cargo_profile }} \
|
|
--llvm-cov-option=--codecov \
|
|
--llvm-cov-option=--output-path=codecov.json
|
|
- name: Upload coverage to Codecov
|
|
uses: codecov/codecov-action@v5
|
|
with:
|
|
token: ${{ secrets.CODECOV_TOKEN }}
|
|
files: codecov.json,support/crown/codecov.json
|
|
fail_ci_if_error: true
|
|
flags: unittests
|