From f8651c22ffc247a9247949ef0fa4f89f281fdf05 Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Mon, 6 May 2024 15:34:49 +0200 Subject: [PATCH] add ci job to check if schema is up to date --- .github/workflows/ci.yml | 16 ++++++++++++++++ flake.nix | 3 ++- nix/codegen.nix | 5 +++-- nix/overlay.nix | 2 ++ nix/schema.nix | 5 +++-- 5 files changed, 26 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index dd339b6..7a24474 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -91,3 +91,19 @@ jobs: instance: https://cache.icewind.me authToken: '${{ secrets.ATTIC_TOKEN }}' - run: nix build .#test + + check-schema: + runs-on: ubuntu-latest + needs: check + steps: + - uses: actions/checkout@v4 + - uses: cachix/install-nix-action@v25 + - uses: icewind1991/attic-action@v1 + with: + name: ci + instance: https://cache.icewind.me + authToken: '${{ secrets.ATTIC_TOKEN }}' + - run: nix run .#demostf-parser-schema > schema.json + - run: | + git diff + git diff-index --quiet HEAD -- diff --git a/flake.nix b/flake.nix index 0a56a7d..377b0a9 100644 --- a/flake.nix +++ b/flake.nix @@ -87,6 +87,7 @@ }; }; }; + overlayPackages = builtins.attrNames ((import ./nix/overlay.nix) {} {}); in rec { packages = lib.attrsets.genAttrs targets (target: @@ -101,7 +102,7 @@ }; })) // rec { - inherit (pkgs) demostf-parser demostf-parser-codegen demostf-parser-codegen-events demostf-parser-codegen-props; + inherit (pkgs) demostf-parser demostf-parser-codegen demostf-parser-codegen-events demostf-parser-codegen-props demostf-parser-schema; check = hostNaersk.buildPackage (nearskOpt // { mode = "check"; diff --git a/nix/codegen.nix b/nix/codegen.nix index ef3d41f..182ad03 100644 --- a/nix/codegen.nix +++ b/nix/codegen.nix @@ -4,7 +4,6 @@ lib, }: let inherit (lib.sources) sourceByRegex; - src = sourceByRegex ../. ["Cargo.*" "(src|benches)(/.*)?"]; in rustPlatform.buildRustPackage { pname = "demostf-parser-codegen"; @@ -14,7 +13,7 @@ in --bin codegen ''; - src = lib.traceVal src; + src = sourceByRegex ../. ["Cargo.*" "(src|benches)(/.*)?"]; buildType = "debug"; buildFeatures = ["codegen"]; @@ -24,4 +23,6 @@ in cargoLock = { lockFile = ../Cargo.lock; }; + + meta.mainProgram = "codegen"; } diff --git a/nix/overlay.nix b/nix/overlay.nix index 750be5d..834a6e0 100644 --- a/nix/overlay.nix +++ b/nix/overlay.nix @@ -9,4 +9,6 @@ final: prev: { ${final.demostf-parser-codegen}/bin/codegen ${../test_data/short-2024.dem} props > $out ${final.rustfmt}/bin/rustfmt $out ''; + demostf-parser-schema = final.callPackage ./schema.nix {}; + } diff --git a/nix/schema.nix b/nix/schema.nix index 6ee6834..d820159 100644 --- a/nix/schema.nix +++ b/nix/schema.nix @@ -4,7 +4,6 @@ lib, }: let inherit (lib.sources) sourceByRegex; - src = sourceByRegex ../. ["Cargo.*" "(src|benches)(/.*)?"]; in rustPlatform.buildRustPackage { pname = "demostf-parser-schema"; @@ -14,7 +13,7 @@ in --bin schema ''; - src = lib.traceVal src; + src = sourceByRegex ../. ["Cargo.*" "(src|benches)(/.*)?"]; buildType = "debug"; buildFeatures = ["schema"]; @@ -24,4 +23,6 @@ in cargoLock = { lockFile = ../Cargo.lock; }; + + meta.mainProgram = "schema"; }