Skip to content
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

Update to the latest Linebender CI standard. #38

Merged
merged 1 commit into from
Nov 4, 2024
Merged
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
171 changes: 125 additions & 46 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,43 @@ env:
#
# We don't run clippy with --all-targets because then even --lib and --bins are compiled with
# dev dependencies enabled, which does not match how they would be compiled by users.
# A dev dependency might enable a feature of a regular dependency that we need, but testing
# with --all-targets would not catch that. Thus we split --lib & --bins into a separate step.
# A dev dependency might enable a feature that we need for a regular dependency,
# and checking with --all-targets would not find our feature requirements lacking.
# This problem still applies to cargo resolver version 2.
# Thus we split all the targets into two steps, one with --lib --bins
# and another with --tests --benches --examples.
# Also, we can't give --lib --bins explicitly because then cargo will error on binary-only packages.
# Luckily the default behavior of cargo with no explicit targets is the same but without the error.
#
# We use cargo-hack for a similar reason. Cargo's --workspace will do feature unification across
# the whole workspace. While cargo-hack will instead check each workspace package separately.
#
# Using cargo-hack also allows us to more easily test the feature matrix of our packages.
# We use --each-feature & --optional-deps which will run a separate check for every feature.
#
# The MSRV jobs run only cargo check because different clippy versions can disagree on goals and
# running tests introduces dev dependencies which may require a higher MSRV than the bare package.
#
# We don't save caches in the merge-group cases, because those caches will never be re-used (apart
# from the very rare cases where there are multiple PRs in the merge queue).
# This is because GitHub doesn't share caches between merge queues and the main branch.

name: CI

on:
pull_request:
merge_group:
# We run on push, even though the commit is the same as when we ran in merge_group.
# This allows the cache to be primed.
# See https://github.com/orgs/community/discussions/66430
push:
branches:
- main

jobs:
rustfmt:
fmt:
name: formatting
runs-on: ubuntu-latest
name: cargo fmt
steps:
- uses: actions/checkout@v4

Expand All @@ -51,9 +75,75 @@ jobs:
- name: check copyright headers
run: bash .github/copyright.sh

clippy-stable:
name: cargo clippy
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [windows-latest, macos-latest, ubuntu-latest]
steps:
- uses: actions/checkout@v4

- name: restore cache
uses: Swatinem/rust-cache@v2
with:
save-if: ${{ github.event_name != 'merge_group' }}

- name: install stable toolchain
uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ env.RUST_STABLE_VER }}
components: clippy

- name: install cargo-hack
uses: taiki-e/install-action@v2
with:
tool: cargo-hack

- name: install native dependencies
if: matrix.os == 'ubuntu-latest'
run: sudo apt-get update; sudo apt-get install --no-install-recommends libasound2-dev libudev-dev

- name: cargo clippy
run: cargo hack clippy --workspace --locked --optional-deps --each-feature -- -D warnings

- name: cargo clippy (auxiliary)
run: cargo hack clippy --workspace --locked --optional-deps --each-feature --tests --benches --examples -- -D warnings

clippy-stable-wasm:
name: cargo clippy (wasm32)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: restore cache
uses: Swatinem/rust-cache@v2
with:
save-if: ${{ github.event_name != 'merge_group' }}

- name: install stable toolchain
uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ env.RUST_STABLE_VER }}
targets: wasm32-unknown-unknown
components: clippy

- name: install cargo-hack
uses: taiki-e/install-action@v2
with:
tool: cargo-hack

- name: cargo clippy
run: cargo hack clippy --workspace --locked --target wasm32-unknown-unknown --optional-deps --each-feature -- -D warnings

- name: cargo clippy (auxiliary)
run: cargo hack clippy --workspace --locked --target wasm32-unknown-unknown --optional-deps --each-feature --tests --benches --examples -- -D warnings

test-stable:
name: cargo test
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [windows-latest, macos-latest, ubuntu-latest]
include:
Expand All @@ -65,20 +155,20 @@ jobs:
# TODO: The windows runners theoretically have CPU fallback for GPUs, but
# this failed in initial testing
gpu: 'no'
name: cargo clippy + test
steps:
- uses: actions/checkout@v4

- name: restore cache
uses: Swatinem/rust-cache@v2
with:
save-if: ${{ github.event_name != 'merge_group' }}

- name: install stable toolchain
uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ env.RUST_STABLE_VER }}
components: clippy

- name: restore cache
uses: Swatinem/rust-cache@v2

- name: Install native dependencies
- name: install native dependencies
if: matrix.os == 'ubuntu-latest'
run: sudo apt-get update; sudo apt-get install --no-install-recommends libasound2-dev libudev-dev

Expand All @@ -92,57 +182,42 @@ jobs:
sudo apt-get update
sudo apt install -y xvfb libegl1-mesa libgl1-mesa-dri libxcb-xfixes0-dev mesa-vulkan-drivers

- name: cargo clippy (no default features)
run: cargo clippy --workspace --lib --bins --no-default-features -- -D warnings

- name: cargo clippy (no default features) (auxiliary)
run: cargo clippy --workspace --tests --benches --examples --no-default-features -- -D warnings

- name: cargo clippy (default features)
run: cargo clippy --workspace --lib --bins -- -D warnings

- name: cargo clippy (default features) (auxiliary)
run: cargo clippy --workspace --tests --benches --examples -- -D warnings

- name: cargo clippy (all features)
run: cargo clippy --workspace --lib --bins --all-features -- -D warnings

- name: cargo clippy (all features) (auxiliary)
run: cargo clippy --workspace --tests --benches --examples --all-features -- -D warnings

# At the time of writing, we don't have any tests. Nevertheless, it's better to still run this
- name: cargo test
run: cargo test --workspace --all-features
run: cargo test --workspace --locked --all-features
env:
VELLO_CI_GPU_SUPPORT: ${{ matrix.gpu }}

clippy-stable-wasm:
runs-on: ubuntu-latest
test-stable-wasm:
name: cargo test (wasm32)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: restore cache
uses: Swatinem/rust-cache@v2
with:
save-if: ${{ github.event_name != 'merge_group' }}

- name: install stable toolchain
uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ env.RUST_STABLE_VER }}
targets: wasm32-unknown-unknown
components: clippy

- name: cargo clippy (wasm)
run: cargo clippy --all-targets --target wasm32-unknown-unknown --workspace -- -D warnings
# TODO: Find a way to make tests work. Until then the tests are merely compiled.
- name: cargo test compile
run: cargo test --workspace --locked --target wasm32-unknown-unknown --all-features --no-run

android-stable-check:
runs-on: ubuntu-latest
check-stable-android:
name: cargo check (aarch64-android)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: restore cache
uses: Swatinem/rust-cache@v2
with:
save-if: ${{ github.event_name != 'merge_group' }}

- name: install stable toolchain
uses: dtolnay/rust-toolchain@master
Expand Down Expand Up @@ -170,6 +245,8 @@ jobs:

- name: restore cache
uses: Swatinem/rust-cache@v2
with:
save-if: ${{ github.event_name != 'merge_group' }}

- name: install msrv toolchain
uses: dtolnay/rust-toolchain@master
Expand All @@ -186,7 +263,7 @@ jobs:
run: sudo apt-get update; sudo apt-get install --no-install-recommends libasound2-dev libudev-dev

- name: cargo check
run: cargo hack check ${{ env.RUST_MIN_VER_PKGS }} --locked --each-feature --optional-deps
run: cargo hack check ${{ env.RUST_MIN_VER_PKGS }} --locked --optional-deps --each-feature

check-msrv-wasm:
name: cargo check (msrv) (wasm32)
Expand All @@ -196,6 +273,8 @@ jobs:

- name: restore cache
uses: Swatinem/rust-cache@v2
with:
save-if: ${{ github.event_name != 'merge_group' }}

- name: install msrv toolchain
uses: dtolnay/rust-toolchain@master
Expand All @@ -209,27 +288,27 @@ jobs:
tool: cargo-hack

- name: cargo check
# We don't include ${{ env.NO_WASM_PKGS }} here, because `-p foo --exclude foo` doesn't work
# and none of our `NO_WASM_PKGS` have an MSRV.
run: cargo hack check ${{ env.RUST_MIN_VER_PKGS }} --locked --target wasm32-unknown-unknown --each-feature --optional-deps
run: cargo hack check ${{ env.RUST_MIN_VER_PKGS }} --locked --target wasm32-unknown-unknown --optional-deps --each-feature

docs:
doc:
name: cargo doc
# NOTE: We don't have any platform specific docs in this workspace, so we only run on Ubuntu.
# If we get per-platform docs (win/macos/linux/wasm32/..) then doc jobs should match that.
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: install nightly toolchain
uses: dtolnay/rust-toolchain@nightly

- name: restore cache
uses: Swatinem/rust-cache@v2
with:
save-if: ${{ github.event_name != 'merge_group' }}

- name: install nightly toolchain
uses: dtolnay/rust-toolchain@nightly

# We test documentation using nightly to match docs.rs. This prevents potential breakages
- name: cargo doc
run: cargo doc --workspace --all-features --no-deps --document-private-items -Zunstable-options -Zrustdoc-scrape-examples
run: cargo doc --workspace --locked --all-features --no-deps --document-private-items -Zunstable-options -Zrustdoc-scrape-examples

# If this fails, consider changing your text or adding something to .typos.toml
typos:
Expand Down
6 changes: 1 addition & 5 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
# Remove Cargo.lock from gitignore if creating an executable, leave it for libraries
# More information here https://doc.rust-lang.org/cargo/guide/cargo-toml-vs-cargo-lock.html
Cargo.lock

# Don't commit example downloads
examples/assets/downloads/*

Expand All @@ -10,4 +6,4 @@ examples/assets/downloads/*
/target

# Some people have Apple
.DS_Store
.DS_Store
Loading