Files
servo/.github/workflows/linux.yml
Martin Robinson eeb31a3cec deps: Merge the servo/media repository (#42369)
This change merges http://github.com/servo/media into this repository.
It is only used by Servo and version upgrades are complicated by having
two repositories. In addition, this avoids the need to refer to
individual commit hashes in the Servo `Cargo.toml`. The hope is that
merging these two repositories will lead to better code organization /
simplification like we have seen with the WebXR support. Initiailly, the
idea was that this media support could be shared with the wider Rust
ecosystem, but I think that hasn't worked out as planned due to the fact
that it is difficult to use the various media packaes outside of the
Servo project and the fact that no one seems to be doing this.

Some changes were made when importing the code:
- The second commit in this PR addresses new clippy warnings from the
imported code.
 - GStreamer Packages are no longer renamed in the media code, so that
   they are named the same as they are currently in Servo.
 - Some examples are not ported as they require being run interactively
   and depend on older version of important libraries like winit.
   Having these dependencies in the core part of Servo isn't very
   convenient. Removed examples:
   - `audio_decoder.rs`: This is meant to be run interactively with a
     file so isn't very useful for testing.
   - Depended on winit GUI (`player` subdirectory):
     - `media_element_source_node.rs`
     - `play_media_stream.rs`
     - `simple_player.rs`
     - `muted_player.rs`
   - `siple_webrtc.rs`: Depended on `webrtc` library:

Testing: This is covered by existing tests. In addition, the job which
runs
the media examples is added to the unit test workflow.

---------

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
2026-02-06 17:00:03 +00:00

433 lines
16 KiB
YAML

name: Linux
on:
workflow_call:
outputs:
artifact_ids:
value: ${{ jobs.build.outputs.artifact_ids }}
description: Comma-separated list of artifact IDs for the release artifacts
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
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
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-24.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: Runner select
id: select
uses: servo/ci-runners/actions/runner-select@6d88b19dda997f1ce2a11e4c1c34717c2bbcafba
with:
GITHUB_TOKEN: ${{ github.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 }}
build:
needs:
- runner-select
name: Linux Build [${{ needs.runner-select.outputs.unique-id }}]
runs-on: ${{ needs.runner-select.outputs.selected-runner-label }}
outputs:
artifact_ids: ${{ steps.artifact_ids.outputs.artifact_ids }}
steps:
- uses: servo/ci-runners/actions/checkout@6d88b19dda997f1ce2a11e4c1c34717c2bbcafba
- 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: 30
run: |
sudo apt update
echo "wireshark-common wireshark-common/install-setuid boolean true" | sudo debconf-set-selections
sudo apt install -qy tshark
./mach bootstrap --yes --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 --profile ${{ inputs.profile }} ${{ inputs.build-args }}
cp -r target/cargo-timings target/cargo-timings-linux
- name: Smoketest
run: xvfb-run ./mach smoketest --profile ${{ inputs.profile }}
- name: Script tests
run: ./mach test-scripts
- name: Unit tests
id: run_unit_tests
if: ${{ inputs.unit-tests }}
env:
NEXTEST_RETRIES: 2 # https://github.com/servo/servo/issues/30683
run: ./mach test-unit --profile ${{ inputs.profile }} --nextest-profile ci
# We upload the test-results to Codecov to help us identify flaky unit-tests.
- name: Upload test results to Codecov
# Upload test results to Codecov, also for failed unit-tests, but only
# if unit-tests were supposed to run, and not if they were skipped (e.g., due
# to an earlier failure).
if: ${{ !cancelled() && steps.run_unit_tests.conclusion != 'skipped' }}
uses: codecov/codecov-action@v5
with:
report_type: test_results
files: target/nextest/ci/junit.xml
disable_search: true
flags: unittests,unittests-linux,unittests-linux-${{ inputs.profile }}
token: ${{ secrets.CODECOV_TOKEN }}
- name: Devtools tests
if: ${{ false && inputs.unit-tests }} # FIXME #39273
run: ./mach test-devtools --profile ${{ inputs.profile }}
- name: Archive build timing
uses: actions/upload-artifact@v6
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 --profile ${{ inputs.profile }}
- name: Upload artifact for mach package
uses: actions/upload-artifact@v6
id: upload-tarball
with:
name: ${{ inputs.profile }}-binary-linux
path: target/${{ inputs.profile }}/servo-tech-demo.tar.gz
- name: Collect artifact IDs needed by the release workflow
id: artifact_ids
shell: bash
run: |
echo "artifact_ids=${{steps.upload-tarball.outputs.artifact-id}}" >> $GITHUB_OUTPUT
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 }}
binary-path: servo/servo
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/servo-tech-demo.tar.gz
binary-path: servo/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@v5
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@v5
if: github.event_name == 'pull_request_target'
with:
ref: ${{ github.event.pull_request.head.sha }}
fetch-depth: 1
- 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
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.
runner-select-coverage:
if: inputs.coverage
runs-on: ubuntu-24.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: Runner select
id: select
uses: servo/ci-runners/actions/runner-select@6d88b19dda997f1ce2a11e4c1c34717c2bbcafba
with:
GITHUB_TOKEN: ${{ github.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 }}
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: servo/ci-runners/actions/checkout@6d88b19dda997f1ce2a11e4c1c34717c2bbcafba
- 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,cargo-nextest
- name: Bootstrap dependencies
if: ${{ runner.environment != 'self-hosted' }}
timeout-minutes: 30
shell: bash
run: |
sudo apt update
./mach bootstrap --yes --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
- name: Run unit-tests with coverage
shell: bash
env:
NEXTEST_RETRIES: 2 # https://github.com/servo/servo/issues/30683
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
media-examples:
name: Media Examples
if: ${{ inputs.unit-tests }}
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v5
if: github.event_name != 'pull_request_target'
with:
fetch-depth: 1
- name: Install Dependencies
run: |
sudo bash -c 'apt-add-repository -y https://mirrors.kernel.org/ubuntu'
sudo apt update
sudo apt install -y \
gstreamer1.0-libav \
gstreamer1.0-plugins-bad \
gstreamer1.0-plugins-base \
gstreamer1.0-plugins-good \
gstreamer1.0-plugins-ugly \
gstreamer1.0-tools \
libasound2-plugins \
libfaad2 \
libffi7 \
libfftw3-single3 \
libges-1.0-dev \
libgstreamer-plugins-bad1.0-dev\
libgstreamer-plugins-base1.0-dev \
libgstreamer1.0-dev \
libgstrtspserver-1.0-dev \
libjack-jackd2-0 \
libmms0 \
libmpg123-0 \
libopus0 \
liborc-0.4-0 \
liborc-0.4-dev \
libpulsedsp \
libsamplerate0 \
libspeexdsp1 \
libtdb1 \
libtheora0 \
libtwolame0 \
libwayland-egl1-mesa \
libwebrtc-audio-processing1 \
pulseaudio \
pulseaudio-utils \
webp
- 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: Virtual Audio Devices
run: |
jackd -d dummy &
pulseaudio --start
gst-inspect-1.0 | grep Total
- name: Run Examples
run: |
ls components/media/examples/examples/*.rs | xargs -I{} basename {} .rs | grep -v params_connect | RUST_BACKTRACE=1 GST_DEBUG=3 xargs -I{} cargo run -p media-examples --example {}