Skip to content

Commit 05c15a0

Browse files
authored
feat(ci): add a justfile and GitHub Actions (#10)
* feat(ci): add `justfile` * feat(ci): add GitHub CI workflows Adds 4 workflows: - Monthly run of dependabot for cargo dependencies and GH Actions - Run `cargo-audit` on every PR - Run `just check` on every PR - Run Zizmor Security Analysis on every PR
1 parent dd9149e commit 05c15a0

5 files changed

Lines changed: 155 additions & 0 deletions

File tree

.github/dependabot.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: "github-actions"
4+
directory: "/"
5+
schedule:
6+
interval: "monthly"
7+
- package-ecosystem: "cargo"
8+
directory: "/"
9+
schedule:
10+
interval: "monthly"

.github/workflows/audit.yml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: Security Audit
2+
3+
on:
4+
pull_request:
5+
merge_group:
6+
push:
7+
branches: [master]
8+
9+
env:
10+
CARGO_TERM_COLOR: always
11+
12+
permissions: {}
13+
14+
jobs:
15+
supply-chain:
16+
name: 'cargo-audit'
17+
runs-on: ubuntu-latest
18+
timeout-minutes: 30
19+
steps:
20+
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v4
21+
with:
22+
persist-credentials: false
23+
24+
- uses: dtolnay/rust-toolchain@22a6a5b0f9f487c5f5587025ae9d4a1caf2a8a78 # clippy
25+
26+
- uses: Swatinem/rust-cache@98c8021b550208e191a6a3145459bfc9fb29c4c0 # v2
27+
with:
28+
cache-on-failure: true
29+
30+
- name: Install cargo-audit
31+
run: cargo install cargo-audit --force --locked
32+
33+
- name: Check for audit warnings
34+
run: cargo audit -D warnings
35+
continue-on-error: true
36+
37+
- name: Check for vulnerabilities
38+
run: cargo audit

.github/workflows/ci.yml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: CI
2+
3+
env:
4+
CARGO_TERM_COLOR: always
5+
6+
on:
7+
push:
8+
branches:
9+
- master
10+
pull_request: {}
11+
workflow_dispatch: null
12+
13+
permissions: {}
14+
15+
jobs:
16+
check:
17+
runs-on: ubuntu-latest
18+
steps:
19+
- name: checkout code
20+
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v4
21+
with:
22+
persist-credentials: false
23+
24+
- name: setup rust
25+
uses: dtolnay/rust-toolchain@b95584d8105b9ab200e15821fa671848cf2b7017 # nightly
26+
with:
27+
components: clippy, rustfmt
28+
29+
- name: setup just
30+
uses: extractions/setup-just@e33e0265a09d6d736e2ee1e0eb685ef1de4669ff # v3
31+
32+
- name: rust cache
33+
uses: Swatinem/rust-cache@98c8021b550208e191a6a3145459bfc9fb29c4c0 # v2
34+
35+
- name: check
36+
run: just check

.github/workflows/zizmor.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
name: GitHub Actions Security Analysis with zizmor 🌈
2+
3+
on:
4+
pull_request:
5+
branches: ["**"]
6+
7+
permissions: {}
8+
9+
jobs:
10+
zizmor:
11+
name: zizmor
12+
runs-on: ubuntu-latest
13+
steps:
14+
- name: Checkout repository
15+
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v4
16+
with:
17+
persist-credentials: false
18+
19+
- name: Install the latest version of uv
20+
uses: astral-sh/setup-uv@d9e0f98d3fc6adb07d1e3d37f3043649ddad06a1 # v5
21+
22+
- name: Run zizmor 🌈
23+
run: uvx zizmor .

justfile

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
alias b := build
2+
alias c := check
3+
alias d := delete
4+
alias e := example
5+
alias f := fmt
6+
7+
_default:
8+
@just --list
9+
10+
# Build bdk_floresta
11+
build:
12+
cargo build
13+
14+
# Check code: formatting, compilation, linting, and commit signature
15+
check:
16+
cargo +nightly fmt --all -- --check
17+
cargo check --workspace
18+
cargo clippy --all-targets -- -D warnings
19+
@[ "$(git log --pretty='format:%G?' -1 HEAD)" = "N" ] && \
20+
echo "\n⚠️ Unsigned commit: bdk_floresta requires commits to be signed." || \
21+
true
22+
23+
# Delete files: bitcoin, signet, testnet4, target, lockfile
24+
delete item="data":
25+
just _delete-{{ item }}
26+
27+
_delete-bitcoin:
28+
rm -rf data/bitcoin
29+
30+
_delete-signet:
31+
rm -rf data/signet
32+
33+
_delete-testnet4:
34+
rm -rf data/testnet4
35+
36+
_delete-target:
37+
rm -rf target
38+
39+
_delete-lockfile:
40+
rm -f Cargo.lock
41+
42+
# Run an example crate
43+
example name="example":
44+
cargo run --example {{ name }} --release
45+
46+
# Format code
47+
fmt:
48+
cargo +nightly fmt

0 commit comments

Comments
 (0)