Skip to content

Commit

Permalink
Merge pull request #1014 from NordSecurity/tk-just
Browse files Browse the repository at this point in the history
Automate day to day rust development tasks with Just(file)
  • Loading branch information
tomaszklak authored Dec 11, 2024
2 parents df90105 + fb795a0 commit e080d9a
Show file tree
Hide file tree
Showing 4 changed files with 90 additions and 44 deletions.
63 changes: 19 additions & 44 deletions .github/workflows/linters.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,30 +28,26 @@ jobs:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6
- uses: actions-rs/toolchain@b2417cde72dcf67f306c0ae8e0828a81bf0b189f # v1.0.6
with:
components: clippy
- uses: actions-rs/cargo@ae10961054e4aa8b4aa7dffede299aaf087aa33b # v1.0.3
- uses: extractions/setup-just@dd310ad5a97d8e7b41793f8ef055398d51ad4de6 # v2.0.0
with:
command: clippy
args: --target "x86_64-unknown-linux-gnu" --lib --color always -- --deny warnings --allow unknown-lints -W clippy::expect_used -W clippy::panic -W clippy::unwrap_used
just-version: 1.37.0
- run: just clippy
clippy-win:
runs-on: windows-2022
steps:
- uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6
- uses: actions-rs/toolchain@b2417cde72dcf67f306c0ae8e0828a81bf0b189f # v1.0.6
- uses: extractions/setup-just@dd310ad5a97d8e7b41793f8ef055398d51ad4de6 # v2.0.0
with:
target: x86_64-pc-windows-gnu
components: clippy
- uses: actions-rs/cargo@ae10961054e4aa8b4aa7dffede299aaf087aa33b # v1.0.3
with:
command: clippy
args: --target "x86_64-pc-windows-gnu" --lib --color always -- --deny warnings --allow unknown-lints -W clippy::expect_used -W clippy::panic -W clippy::unwrap_used
just-version: 1.37.0
- run: just clippy
clippy-mac:
runs-on: macos-13
steps:
- uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6
- run: cargo clippy --verbose --target "x86_64-apple-darwin" --lib --color always -- --deny warnings --allow unknown-lints -W clippy::expect_used -W clippy::panic -W clippy::unwrap_used
- uses: extractions/setup-just@dd310ad5a97d8e7b41793f8ef055398d51ad4de6 # v2.0.0
with:
just-version: 1.37.0
- run: just clippy
clippy-teliod:
runs-on: ubuntu-22.04
steps:
Expand All @@ -62,21 +58,18 @@ jobs:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6
- uses: EmbarkStudios/cargo-deny-action@3f4a782664881cf5725d0ffd23969fcce89fd868 # v1.6.3
- uses: extractions/setup-just@dd310ad5a97d8e7b41793f8ef055398d51ad4de6 # v2.0.0
with:
rust-version: 1.77.2 # NOTE: Runs in its own docker container and doesn't support toolchain files
just-version: 1.37.0
- run: just deny
udeps:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6
- uses: actions-rs/toolchain@b2417cde72dcf67f306c0ae8e0828a81bf0b189f # v1.0.6
with:
toolchain: nightly-2024-05-10
override: true
- uses: aig787/cargo-udeps-action@1cd634a329e14ccfbccfe7c96497d14dac24a743 # v1
- uses: extractions/setup-just@dd310ad5a97d8e7b41793f8ef055398d51ad4de6 # v2.0.0
with:
version: 'v0.1.47'
args: '--workspace --locked --output human --backend depinfo'
just-version: 1.37.0
- run: just udeps
rustfmt:
runs-on: ubuntu-22.04
steps:
Expand Down Expand Up @@ -152,25 +145,7 @@ jobs:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3
- uses: actions-rs/toolchain@b2417cde72dcf67f306c0ae8e0828a81bf0b189f # v1.0.6
- uses: extractions/setup-just@dd310ad5a97d8e7b41793f8ef055398d51ad4de6 # v2.0.0
with:
toolchain: 1.80.0
override: true
default: true
- name: Install cargo-unusued-features
run: cargo install --version 0.2.0 cargo-unused-features --locked
- name: Run cargo-unused-features
run: |
for dir in ./crates/* ./clis/*; do
pushd "$dir"
unused-features analyze -l debug
unused-features prune -l debug
popd
done
- name: Check results
run: |
git restore Cargo.lock
if ! git diff --quiet; then
git diff
exit 1
fi
just-version: 1.37.0
- run: just deny
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,4 @@ gamma-events.db
nat-lab/**/report.html
events-moose.log
qnap/**/teliod
report.json
Empty file added .unreleased/justfile
Empty file.
70 changes: 70 additions & 0 deletions Justfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
set shell := ["sh", "-c"]

# Aliases to be used only in interactive mode, please use full names when calling
# just in scripts or gitlab jobs.

[private]
alias t := test
[private]
alias c := clippy
[private]
alias u := udeps
[private]
alias un := unused
[private]
alias d := deny
[private]
alias p := prepush

nightly := "nightly-2024-04-23"
rust1_80 := "1.80.0"

# Run all rust tests
test:
cargo test --all --quiet

# Run clippy
clippy:
cargo clippy --lib -- --deny warnings --allow unknown-lints -W clippy::expect_used -W clippy::panic -W clippy::unwrap_used

# Run udeps
udeps: _udeps-install
cargo +{{ nightly }} udeps --workspace --locked --output human --backend depinfo

# Run unused features
unused: _unused-install
#!/usr/bin/env bash
set -euxo pipefail
for dir in ./crates/* ./clis/*; do
pushd "$dir"
unused-features analyze -l debug
unused-features prune -l debug
popd
done
git restore Cargo.lock
if ! git diff --quiet; then
git diff
exit 1
fi
# Run deny
deny: _deny-install
cargo deny check

# Run rust pre-push checks
prepush: test clippy udeps unused deny

_udeps-install: _nightly-install
cargo +{{ nightly }} install cargo-udeps@0.1.47 --locked

_unused-install: _rust1_80-install
cargo +{{ rust1_80 }} install --version 0.2.0 cargo-unused-features --locked

_deny-install:
cargo install --locked cargo-deny@0.15.1

_nightly-install:
rustup toolchain add {{ nightly }}

_rust1_80-install:
rustup toolchain add {{ rust1_80}}

0 comments on commit e080d9a

Please sign in to comment.