Skip to content

Commit

Permalink
CI: github actions updates (#3476)
Browse files Browse the repository at this point in the history
Couple of CI updates
- remove `actions-rs/*` actions, haven't been maintained for quite some
time. Replace with `dtolnay/rust-toolchain`, `taiki-e/install-action`
- Add rust caching via `Swatinem/rust-cache`
- Use `nextest` for running tests, much faster
- Use `cargo-llvm-cov` for coverage tracking
- remove `cargo-wasi` and `wasm32-wasi` checks, should redo with
`cargo-component` instead (and `wasm32-wasip2`):
https://blog.rust-lang.org/2024/04/09/updates-to-rusts-wasi-targets.html
- update to cbindgen `0.26.0`, which is not the latest version:
mozilla/cbindgen#959 broke `0.27.0` for us, will
investigate how to fix
  • Loading branch information
luizirber authored Jan 9, 2025
1 parent 77e1802 commit c3791c8
Show file tree
Hide file tree
Showing 6 changed files with 78 additions and 133 deletions.
7 changes: 3 additions & 4 deletions .github/workflows/asv.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,9 @@ jobs:
with:
python-version: "3.10"

- uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
- uses: dtolnay/rust-toolchain@stable

- uses: Swatinem/rust-cache@v2

- name: Install dependencies
run: |
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/dev_envs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:

- run: nix run .# -- --version

- run: nix develop --command bash -c "tox -e py310"
- run: nix develop --command bash -c "tox -e py311"

pixi:
runs-on: ${{ matrix.os }}
Expand All @@ -39,7 +39,7 @@ jobs:
- name: set up pixi
uses: prefix-dev/[email protected]
with:
pixi-version: v0.26.1
pixi-version: v0.39.5
cache: true
frozen: true

Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/python.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ jobs:
restore-keys: |
${{ runner.os }}-pip-v4-
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2

- name: Install dependencies
run: |
python -m pip install --upgrade pip
Expand Down
170 changes: 55 additions & 115 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,13 @@ jobs:
- name: Checkout sources
uses: actions/checkout@v4

- name: Install stable toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
- uses: dtolnay/rust-toolchain@stable

- uses: Swatinem/rust-cache@v2

- name: Run cargo check
uses: actions-rs/cargo@v1
with:
command: check
run: |
cargo check
test:
runs-on: ${{ matrix.os }}
Expand Down Expand Up @@ -53,32 +49,30 @@ jobs:
steps:
- uses: actions/checkout@v4

- uses: actions-rs/toolchain@v1
- uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ matrix.rust }}
override: true

- uses: Swatinem/rust-cache@v2

- uses: taiki-e/install-action@nextest

- name: Run tests
uses: actions-rs/cargo@v1
with:
command: test
args: --no-fail-fast
run: |
cargo nextest run
test_all_features:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
- uses: dtolnay/rust-toolchain@stable

- uses: Swatinem/rust-cache@v2

- uses: actions-rs/install@v0.1
- uses: taiki-e/install-action@v2
with:
crate: cargo-all-features
version: latest
use-tool-cache: true
tool: cargo-all-features

- name: Run tests for all feature combinations
run: cargo test-all-features --no-fail-fast --all
Expand All @@ -88,29 +82,23 @@ jobs:
steps:
- uses: actions/checkout@v4

- uses: actions-rs/toolchain@v1
- uses: dtolnay/rust-toolchain@stable
with:
toolchain: stable
override: true
components: llvm-tools-preview
- uses: Swatinem/rust-cache@v2

- name: Install cargo-binstall
run: |
wget https://github.com/ryankurte/cargo-binstall/releases/latest/download/cargo-binstall-x86_64-unknown-linux-gnu.tgz
tar xf cargo-binstall-x86_64-unknown-linux-gnu.tgz
chmod +x cargo-binstall
mv cargo-binstall "$HOME/.cargo/bin"
- name: Install cargo-tarpaulin
run: cargo binstall --no-confirm cargo-tarpaulin
- uses: taiki-e/install-action@cargo-llvm-cov
- uses: taiki-e/install-action@nextest

- name: Coverage with tarpaulin
run: cargo tarpaulin --all --all-features --timeout 600 --out xml -- --test-threads 1
- name: Collect coverage data
run: cargo llvm-cov nextest --all-features --lcov --output-path lcov.info

- name: Upload Rust coverage to codecov
uses: codecov/codecov-action@v3
with:
flags: rust
fail_ci_if_error: true
files: lcov.info

lints:
name: Lints
Expand All @@ -129,36 +117,33 @@ jobs:
uses: actions/checkout@v4

- name: Install Rust toolchain
uses: actions-rs/toolchain@v1
uses: dtolnay/rust-toolchain@master
with:
profile: minimal
toolchain: ${{ matrix.rust }}
override: true
components: rustfmt, clippy
components: "clippy, rustfmt"

- uses: Swatinem/rust-cache@v2

- name: Run cargo fmt
uses: actions-rs/cargo@v1
with:
command: fmt
args: --all -- --check
run: |
cargo fmt --all -- --check
- name: Run cargo clippy
uses: actions-rs/cargo@v1
with:
command: clippy
args: --all -- -D warnings
run: |
cargo clippy --all -- -D warnings
wasm-pack:
name: Check if wasm-pack builds a valid package for the sourmash crate
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- uses: actions-rs/toolchain@v1
- uses: dtolnay/rust-toolchain@stable
with:
toolchain: stable
target: wasm32-unknown-unknown

- uses: Swatinem/rust-cache@v2

- name: Install wasm-pack
run: "curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh"

Expand Down Expand Up @@ -190,51 +175,16 @@ jobs:
with:
path: 'pkg/sourmash*.tgz'

wasm32-wasi:
name: Run tests under wasm32-wasi
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install wasm32-wasi target
uses: actions-rs/toolchain@v1
with:
toolchain: stable
target: wasm32-wasi
- name: Install wasmtime
run: "curl https://wasmtime.dev/install.sh -sSf | bash"
- name: Add wasmtime to PATH
run: echo "$HOME/.wasmtime/bin" >> $GITHUB_PATH
- name: Install cargo-wasi command
uses: actions-rs/cargo@v1
with:
command: install
args: --force cargo-wasi
- name: Build code with cargo-wasi
uses: actions-rs/cargo@v1
continue-on-error: true ## TODO: remove this when build works...
with:
command: wasi
args: build
- name: Run tests under wasm32-wasi
uses: actions-rs/cargo@v1
continue-on-error: true ## TODO: remove this when tests work...
with:
command: wasi
args: test

publish:
name: Publish (on tags, dry-run otherwise)
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v4

- name: Install stable toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
- uses: dtolnay/rust-toolchain@stable

- uses: Swatinem/rust-cache@v2

- name: Check semver
uses: obi1kenobi/cargo-semver-checks-action@v2
Expand All @@ -245,62 +195,52 @@ jobs:
features: branchwater

- name: Make sure we can publish the sourmash crate
uses: actions-rs/cargo@v1
with:
command: publish
args: --dry-run --manifest-path src/core/Cargo.toml
run: |
cargo publish --dry-run --manifest-path src/core/Cargo.toml
# Login to crates.io on tags
- name: login to crates.io
uses: actions-rs/cargo@v1
if: startsWith(github.ref, 'refs/tags/r')
with:
command: login
args: ${{ secrets.CRATES_IO_TOKEN }}
run: |
cargo login ${{ secrets.CRATES_IO_TOKEN }}
# Publish to crates.io on tags
- name: Publish to crates.io
if: startsWith(github.ref, 'refs/tags/r')
uses: actions-rs/cargo@v1
with:
command: publish
args: --manifest-path src/core/Cargo.toml
run: |
cargo publish --manifest-path src/core/Cargo.toml
minimum_rust_version:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- uses: actions-rs/toolchain@v1
- uses: dtolnay/rust-toolchain@master
with:
toolchain: "1.66.0"
override: true

- uses: Swatinem/rust-cache@v2

- name: check if README matches MSRV defined here
run: grep '1.66.0' src/core/README.md

- name: Check if it builds properly
uses: actions-rs/cargo@v1
with:
command: build
args: --all-features
run: |
cargo build --all-features
check_cbindgen:
name: "Check if cbindgen runs cleanly for generating the C headers"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
- uses: dtolnay/rust-toolchain@stable

- uses: Swatinem/rust-cache@v2

- uses: actions-rs/install@v0.1
- uses: taiki-e/install-action@v2
with:
crate: cbindgen
version: 0.20.0
use-tool-cache: true
tool: [email protected]

- run: make include/sourmash.h

Expand Down
18 changes: 9 additions & 9 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit c3791c8

Please sign in to comment.