From fbcca0ba79901a68885dc693c55f709e63a68923 Mon Sep 17 00:00:00 2001 From: Jan David Date: Sun, 17 Mar 2024 18:18:46 +0100 Subject: [PATCH] Create a Justfile Just[^1] is a modern command runner that makes it easy to define and run project-specific commands in a project. We use it to define the commands to format, lint, and test the code. [^1]: https://github.com/casey/just --- .github/workflows/rust.yml | 15 ++++++++++++--- Justfile | 15 +++++++++++++++ 2 files changed, 27 insertions(+), 3 deletions(-) create mode 100644 Justfile diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 3251914..2eb8d89 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -50,6 +50,9 @@ jobs: if: needs.detect-changes.outputs.any_changed == 'true' steps: + - name: Install Just + run: sudo snap install --edge --classic just + - name: Checkout code uses: actions/checkout@v4 @@ -62,7 +65,7 @@ jobs: uses: mozilla-actions/sccache-action@v0.0.4 - name: Run Clippy - run: cargo clippy --all-targets --all-features -- -D warnings + run: just lint style: name: Check style @@ -72,11 +75,14 @@ jobs: if: needs.detect-changes.outputs.any_changed == 'true' steps: + - name: Install Just + run: sudo snap install --edge --classic just + - name: Checkout code uses: actions/checkout@v4 - name: Run Rustfmt - run: cargo fmt --all -- --check + run: just format --check test: name: Run tests @@ -86,6 +92,9 @@ jobs: if: needs.detect-changes.outputs.any_changed == 'true' steps: + - name: Install Just + run: sudo snap install --edge --classic just + - name: Checkout code uses: actions/checkout@v4 @@ -98,4 +107,4 @@ jobs: uses: mozilla-actions/sccache-action@v0.0.4 - name: Run tests - run: cargo test --all-features --all-targets + run: just test diff --git a/Justfile b/Justfile new file mode 100644 index 0000000..2b5db4d --- /dev/null +++ b/Justfile @@ -0,0 +1,15 @@ +# List available commands +_default: + just --list + +format ARGS: + cargo fmt --all -- {{ARGS}} + +lint: + cargo clippy --all-targets --all-features -- -D warnings + +run ARGS: + cargo run -- {{ARGS}} + +test: + cargo test --all-features --all-targets