From bef8b677d7546ff4f4eaa2f1b936325479a0c303 Mon Sep 17 00:00:00 2001 From: jutty Date: Mon, 29 Jun 2026 02:56:17 -0300 Subject: [PATCH] CI: Wrap nix devshell invocation with just This commit also adds the flake version to the justfile's version check. --- .forgejo/workflows/verify.yaml | 30 ++++++++++----------- .justfile | 48 +++++++++++++++++++--------------- flake.nix | 2 +- 3 files changed, 43 insertions(+), 37 deletions(-) diff --git a/.forgejo/workflows/verify.yaml b/.forgejo/workflows/verify.yaml index 1370061..27e6efb 100644 --- a/.forgejo/workflows/verify.yaml +++ b/.forgejo/workflows/verify.yaml @@ -16,10 +16,13 @@ jobs: container: image: rust:slim steps: - - name: Install action dependencies + - name: Set up action dependencies run: | apt-get install --no-install-recommends --update -y \ nodejs git nix + echo experimental-features = nix-command flakes >> /etc/nix/nix.conf + echo 'export PATH=$PATH:$HOME/.nix-profile/bin' >> /root/.bashrc + nix profile install nixpkgs#just # trixie is on nix 2.26 - name: Checkout code uses: actions/checkout@v6 @@ -36,20 +39,17 @@ jobs: run: | rust_version=$(sed -nE 's/^rust-version = "(.*)"$/\1/p' Cargo.toml) - su ci -c " - rustup default '$rust_version' - rustup toolchain install nightly - rustup component add llvm-tools - rustup component add --toolchain nightly rustfmt clippy - rustup target add \ - x86_64-unknown-linux-musl \ - x86_64-unknown-linux-gnu - " + # su ci -c " + # rustup default '$rust_version' + # rustup toolchain install nightly + # rustup component add llvm-tools + # rustup component add --toolchain nightly rustfmt clippy + # rustup target add \ + # x86_64-unknown-linux-musl \ + # x86_64-unknown-linux-gnu + # " - name: Assess run: | - ENV_PATH=$PATH su ci -c " - nix --experimental-features 'nix-command flakes' \ - develop path:$PWD \ - -c just -f $PWD/.justfile verify - " + echo $PATH + just ci-nix "$PATH" verify || /root/.nix-profile/bin/just ci-nix "$PATH" verify diff --git a/.justfile b/.justfile index a3362b4..a6f39fd 100644 --- a/.justfile +++ b/.justfile @@ -310,17 +310,17 @@ check: alias c := check # Run tests -[group: 'assess'] +[group: 'assess', script] test pattern="": cargo test {{ pattern }} --timings -- --test-threads=1 'serial_tests::' cargo test {{ pattern }} --timings --bin en cargo test {{ pattern }} --timings --doc cargo test {{ pattern }} --timings --lib -- --skip 'serial_tests::' - {{ if which("wine") == "" { - "echo Skipping Windows tests: wine not found" - } else { - just_cmd + " test-windows" - } }} + if command -v wine >/dev/null; then + {{ just_cmd }} test-windows + else + echo "Skipping Windows tests: wine not found" + fi alias t := test @@ -383,17 +383,15 @@ alias v := verify [script, group: 'assess'] [arg("remote", long="remote", short="r", value="true")] version-assess remote="false": update - last_remote_tag=$( - git ls-remote --tags --sort=-creatordate origin | - head -n 1 | tr -d v | cut -d / -f 3 - ) - printf 'Local: %s\nRemote: %s\nManifest: %s\nLockfile: %s\n' \ - "{{ last_local_tag }}" \ - "$last_remote_tag" \ - "{{ manifest_version }}" \ - "{{ lockfile_version }}" + echo "Local: {{ last_local_tag }}" + echo "Remote: {{ last_remote_tag }}" + echo "Manifest: {{ manifest_version }}" + echo "Lockfile: {{ lockfile_version }}" + echo "Flake: {{ flake_version }}" + test "{{ last_local_tag }}" = "{{ lockfile_version }}" test "{{ last_local_tag }}" = "{{ manifest_version }}" + test "{{ last_local_tag }}" = "{{ flake_version }}" if {{ if remote == "true" { "true" } else { "false" } }}; then test "{{ last_local_tag }}" = "$last_remote_tag" fi @@ -529,12 +527,15 @@ alias ch := choose [script, private] ci recipes: - ENV_PATH="$PATH" su ci -c "{{ just_cmd }} -f '{{ justfile() }}' {{ recipes }}" + su ci -c "{{ just_cmd }} -f '{{ justfile() }}' {{ recipes }}" [script, private] -ci-nix recipes: - ENV_PATH="$PATH" su ci -c "nix develop --command \ - {{ just_cmd }} -f '{{ justfile() }}' {{ recipes }}" +ci-nix path recipes: + ENV_PATH="{{ path }}" su ci -c " + nix --experimental-features 'nix-command flakes' \ + develop "path:{{ justfile_directory() }}" --command \ + {{ just_cmd }} -f '{{ justfile() }}' {{ recipes }} + " [private] smoke: @@ -555,12 +556,17 @@ watch_cmd := "watchexec -qc -r -e rs,toml,html,css --color always -- " cover_cmd := 'cargo llvm-cov --color always --ignore-filename-regex "main\.rs|log\.rs"' last_local_tag := `git tag --sort=-creatordate | head -n 1 | tr -d v` +last_remote_tag := ``` + git ls-remote --tags --sort=-creatordate origin | + head -n 1 | tr -d v | cut -d / -f 3 +``` manifest_version := `grep "^version" Cargo.toml | cut -d \" -f 2` lockfile_version := ``` grep -A 1 'name = "en"' Cargo.lock \ | grep version | cut -d '"' -f 2 - ``` +``` +flake_version := `grep '^ *version = "' flake.nix | cut -d \" -f 2` ## OPTIONS -set unstable +set unstable # TODO remove this once all used features are stabilized set lazy diff --git a/flake.nix b/flake.nix index 0c4f0aa..3f51ba2 100644 --- a/flake.nix +++ b/flake.nix @@ -5,7 +5,7 @@ outputs = { nixpkgs, self }: let name = "en"; - version = "0.4.0"; + version = "0.4.0-alpha"; supportedSystems = [ "x86_64-linux"