Skip to content

Commit

Permalink
feat: justfile with github actions
Browse files Browse the repository at this point in the history
  • Loading branch information
refcell committed Jul 24, 2024
1 parent bd5f233 commit 9b28c48
Show file tree
Hide file tree
Showing 4 changed files with 151 additions and 9 deletions.
100 changes: 100 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
name: Rust CI

on:
push:
branches: [main]
merge_group:
pull_request:

env:
CARGO_TERM_COLOR: always

jobs:
cargo-tests:
runs-on: ubuntu-latest
timeout-minutes: 20
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
with:
cache-on-failure: true
- uses: taiki-e/install-action@nextest
- name: cargo nextest
run: cargo nextest run --release --workspace --all --locked
run: just test
cargo-lint:
runs-on: ubuntu-latest
timeout-minutes: 20
name: lint
steps:
- uses: actions/checkout@v4
- uses: taiki-e/install-action@just
- uses: dtolnay/rust-toolchain@nightly
with:
components: rustfmt, clippy
- uses: Swatinem/rust-cache@v2
with:
cache-on-failure: true
- name: Log into ghcr
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: fmt + lint
run: just lint
- name: chown target
run: sudo chown -R $(id -u):$(id -g) ./target
cargo-build-benches:
runs-on: ubuntu-latest
timeout-minutes: 20
name: build-benchmarks
continue-on-error: true
steps:
- uses: actions/checkout@v4
- uses: taiki-e/install-action@just
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
with:
cache-on-failure: true
- name: build benches
run: cargo bench --no-run --workspace --all
- name: chown target
run: sudo chown -R $(id -u):$(id -g) ./target
cargo-build:
runs-on: ubuntu-latest
timeout-minutes: 20
name: build
continue-on-error: true
steps:
- uses: actions/checkout@v4
- uses: taiki-e/install-action@just
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
with:
cache-on-failure: true
- name: Log into ghcr
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: build
run: just build
- name: chown target
run: sudo chown -R $(id -u):$(id -g) ./target
cargo-doc:
runs-on: ubuntu-latest
timeout-minutes: 20
steps:
- uses: actions/checkout@v4
- uses: taiki-e/install-action@just
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
with:
cache-on-failure: true
- name: doclint
run: just lint-docs
- name: doctest
run: just test-docs
46 changes: 46 additions & 0 deletions Justfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
set positional-arguments
alias t := test
alias f := fmt
alias l := lint
alias b := build

# default recipe to display help information
default:
@just --list

# Run all tests
tests: test test-docs

# Test for the native target with all features
test *args='':
cargo nextest run --workspace --all --all-features $@

# Test the Rust documentation
test-docs:
cargo test --doc --all --locked

# Fixes and checks all workspace formatting
fmt: fmt-fix fmt-check

# Fixes the formatting of the workspace
fmt-fix:
cargo +nightly fmt --all

# Check the formatting of the workspace
fmt-check:
cargo +nightly fmt --all -- --check

# Lint workspace and docs
lint: lint-docs clippy

# Lint the Rust documentation
lint-docs:
RUSTDOCFLAGS="-D warnings" cargo doc --all --no-deps --document-private-items

# Run clippy lints on the workspace
clippy:
cargo +nightly clippy --workspace --all --all-features --all-targets -- -D warnings

# Build for the native target
build *args='':
cargo build --workspace --all $@
2 changes: 1 addition & 1 deletion crates/opt8n/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ pub enum Commands {
#[command(visible_alias = "s")]
Script {
#[command(flatten)]
script_args: ScriptArgs,
script_args: Box<ScriptArgs>,
},
}

Expand Down
12 changes: 4 additions & 8 deletions crates/opt8n/src/opt8n.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,10 @@ impl Opt8n {
output_file: PathBuf,
genesis: Option<PathBuf>,
) -> Self {
let genesis = if let Some(path) = genesis.as_ref() {
Some(
serde_json::from_reader(File::open(path).expect("TODO: handle error Invalid path"))
.expect("TODO: handle error Invalid genesis"),
)
} else {
None
};
let genesis = genesis.as_ref().map(|path| {
serde_json::from_reader(File::open(path).expect("TODO: handle error Invalid path"))
.expect("TODO: handle error Invalid genesis")
});

let node_config = node_config
.unwrap_or_default()
Expand Down

0 comments on commit 9b28c48

Please sign in to comment.