Skip to content

Ci improvements

Ci improvements #16

Workflow file for this run

permissions:
contents: read
on:
push:
branches: [main, kernel]
pull_request:
name: CI
jobs:
# commit_list job copied & adapted from <https://github.com/landlock-lsm/rust-landlock/blob/0f4246a54e17eb57ee938e67c5d85a07d1f977a5/.github/workflows/rust.yml>
commit_list:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Get commit list (push)
id: get_commit_list_push
if: ${{github.event_name == 'push'}}
run: |
echo "id0=$GITHUB_SHA" > $GITHUB_OUTPUT
echo "List of tested commits:" > $GITHUB_STEP_SUMMARY
sed -n 's,^id[0-9]\+=\(.*\),- https://github.com/Rust-for-Linux/pin-init/commit/\1,p' -- $GITHUB_OUTPUT >> $GITHUB_STEP_SUMMARY
- name: Get commit list (PR)
id: get_commit_list_pr
if: ${{github.event_name == 'pull_request'}}
run: |
git rev-list --reverse refs/remotes/origin/${{github.base_ref}}..${{github.event.pull_request.head.sha}} | awk '{ print "id" NR "=" $1 }' > $GITHUB_OUTPUT
git diff --quiet ${{github.event.pull_request.head.sha}} ${{github.sha}} || echo "id0=$GITHUB_SHA" >> $GITHUB_OUTPUT
echo "List of tested commits:" > $GITHUB_STEP_SUMMARY
sed -n 's,^id[0-9]\+=\(.*\),- https://github.com/Rust-for-Linux/pin-init/commit/\1,p' -- $GITHUB_OUTPUT >> $GITHUB_STEP_SUMMARY
outputs:
commits: ${{toJSON(steps.*.outputs.*)}}
fmt:
needs: commit_list
strategy:
matrix:
commit: ${{fromJSON(needs.commit_list.outputs.commits)}}
name: fmt @${{matrix.commit[0:11]}}

Check failure on line 38 in .github/workflows/ci.yml

View workflow run for this annotation

GitHub Actions / CI

Invalid workflow file

The workflow is not valid. .github/workflows/ci.yml (Line: 38, Col: 11): Unexpected symbol: '0:11'. Located at position 15 within expression: matrix.commit[0:11] .github/workflows/ci.yml (Line: 55, Col: 11): Unexpected symbol: '0:11'. Located at position 15 within expression: matrix.commit[0:11]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
ref: ${{matrix.commit}}
- uses: dtolnay/rust-toolchain@nightly
with:
components: rustfmt
- run: cargo fmt --check
- run: cd internal && cargo fmt --check
readme:
needs: commit_list
runs-on: ubuntu-latest
strategy:
matrix:
commit: ${{fromJSON(needs.commit_list.outputs.commits)}}
name: readme @${{matrix.commit[0:11]}}
steps:
- uses: actions/checkout@v4
with:
ref: ${{matrix.commit}}
- uses: dtolnay/rust-toolchain@nightly
- run: cargo install cargo-rdme
- run: cargo rdme --check
docs:
needs: commit_list
runs-on: ubuntu-latest
strategy:
matrix:
commit: ${{fromJSON(needs.commit_list.outputs.commits)}}
name: docs @${{matrix.commit[0:11]}}
steps:
- uses: actions/checkout@v4
with:
ref: ${{matrix.commit}}
- uses: dtolnay/rust-toolchain@nightly
- uses: dtolnay/rust-toolchain@nightly
with:
components: rust-src
- run: cargo doc --no-deps
clippy:
needs: commit_list
runs-on: ubuntu-latest
strategy:
matrix:
commit: ${{fromJSON(needs.commit_list.outputs.commits)}}
name: clippy @${{matrix.commit[0:11]}}
steps:
- uses: actions/checkout@v4
with:
ref: ${{matrix.commit}}
- uses: dtolnay/rust-toolchain@nightly
with:
components: clippy
- run: cargo install cargo-hack
- run: cargo hack --clean-per-run --feature-powerset clippy --locked
test:
needs: commit_list
runs-on: ubuntu-latest
strategy:
matrix:
commit: ${{fromJSON(needs.commit_list.outputs.commits)}}
name: test @${{matrix.commit[0:11]}}
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@nightly
with:
components: rust-src
- run: cargo install cargo-expand
- run: cargo test --locked
miri:
needs: commit_list
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
commit: ${{fromJSON(needs.commit_list.outputs.commits)}}
flags: [
"",
"-Zmiri-tree-borrows",
"-Zmiri-strict-provenance",
"-Zmiri-tree-borrows -Zmiri-strict-provenance",
]
name: miri (${{matrix.flags}}) @${{matrix.commit[0:11]}}
steps:
- uses: actions/checkout@v4
with:
ref: ${{matrix.commit}}
- run: |
echo "NIGHTLY=nightly-$(curl -s https://rust-lang.github.io/rustup-components-history/x86_64-unknown-linux-gnu/miri)" >> $GITHUB_ENV
- name: Install ${{env.NIGHTLY}}
uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{env.NIGHTLY}}
components: miri, rust-src
- run: cargo install cargo-expand
- name: ${{matrix.flags}} cargo miri test
run: cargo miri test --locked
env:
MIRIFLAGS: ${{matrix.flags}}
sanitizers:
needs: commit_list
runs-on: ubuntu-latest
strategy:
matrix:
commit: ${{fromJSON(needs.commit_list.outputs.commits)}}
name: sanitizers @${{matrix.commit[0:11]}}
steps:
- uses: actions/checkout@v4
with:
ref: ${{matrix.commit}}
- uses: dtolnay/rust-toolchain@nightly
with:
components: rust-src
- name: enable debug symbols
run: |
sudo apt install llvm
# https://github.com/japaric/rust-san#unrealiable-leaksanitizer
sed -i '/\[features\]/i [profile.dev]' Cargo.toml
sed -i '/profile.dev/a opt-level = 1' Cargo.toml
cat Cargo.toml
- run: cargo test --lib --tests --target x86_64-unknown-linux-gnu
env:
ASAN_OPTIONS: "detect_odr_violation=0:detect_leaks=0"
RUSTFLAGS: "--cfg NO_UI_TESTS --cfg NO_ALLOC_FAIL_TESTS -Z sanitizer=address"
- run: cargo test --target x86_64-unknown-linux-gnu
env:
RUSTFLAGS: "--cfg NO_UI_TESTS --cfg NO_ALLOC_FAIL_TESTS -Z sanitizer=leak"
msrv:
needs: commit_list
runs-on: ubuntu-latest
strategy:
matrix:
commit: ${{fromJSON(needs.commit_list.outputs.commits)}}
name: msrv @${{matrix.commit[0:11]}}
steps:
- uses: actions/checkout@v4
with:
ref: ${{matrix.commit}}
- uses: dtolnay/rust-toolchain@stable
- run: cargo install cargo-hack
- run: cargo hack --clean-per-run --feature-powerset --exclude-features alloc --exclude-features default --version-range 1.82.. --clean-per-version check --locked
nightly-msrv:
needs: commit_list
runs-on: ubuntu-latest
strategy:
matrix:
commit: ${{fromJSON(needs.commit_list.outputs.commits)}}
name: nightly-msrv @${{matrix.commit[0:11]}}
steps:
- uses: actions/checkout@v4
with:
ref: ${{matrix.commit}}
- uses: dtolnay/rust-toolchain@stable
with:
components: rust-src
- run: cargo install cargo-hack
- run: cargo install cargo-expand
- run: cargo hack --clean-per-run --feature-powerset --version-range 1.78.. --clean-per-version check --locked
env:
RUSTC_BOOTSTRAP: 1
os-check:
needs: commit_list
strategy:
fail-fast: false
matrix:
os: [macos-latest, windows-latest]
commit: ${{fromJSON(needs.commit_list.outputs.commits)}}
runs-on: ${{matrix.os}}
name: os-check (${{matrix.os}}) @${{matrix.commit[0:11]}}
steps:
- uses: actions/checkout@v4
with:
ref: ${{matrix.commit}}
- uses: dtolnay/rust-toolchain@nightly
with:
components: rust-src
- run: cargo install cargo-expand
- run: cargo test --locked