Skip to content

Commit

Permalink
ci: format (#25)
Browse files Browse the repository at this point in the history
* refactor(just): allow just {fmt,format} via alias

* ci(format): add nix-based formatting workflow

* fix(just): pass *args in fmt recipe

* ci(format): run in check mode

* fix: typo in format action

* ci(format): better step name

* format: cargo fmt
  • Loading branch information
cmdoret authored Feb 19, 2025
1 parent f051675 commit 531b7dd
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 8 deletions.
26 changes: 26 additions & 0 deletions .github/workflows/format.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: format
on:
pull_request:
push:
branches: main
jobs:
format:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- uses: cachix/install-nix-action@v30
with:
nix_path: nixpkgs=channel:nixos-unstable

- uses: cachix/cachix-action@v15
with:
name: "${{ secrets.CACHIX_CACHE_NAME }}"
authToken: "${{ secrets.CACHIX_AUTH_TOKEN }}"

- name: check code formatting
run: |
nix develop \
./tools/nix#default \
--accept-flake-config \
--command bash -c "just fmt --check"
5 changes: 3 additions & 2 deletions justfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,10 @@ build *args:
test *args:
cargo test

alias fmt := format
# Format all crates
fmt *args:
cargo fmt
format *args:
cargo fmt {{args}}

# Run the synth-converter.
run input_file output_file *args:
Expand Down
2 changes: 1 addition & 1 deletion src/catplus-common/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
pub mod graph;
pub mod models;
pub mod rdf;
pub mod rdf;
6 changes: 4 additions & 2 deletions src/catplus-common/src/models/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -334,8 +334,10 @@ mod tests {
use sophia::iri::IriRef;
use sophia_api::term::Term;

use crate::graph::{graph_builder::GraphBuilder, insert_into::InsertIntoGraph};
use crate::models::{ErrorMargin, Observation};
use crate::{
graph::{graph_builder::GraphBuilder, insert_into::InsertIntoGraph},
models::{ErrorMargin, Observation},
};

#[test]
fn test_observation_to_triples() -> anyhow::Result<()> {
Expand Down
3 changes: 1 addition & 2 deletions src/synth-converter/src/convert.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use catplus_common::graph::graph_builder::GraphBuilder;
use catplus_common::models::types::Batch;
use anyhow::{Context, Result};
use catplus_common::{graph::graph_builder::GraphBuilder, models::types::Batch};

/// Parse JSON and serialize the RDF graph to the specified format
///
Expand Down
2 changes: 1 addition & 1 deletion src/synth-converter/tests/convert_tests.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use catplus_common::rdf::rdf_parser::parse_turtle_to_graph;
use sophia_isomorphism::isomorphic_graphs;
use synth_converter::convert::json_to_rdf;
use catplus_common::rdf::rdf_parser::parse_turtle_to_graph;

#[test]
fn test_convert_filtrate_action() {
Expand Down

0 comments on commit 531b7dd

Please sign in to comment.