Skip to content

Ci improvements

Ci improvements #34

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: |
git rev-list --reverse ${{github.event.before}}..${{github.event.after}} | \
awk '{ printf "{\"num\":" NR ",\"sha\":\"" $1 "\",\"short\":\"" substr($1, 0, 12) "\"}," }' | \
sed 's/,$//' | \
awk '{ printf "[" $1 "]" }' | \
jq -c . | \
awk '{ print "commits=" $1 }' >> $GITHUB_OUTPUT
cat $GITHUB_OUTPUT
- name: Get commit list (PR)
id: get_commit_list_pr
if: ${{github.event_name == 'pull_request'}}
run: |
git rev-list --reverse ${{github.event.pull_request.base.sha}}..${{github.event.pull_request.head.sha}} | \
awk '{ print "id" NR "={num: " NR ", sha: " $1 ", short: " substr($1, 0, 12) "}" }' >> $GITHUB_OUTPUT
# awk '{ printf "{\"num\":" NR ",\"sha\":\"" $1 "\",\"short\":\"" substr($1, 0, 12) "\"}," }' | \
# sed 's/,$//' | \
# awk '{ printf "[" $1 "]" }' | \
# jq -c . | \
# awk '{ print "commits=" $1 }' >> $GITHUB_OUTPUT
outputs:
commits: ${{toJSON(steps.*.outputs.*)}}
fmt:
needs: commit_list
runs-on: ubuntu-latest
strategy:
matrix:
commit:
- ${{fromJSON(needs.commit_list.outputs.commits)}}
name: "fmt #${{matrix.commit.num}} (${{matrix.commit.short}})"
steps:
- run: echo "${{matrix.commit}}"
# fmt:
# needs: commit_list
# strategy:
# matrix:
# commit: ${{fromJSON(needs.commit_list.outputs.commits)}}
# name: "fmt #${{matrix.commit.num}} (${{matrix.commit.short}})"
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v4
# with:
# ref: ${{matrix.commit.sha}}
# - 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.num}} (${{matrix.commit.short}})"
# steps:
# - uses: actions/checkout@v4
# with:
# ref: ${{matrix.commit.sha}}
# - 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.num}} (${{matrix.commit.short}})"
# steps:
# - uses: actions/checkout@v4
# with:
# ref: ${{matrix.commit.sha}}
# - 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.num}} (${{matrix.commit.short}})"
# steps:
# - uses: actions/checkout@v4
# with:
# ref: ${{matrix.commit.sha}}
# - 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.num}} (${{matrix.commit.short}})"
# 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.commit.num}} (${{matrix.commit.short}})"
# steps:
# - uses: actions/checkout@v4
# with:
# ref: ${{matrix.commit.sha}}
# - 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.num}} (${{matrix.commit.short}})"
# steps:
# - uses: actions/checkout@v4
# with:
# ref: ${{matrix.commit.sha}}
# - 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.num}} (${{matrix.commit.short}})"
# steps:
# - uses: actions/checkout@v4
# with:
# ref: ${{matrix.commit.sha}}
# - 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.num}} (${{matrix.commit.short}})"
# steps:
# - uses: actions/checkout@v4
# with:
# ref: ${{matrix.commit.sha}}
# - 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.num}} (${{matrix.commit.short}})"
# steps:
# - uses: actions/checkout@v4
# with:
# ref: ${{matrix.commit.sha}}
# - uses: dtolnay/rust-toolchain@nightly
# with:
# components: rust-src
# - run: cargo install cargo-expand
# - run: cargo test --locked