Skip to content

Commit

Permalink
ci(rust): only use allowed actions (#1749)
Browse files Browse the repository at this point in the history
Update Rust workflow to only use Apache allowed actions. This also adds
`Cargo.lock` (used in cache key) to the Rust workspace following [this
recommendation](https://doc.rust-lang.org/cargo/guide/cargo-toml-vs-cargo-lock.html),
and fixes some doc warnings.
  • Loading branch information
mbrobbel authored Apr 23, 2024
1 parent 2f0e926 commit 93dda62
Show file tree
Hide file tree
Showing 4 changed files with 831 additions and 15 deletions.
39 changes: 28 additions & 11 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ permissions:

defaults:
run:
working-directory: rust2
shell: bash
working-directory: rust

jobs:
rust:
Expand All @@ -47,22 +48,38 @@ jobs:
os: [windows-latest, macos-latest, ubuntu-latest]
name: "Rust ${{ matrix.os }}"
runs-on: ${{ matrix.os }}
env:
CARGO_INCREMENTAL: 0
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
persist-credentials: false
- name: Install stable toolchain
uses: dtolnay/rust-toolchain@stable
- name: Use stable Rust
id: rust
run: |
rustup update stable
rustup default stable
VERSION=$(rustup show active-toolchain -v | tail -1 | tr -d "[:space:]")
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
- uses: actions/cache@v4
with:
components: clippy, rustfmt
- uses: Swatinem/rust-cache@v2
- name: Check format
run: cargo fmt -- --check
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
rust/target/
key: ${{ runner.os }}-cargo-${{ steps.rust.outputs.version }}-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-${{ steps.rust.outputs.version }}-
- name: Rustfmt
run: cargo fmt --all -- --check
- name: Clippy
run: cargo clippy --tests
run: cargo clippy --workspace --all-targets --all-features -- -Dwarnings
- name: Test
shell: bash -l {0}
run: cargo test
run: cargo test --workspace --all-targets --all-features
- name: Doctests
run: cargo test --workspace --doc --all-features
- name: Check docs
run: cargo doc
run: cargo doc --workspace --all-features
1 change: 1 addition & 0 deletions dev/release/rat_exclude_files.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,5 @@ r/*/NEWS.md
r/*/cran-comments.md
r/*/.Rbuildignore
r/*/tests/testthat/_snaps/*
rust/Cargo.lock
testing/*
Loading

0 comments on commit 93dda62

Please sign in to comment.