Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions .cargo/config.toml
Original file line number Diff line number Diff line change
@@ -1,2 +1,38 @@
[alias]
xtask = "run --package xtask --"
t = "test --all -- --nocapture"
t-all = "cargo t-native && cargo t-wasm"
t-native = "test --all -- --nocapture"
t-wasm = "test --target wasm32-unknown-unknown -- --nocapture"
b = "build --workspace"
b-all = "cargo b-native && cargo b-wasm"
b-native = "build --workspace"
b-wasm = "build --workspace --target wasm32-unknown-unknown"
r = "run --release"
r-all = "cargo r-native && cargo r-wasm"
r-native = "run --relase"
r-wasm = "run --relase --target wasm32-unknown-unknown"
format = "fmt --all"
cl = "clippy --all-targets --all-features -- -Dwarnings"

[build]
rustflags = ["-Dwarnings", "-Dunsafe-code"]

[target.wasm32-unknown-unknown]
runner = "wasm-bindgen-test-runner"

[profile.dev]
opt-level = 1
incremental = true

[env]
RUST_TEST_THREADS = "1"
RUST_BACKTRACE = "1"

[target.'cfg(all())']
rustflags = [
"-Wclippy::all",
"-Wclippy::pedantic",
"-Wclippy::nursery",
"-Wclippy::cargo",
]
10 changes: 0 additions & 10 deletions .config/nextest.toml
Original file line number Diff line number Diff line change
@@ -1,16 +1,6 @@
[profile.default]
# Don't cancel the run when a test fails
cancel = "never"

# Retry failing tests up to 2 times before marking them failed
retries = 2

# Set a global timeout for each test (in seconds)
test-timeout = "120s"

# Control output: show failures immediately, but keep passing tests quiet
status-level = "all"

# Optional: store junit-style reports for CI integration
[junit]
path = "target/nextest/junit.xml"
19 changes: 16 additions & 3 deletions .github/workflows/autofix.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,21 @@ on:

jobs:
autofix:
name: Auto Fix
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write

steps:
- uses: actions/checkout@v6
- run: cargo fmt
- uses: autofix-ci/action@635ffb0c9798bd160680f18fd73371e355b85f27
- name: Checkout
uses: actions/checkout@v6

- name: Cargo Format
uses: yonasBSD/toolkit@9067fa17c79d97c3bad28da5ebba1d3c32ab3582 # v0.1.0
with:
run: |
cargo format

- name: Autofix
uses: autofix-ci/action@635ffb0c9798bd160680f18fd73371e355b85f27
2 changes: 1 addition & 1 deletion .github/workflows/licenses.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ jobs:
toolchain: nightly

- name: Run cargo-deny
uses: yonasBSD/toolkit@d9d381e7c259d31d02f8a18c491a1ea8980d824f # v0.1.0
uses: yonasBSD/toolkit@9067fa17c79d97c3bad28da5ebba1d3c32ab3582 # v0.1.0
with:
run: |
cargo-deny check licenses bans
Expand Down
91 changes: 44 additions & 47 deletions .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,23 +44,19 @@ jobs:
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
- uses: mozilla-actions/sccache-action@7d986dd989559c6ecdb630a3fd2557667be217ad # v0.0.9

- uses: dtolnay/rust-toolchain@b3b07ba8b418998c39fb20f53e8b695cdcc8de1b # stable
- name: Cargo Format
uses: yonasBSD/toolkit@9067fa17c79d97c3bad28da5ebba1d3c32ab3582 # v0.1.0
with:
toolchain: stable
components: rustfmt

- name: cargo fmt
run: |
cargo fmt --version
cargo clippy --fix --workspace
cargo fmt --all --check
run: |
cargo format --version
cargo clippy --fix --workspace
cargo format --check

- name: treefmt
run: |
curl -s https://api.github.com/repos/numtide/treefmt/tags | jq -r '.[0].name' > .ver
curl -sSLo treefmt.tgz https://github.com/numtide/treefmt/releases/download/$(cat .ver)/treefmt_$(cat .ver | cut -d'v' -f2)_linux_amd64.tar.gz
tar -xvf treefmt.tgz
./treefmt
- name: Tree Format
uses: yonasBSD/toolkit@9067fa17c79d97c3bad28da5ebba1d3c32ab3582 # v0.1.0
with:
run: |
treefmt

clippy:
name: Clippy
Expand Down Expand Up @@ -105,35 +101,36 @@ jobs:
args: --all-targets --all-features
name: Clippy Output

semver:
name: Check semver
runs-on: ubuntu-latest
env:
SCCACHE_GHA_ENABLED: "true"
RUSTC_WRAPPER: "sccache"
steps:
- name: Harden Runner
uses: step-security/harden-runner@f4a75cfd619ee5ce8d5b864b0d183aff3c69b55a # v2.13.1
with:
disable-sudo: true
egress-policy: block
allowed-endpoints: >
api.deps.dev:443
api.github.com:443
api.osv.dev:443
api.scorecard.dev:443
fulcio.sigstore.dev:443
github.com:443
oss-fuzz-build-logs.storage.googleapis.com:443
rekor.sigstore.dev:443
tuf-repo-cdn.sigstore.dev:443
www.bestpractices.dev:443
objects.githubusercontent.com:443
release-assets.githubusercontent.com:443
static.rust-lang.org:443
index.crates.io:443
static.crates.io:443

- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
- uses: mozilla-actions/sccache-action@7d986dd989559c6ecdb630a3fd2557667be217ad # v0.0.9
- uses: obi1kenobi/cargo-semver-checks-action@5b298c9520f7096a4683c0bd981a7ac5a7e249ae # v2.8
# FIXME: https://github.com/yonasBSD/rust-ci-github-actions-workflow/issues/82
#semver:
# name: Check semver
# runs-on: ubuntu-latest
# env:
# SCCACHE_GHA_ENABLED: "true"
# RUSTC_WRAPPER: "sccache"
# steps:
# - name: Harden Runner
# uses: step-security/harden-runner@f4a75cfd619ee5ce8d5b864b0d183aff3c69b55a # v2.13.1
# with:
# disable-sudo: true
# egress-policy: block
# allowed-endpoints: >
# api.deps.dev:443
# api.github.com:443
# api.osv.dev:443
# api.scorecard.dev:443
# fulcio.sigstore.dev:443
# github.com:443
# oss-fuzz-build-logs.storage.googleapis.com:443
# rekor.sigstore.dev:443
# tuf-repo-cdn.sigstore.dev:443
# www.bestpractices.dev:443
# objects.githubusercontent.com:443
# release-assets.githubusercontent.com:443
# static.rust-lang.org:443
# index.crates.io:443
# static.crates.io:443
#
# - uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
# - uses: mozilla-actions/sccache-action@7d986dd989559c6ecdb630a3fd2557667be217ad # v0.0.9
# - uses: obi1kenobi/cargo-semver-checks-action@5b298c9520f7096a4683c0bd981a7ac5a7e249ae # v2.8
2 changes: 1 addition & 1 deletion .github/workflows/release-packaging.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ jobs:
toolchain: stable

- name: Release Build
uses: yonasBSD/toolkit@d9d381e7c259d31d02f8a18c491a1ea8980d824f # v0.1.0
uses: yonasBSD/toolkit@9067fa17c79d97c3bad28da5ebba1d3c32ab3582 # v0.1.0
with:
run: |
cargo auditable build --release
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/security.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ jobs:
toolchain: stable

- name: Run advisories checklist
uses: yonasBSD/toolkit@d9d381e7c259d31d02f8a18c491a1ea8980d824f # v0.1.0
uses: yonasBSD/toolkit@9067fa17c79d97c3bad28da5ebba1d3c32ab3582 # v0.1.0
with:
run: |
echo ### Advisories > $GITHUB_STEP_SUMMARY
Expand Down
39 changes: 21 additions & 18 deletions .github/workflows/test-with-coverage.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -73,33 +73,35 @@ jobs:

# Cache target directory seperately to prevent cache invalidation of
# ~/.cargo when target changes
- name: Cache target directory
uses: actions/cache@9255dc7a253b0ccc959486e2bca901246202afeb # v5.0.1
env:
cache-name: cache-dependencies
with:
path: target
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('Cargo.lock') }}
#- name: Cache target directory
# uses: actions/cache@9255dc7a253b0ccc959486e2bca901246202afeb # v5.0.1
# env:
# cache-name: cache-dependencies
# with:
# path: target
# key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('Cargo.lock') }}

- name: Install grcov
uses: taiki-e/install-action@f63c33fd96cc1e69a29bafd06541cf28588b43a4 # v2.58.21
with:
tool: grcov,cargo-llvm-cov

- name: Run tests
uses: yonasBSD/toolkit@main
uses: yonasBSD/toolkit@9067fa17c79d97c3bad28da5ebba1d3c32ab3582 # v0.1.0
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
run: |
task test

- name: Generate test results and coverage report
uses: yonasBSD/toolkit@9067fa17c79d97c3bad28da5ebba1d3c32ab3582 # v0.1.0
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
cargo test $CARGO_OPTIONS -- -Z unstable-options --format json | cargo2junit > results.xml;
cargo llvm-cov --all-features --workspace --codecov --output-path ./codecov.json
with:
run: |
cargo test ${CARGO_OPTIONS:+$CARGO_OPTIONS} -- -Z unstable-options --format json | cargo2junit > results.xml;
cargo llvm-cov --all-features --workspace --codecov --output-path ./codecov.json

- name: Upload test results
uses: EnricoMi/publish-unit-test-result-action@170bf24d20d201b842d7a52403b73ed297e6645b # v2.18.0
Expand All @@ -108,13 +110,14 @@ jobs:
github_token: ${{ secrets.GITHUB_TOKEN }}
files: results.xml

- name: Run xtask coverage
uses: actions-rs/cargo@844f36862e911db73fe0815f00a4a2602c279505 # v1.0.3
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
command: xtask
args: coverage
# FIXME: https://github.com/yonasBSD/rust-ci-github-actions-workflow/issues/85
#- name: Run xtask coverage
# uses: actions-rs/cargo@844f36862e911db73fe0815f00a4a2602c279505 # v1.0.3
# env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# with:
# command: xtask
# args: coverage

#- name: Upload Coverage Report
# uses: codecov/codecov-action@v5
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,5 @@ Cargo.lock
# Build output
build/
coverage/
**/results.json
**/results.xml
12 changes: 11 additions & 1 deletion Taskfile.dist.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ tasks:

audit:
desc: Perform a security audit
deps: ['audit:secrets', 'audit:vulnerabilities', 'audit:code-quality']
deps: ['audit:secrets', 'audit:vulnerabilities', 'audit:code-quality', 'audit:code-coverage']

audit:secrets:
desc: Scan for secrets
Expand Down Expand Up @@ -288,3 +288,13 @@ tasks:
desc: Run sonarcube
cmds:
- echo sonarcube run

audit:code-coverage:
desc: Calculate code coverage
cmds:
- task: run:llvm-cov

run:llvm-cov:
desc: Run LLVM cov
cmds:
- cargo llvm-cov nextest
22 changes: 15 additions & 7 deletions backpack/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,11 @@ version = "0.1.0"
authors = ["test@example.com"]
edition = "2021"
license = "MIT"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
description = "Test"
repository = "https://github.com/yonasBSD/rust-ci-github-actions-workflow"
readme = "README.md"
keywords = ["template", "rust"]
categories = ["template"]

[[bin]]
name = "test2"
Expand All @@ -15,10 +18,15 @@ path = "src/main.rs"
coverage = []

[dev-dependencies]
demonstrate = "*"
async-attributes = "*"
async-std = "*"
pretty_assertions = "*"
wasm-bindgen-test = "0.3.56"

[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
smol = "2"
human-panic = "2"

[target.'cfg(target_arch = "wasm32")'.dependencies]
wasm-bindgen-futures = "0.4"

[dependencies]
human-panic = "2.0.2"
demonstrate = { git = "https://github.com/yonasBSD/demonstrate" }
pretty_assertions = "1.4.1"
Loading
Loading