Skip to content

Commit

Permalink
tests: enable namaka ci tests based on the previous commit
Browse files Browse the repository at this point in the history
  • Loading branch information
blaggacao committed Jun 23, 2023
1 parent b7a2649 commit 1dfd574
Show file tree
Hide file tree
Showing 9 changed files with 84 additions and 14 deletions.
46 changes: 43 additions & 3 deletions .github/workflows/std.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ jobs:
id: discovery

build_cli:
needs: discover
needs: [discover, check_tests]
if: fromJSON(needs.discover.outputs.hits).cli.build != '{}'
strategy:
fail-fast: false
Expand All @@ -67,7 +67,7 @@ jobs:
extra_nix_config: ${{ needs.discover.outputs.nix_conf }}

build_packages:
needs: discover
needs: [discover, check_tests]
if: fromJSON(needs.discover.outputs.hits).packages.build != '{}'
strategy:
fail-fast: false
Expand All @@ -87,7 +87,7 @@ jobs:
extra_nix_config: ${{ needs.discover.outputs.nix_conf }}

build_shells:
needs: discover
needs: [discover, check_tests]
if: fromJSON(needs.discover.outputs.hits).shells.build != '{}'
strategy:
fail-fast: false
Expand All @@ -105,3 +105,43 @@ jobs:
nix_cache: s3://cache.divnix.com?endpoint=fra1.digitaloceanspaces.com
discovery_json: ${{ toJSON(matrix.target) }}
extra_nix_config: ${{ needs.discover.outputs.nix_conf }}

check_tests:
needs: discover
if: fromJSON(needs.discover.outputs.hits).checks.check != '{}'
strategy:
fail-fast: false
matrix:
target: ${{ fromJSON(needs.discover.outputs.hits).checks.check }}
name: //${{ matrix.target.cell }}/${{ matrix.target.block }}/${{ matrix.target.name }}:${{ matrix.target.action }}
runs-on: ${{ inputs.runs-on }}
steps:
- name: Install Nix Early (to update subflake references)
uses: nixbuild/nix-quick-install-action@v22
with:
nix_conf: |
experimental-features = nix-command flakes
accept-flake-config = true
- uses: actions/checkout@v3
- name: Update subflake references
run: |
# create the store path of
nix store add-path --name source .
# update the subflake lockfile to the (now existing) store path
# set lastModified to 1 because unknown issues in the GH action environment
(cd ./src/local && nix flake lock --update-input std && (
jq '.nodes.std.locked.lastModified = 1' flake.lock > flake.lock.new && rm flake.lock && mv flake.lock.new flake.lock
) && git add -f flake.lock)
(cd ./src/tests && nix flake lock --update-input std && (
jq '.nodes.std.locked.lastModified = 1' flake.lock > flake.lock.new && rm flake.lock && mv flake.lock.new flake.lock
) &&git add -f flake.lock)
# continue normally ...
- uses: divnix/std-action/run@v0.23.0
env:
AWS_ACCESS_KEY_ID: ${{ secrets.S3_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.S3_SECRET }}
with:
nix_signing_key: ${{ secrets.NIX_KEY }}
nix_cache: s3://cache.divnix.com?endpoint=fra1.digitaloceanspaces.com
discovery_json: ${{ toJSON(matrix.target) }}
extra_nix_config: ${{ needs.discover.outputs.nix_conf }}
2 changes: 1 addition & 1 deletion dogfood.nix
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ in
(devshells "shells" {ci.build = true;})
(nixago "configs")
(containers "containers")
(namaka "checks")
(namaka "checks" {ci.check = true;})
];
}
{
Expand Down
6 changes: 3 additions & 3 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions namaka.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[check]
cmd = ["nix", "eval", ".#checks.snapshots"]
cmd = ["nix", "eval", ".#checks.snapshots.check"]

[eval]
cmd = ["nix", "eval", ".#checks.snapshots"]
cmd = ["nix", "eval", ".#checks.snapshots.check"]
2 changes: 1 addition & 1 deletion src/std/fwlib/blockTypes/namaka.nix
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ in
pkg = inputs.namaka.packages.${currentSystem}.default;
in [
(mkCommand currentSystem "check" "run namaka tests against snapshots" [pkg] ''
namaka check -c nix eval '.#${fragment}'
namaka check -c nix eval '.#${fragment}.check'
'' {})
];
}
11 changes: 7 additions & 4 deletions src/tests/checks.nix
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
let
inherit (inputs) namaka self;
inputs' = builtins.removeAttrs inputs ["self"];
in {
inherit inputs;
snapshots = namaka.lib.load {
src = self + /tests;
inputs = builtins.removeAttrs inputs ["self"];
snapshots = {
meta.description = "The main Standard Snapshotting test suite";
check = namaka.lib.load {
src = self + /tests;
inputs = inputs' // {inputs = inputs';};
};
};
}
19 changes: 19 additions & 0 deletions tests/_snapshots/check-augmented-cell-inputs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#pretty
{
arion = "/nix/store/8px6k532a5fvz0k7ckhj3kfyqxbhz317-source";
blank = "/nix/store/scflkbbsqxlzxvja3gm4xf1y2kvsww32-source";
cells = "no .outPath";
devshell = "/nix/store/gadmzrrq2dygvzy3yqp5x7gfbd7l2pw1-source";
dmerge = "/nix/store/8b67fxqldqv1x3x07nhabb9ild2zl6rz-source";
haumea = "/nix/store/ih873qmabdsdgk1naaiv6v7jy1mxq241-source";
incl = "/nix/store/4dqlpd9c8yil4ay4prr38vslxhpsp4zp-source";
makes = "/nix/store/71rzg7vs53gmxqph64d9zqf4ns928c6c-source";
microvm = "/nix/store/v5za7dzczgcvfvqgcm80qari3msyhw6b-source";
n2c = "/nix/store/rgd4s5ylv38p94wi6vays6wc1a0l5iyf-source";
namaka = "/nix/store/xgzvi3baaaz9lpymfv6f1fgxfmy0ygvv-source";
nixago = "/nix/store/cys15p6lyyhj85bk4bckn82waih2l945-source";
nixpkgs = "/nix/store/yf26s7734ql7q05zlq6nq4y5q3rjyhj7-source";
paisano = "/nix/store/ypilc1pa3g7ycrsg9rq41cfqappsdxqk-source";
paisano-tui = "/nix/store/w5wg8h6506raj0qxwal4w8hg7iwchnv5-source";
yants = "/nix/store/np6pvhkza8grv26qypzpibwrrg7kqxkc-source";
}
7 changes: 7 additions & 0 deletions tests/check-augmented-cell-inputs/expr.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{inputs}:
builtins.mapAttrs (n: v:
if v ? outPath
then builtins.unsafeDiscardStringContext (toString v)
else "no .outPath")
# std is too volatile as long as suflakes aren't solved
(builtins.removeAttrs inputs ["std"])
1 change: 1 addition & 0 deletions tests/check-augmented-cell-inputs/format.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"pretty"

0 comments on commit 1dfd574

Please sign in to comment.