Skip to content

Commit

Permalink
Fix integration-test
Browse files Browse the repository at this point in the history
  • Loading branch information
linyinfeng committed Dec 1, 2023
1 parent d1fb388 commit 91019af
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 10 deletions.
11 changes: 6 additions & 5 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,8 @@ jobs:
- name: Get test packages from cache.nixos.org
run: |
nix path-info --derivation --recursive "$PACKAGE_FOR_TEST" > /tmp/derivers
cat /tmp/derivers | xargs nix build --no-link --print-out-paths > /tmp/derived
nix build "$PACKAGE_FOR_TEST" --no-link --print-out-paths > /tmp/derived
cat /tmp/derived | xargs nix path-info --recursive > /tmp/derived_closure
cat /tmp/derivers /tmp/derived_closure | sort | uniq > /tmp/store_paths
Expand All @@ -137,7 +138,7 @@ jobs:
# sign first,then push with --already-signed
# oranc will check generated signature matches already exists signature
cat /tmp/store_paths | \
cat /tmp/derived_closure | \
xargs nix store sign --key-file /tmp/nix-key-pair/secret
# push everything
Expand All @@ -151,7 +152,7 @@ jobs:
--already-signed
- name: Verify remote store
run: |
cat /tmp/store_paths | \
cat /tmp/derived_closure | \
xargs nix store verify \
--store "$STORE_URL" \
--trusted-public-keys "$(cat /tmp/nix-key-pair/public)"
Expand All @@ -162,14 +163,14 @@ jobs:
run: |
# instantiate derivations again
nix path-info --derivation --recursive "$PACKAGE_FOR_TEST" > /dev/null
cat /tmp/derived_closure | \
cat /tmp/derived | \
xargs nix build \
--no-link \
--max-jobs 0 \
--substituters "$STORE_URL" \
--trusted-public-keys "$(cat /tmp/nix-key-pair/public)"
- name: Verify local store
run: |
cat /tmp/store_paths | \
cat /tmp/derived_closure | \
xargs nix store verify \
--trusted-public-keys "$(cat /tmp/nix-key-pair/public)"
7 changes: 7 additions & 0 deletions integration-test/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
curl,
findutils,
shadow,
gnused,
tcping-go,
}: let
packageForTest = "github:nixos/nixpkgs/nixos-unstable#coreutils";
composeFile = (formats.yaml {}).generate "container-compose-yml" {
Expand All @@ -24,6 +26,9 @@
environment = [
"EXTRA_ARGS=--no-ssl"
];
depends_on = {
registry = {condition = "service_started";};
};
};
oranc-test-script = {
image = "oranc-test-script:${dockerImage.imageTag}";
Expand Down Expand Up @@ -54,6 +59,8 @@
curl
findutils
shadow
tcping-go
gnused
dockerTools.caCertificates
];
};
Expand Down
10 changes: 5 additions & 5 deletions integration-test/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ stage "setting up variables..."

registry="registry:5000"
repository="test-user/oranc-cache"
substituter="http://oranc/registry:5000/$repository"
substituter="http://oranc/$registry/$repository"
public_key="$(cat public)"
export ORANC_SIGNING_KEY="$(cat secret)"

Expand All @@ -64,7 +64,7 @@ curl "$substituter/nix-cache-info" -v
stage "get test packages"

nix path-info --derivation --recursive "$PACKAGE_FOR_TEST" >derivers
cat derivers | xargs nix build --no-link --print-out-paths >derived
nix build "$PACKAGE_FOR_TEST" --no-link --print-out-paths >derived
cat derived | xargs nix path-info --recursive >derived_closure
cat derivers derived_closure >store_paths

Expand All @@ -80,7 +80,7 @@ cat store_paths

# sign first, then push with --already-signed
# oranc will check its signature matches already exists signature
cat store_paths | xargs nix store sign --key-file secret --verbose
cat derived_closure | xargs nix store sign --key-file secret --verbose
cat store_paths |
oranc push \
--no-ssl \
Expand All @@ -104,7 +104,7 @@ stage "get test package from registry"

# instantiate derivations again
nix path-info --derivation --recursive "$PACKAGE_FOR_TEST" >/dev/null
cat derived_closure |
cat derived |
xargs nix build \
--no-link \
--max-jobs 0 \
Expand All @@ -114,6 +114,6 @@ cat derived_closure |

stage "verify local store"

cat store_paths | xargs nix store verify \
cat derived_closure | xargs nix store verify \
--trusted-public-keys "$public_key" \
--verbose

0 comments on commit 91019af

Please sign in to comment.