Skip to content

Commit

Permalink
ci: change rustup and cache actions
Browse files Browse the repository at this point in the history
- Update git checkout to v3
- Change Rust install from actions-rs to dtolney/rust-toolchain
- Change caching from manual setup to Swatinem/rust-cache
- Generates lockfile if it does not exist
- Update ./cicheck script to match CI
  • Loading branch information
sonro committed Jun 8, 2023
1 parent 5282811 commit 150cdb3
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 88 deletions.
24 changes: 5 additions & 19 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,8 @@ jobs:
publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1

- name: Generate Cargo.lock
uses: actions-rs/cargo@v1
with:
command: generate-lockfile
- uses: actions/checkout@v3

- name: Cache
uses: actions/cache@v2
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: stable-x86_64-unknown-linux-gnu-cargo-${{ hashFiles('**/Cargo.lock') }}

- name: Wait for tests to succeed
uses: lewagon/wait-on-check-action@v1.0.0
with:
Expand All @@ -36,11 +22,11 @@ jobs:
repo-token: ${{ secrets.GITHUB_TOKEN }}
wait-interval: 10

- name: Install stable
uses: dtolnay/rust-toolchain@stable

- name: cargo publish
uses: actions-rs/cargo@v1
with:
command: publish
args: --token ${{ secrets.CRATES_TOKEN }}
run: cargo publish --token ${{ secrets.CRATES_TOKEN }}

create-release:
needs: publish
Expand Down
98 changes: 30 additions & 68 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,133 +4,95 @@ on:
push:
branches:
- 'main'
- "ci"

pull_request:
branches:
- 'main'
- 'dev'

env:
RUST_BACKTRACE: 1

jobs:
tests:
strategy:
fail-fast: false
matrix:
# minimum supported rust version
rust: [1.61.0, stable]
on:
- { os: ubuntu-latest, target: x86_64-unknown-linux-gnu }
- { os: macos-latest, target: x86_64-apple-darwin }
- { os: windows-latest, target: x86_64-pc-windows-msvc }
include:
- use-cross: false

runs-on: ${{ matrix.on.os }}
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3

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

- name: Generate Cargo.lock
uses: actions-rs/cargo@v1
with:
use-cross: ${{ matrix.use-cross }}
command: generate-lockfile
- name: Generate lockfile
if: hashFiles('Cargo.lock') == ''
run: cargo generate-lockfile

- name: Cache
uses: actions/cache@v2
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ matrix.rust }}-${{ matrix.on.target }}-cargo-${{ hashFiles('**/Cargo.lock') }}
uses: Swatinem/rust-cache@v2

- name: Build tests
uses: actions-rs/cargo@v1
with:
use-cross: ${{ matrix.use-cross }}
command: test
args: --no-run --target ${{ matrix.on.target }}
run: cargo test --no-run --locked --all-features

- name: Run tests
uses: actions-rs/cargo@v1
with:
use-cross: ${{ matrix.use-cross }}
command: test
args: --target ${{ matrix.on.target }}
run: cargo test --locked --all-features

rustfmt:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3

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

- name: Run rustfmt
uses: actions-rs/cargo@v1
with:
command: fmt
args: -- --check
run: cargo fmt -- --check

docs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

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

- name: Run rustdoc
- name: cargo doc
env:
RUSTDOCFLAGS: -D warnings
uses: actions-rs/cargo@v1
with:
command: doc
args: --no-deps --document-private-items
RUSTDOCFLAGS: --cfg docsrs -D warnings
run: cargo doc --no-deps --all-features --document-private-items

clippy:
runs-on: ubuntu-latest
strategy:
matrix:
feature: [default, cli-error, error, report]
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3

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

- name: Generate Cargo.lock
uses: actions-rs/cargo@v1
with:
command: generate-lockfile
- name: Generate lockfile
if: hashFiles('Cargo.lock') == ''
run: cargo generate-lockfile

- name: Cache
uses: actions/cache@v2
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: clippy-cargo-${{ hashFiles('**/Cargo.lock') }}
uses: Swatinem/rust-cache@v2

- name: Run clippy
uses: actions-rs/cargo@v1
with:
command: clippy
args: --no-default-features --features ${{ matrix.feature }} -- -D warnings
run: cargo clippy --all --examples --tests -- -D warnings --no-default-features --features ${{ matrix.feature }}
7 changes: 6 additions & 1 deletion cicheck
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ set -e

echo "fmt check"
cargo fmt --check

echo "clippy"
echo "| default feature"
cargo clippy -q -- -D warnings
Expand All @@ -14,7 +15,11 @@ echo "| error feature "
cargo clippy -q --no-default-features --features error -- -D warnings
echo "| cli-error feature "
cargo clippy -q --no-default-features --features cli-error -- -D warnings

echo "build docs"
RUSTDOCFLAGS="--cfg docsrs -D warnings" cargo doc -q --no-deps --all-features --document-private-items

echo "build tests"
cargo test -q --no-run
echo "run tests"
echo "running tests..."
cargo test -q

0 comments on commit 150cdb3

Please sign in to comment.