Skip to content

Commit

Permalink
chore: Clean up CI and pre-push a little
Browse files Browse the repository at this point in the history
also now `cargo-deny` is cached in CI. three minutes is craaaazy
  • Loading branch information
onkoe committed Nov 21, 2023
1 parent 48e5c6e commit 12601d0
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 6 deletions.
12 changes: 7 additions & 5 deletions .githooks/pre-push
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,24 @@
# Prevent push if any of these commands fail
set -e

echo "Running cargo semver-checks..."
echo "Before pushing to origin, let's run some pre-push checks..."

echo "Checking for semver violations..."
cargo semver-checks || exit 1

echo "Running cargo clippy..."
cargo clippy -- -D warnings || exit 1

echo "Generating documentation..."
echo "Ensuring documentation generates correctly..."
cargo doc --no-deps || exit 1

echo "Checking code compilation..."
echo "Checking if code compiles..."
cargo check || exit 1

echo "Checking code formatting..."
echo "Checking is code is formatted..."
cargo fmt -- --check || exit 1

echo "Running tests..."
cargo test || exit 1

echo "All checks passed!"
echo "All checks passed! Carry on!"
22 changes: 21 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
name: Cargo Build & Test

on:
push:
pull_request:
Expand All @@ -19,38 +20,57 @@ jobs:

steps:
- uses: actions/checkout@v3

- name: Set up Rust toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: ${{ matrix.toolchain }}
override: true

- name: Cache cargo registry
uses: actions/cache@v2
with:
path: ~/.cargo/registry
key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }}

- name: Cache cargo index
uses: actions/cache@v2
with:
path: ~/.cargo/git
key: ${{ runner.os }}-cargo-index-${{ hashFiles('**/Cargo.lock') }}

- name: Cache cargo build
uses: actions/cache@v2
with:
path: target
key: ${{ runner.os }}-cargo-build-target-${{ matrix.toolchain }}-${{ hashFiles('**/Cargo.lock') }}

- name: Cache cargo bin # bc wow why does it take three minutes to build `cargo-deny`
uses: actions/cache@v2
with:
path: ~/.cargo/bin
key: ${{ runner.os }}-cargo-bin-${{ hashFiles('**/Cargo.lock') }}

- name: Build
run: cargo build --verbose

- name: Run tests
run: cargo test --verbose

- name: Install cargo-deny
run: cargo install cargo-deny
run: |
if ! command -v cargo-deny &> /dev/null
then
cargo install cargo-deny
fi
- name: Run cargo-deny
run: cargo deny check

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

- name: Check semver
uses: obi1kenobi/cargo-semver-checks-action@v2

0 comments on commit 12601d0

Please sign in to comment.