Skip to content

Commit

Permalink
add ci job to check if schema is up to date
Browse files Browse the repository at this point in the history
  • Loading branch information
icewind1991 committed May 6, 2024
1 parent 4e6d6e4 commit f8651c2
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 5 deletions.
16 changes: 16 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 --
3 changes: 2 additions & 1 deletion flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@
};
};
};
overlayPackages = builtins.attrNames ((import ./nix/overlay.nix) {} {});
in rec {
packages =
lib.attrsets.genAttrs targets (target:
Expand All @@ -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";
Expand Down
5 changes: 3 additions & 2 deletions nix/codegen.nix
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
lib,
}: let
inherit (lib.sources) sourceByRegex;
src = sourceByRegex ../. ["Cargo.*" "(src|benches)(/.*)?"];
in
rustPlatform.buildRustPackage {
pname = "demostf-parser-codegen";
Expand All @@ -14,7 +13,7 @@ in
--bin codegen
'';

src = lib.traceVal src;
src = sourceByRegex ../. ["Cargo.*" "(src|benches)(/.*)?"];

buildType = "debug";
buildFeatures = ["codegen"];
Expand All @@ -24,4 +23,6 @@ in
cargoLock = {
lockFile = ../Cargo.lock;
};

meta.mainProgram = "codegen";
}
2 changes: 2 additions & 0 deletions nix/overlay.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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 {};

}
5 changes: 3 additions & 2 deletions nix/schema.nix
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
lib,
}: let
inherit (lib.sources) sourceByRegex;
src = sourceByRegex ../. ["Cargo.*" "(src|benches)(/.*)?"];
in
rustPlatform.buildRustPackage {
pname = "demostf-parser-schema";
Expand All @@ -14,7 +13,7 @@ in
--bin schema
'';

src = lib.traceVal src;
src = sourceByRegex ../. ["Cargo.*" "(src|benches)(/.*)?"];

buildType = "debug";
buildFeatures = ["schema"];
Expand All @@ -24,4 +23,6 @@ in
cargoLock = {
lockFile = ../Cargo.lock;
};

meta.mainProgram = "schema";
}

0 comments on commit f8651c2

Please sign in to comment.