Skip to content

Commit

Permalink
check image validity
Browse files Browse the repository at this point in the history
  • Loading branch information
yihuang committed Jun 20, 2024
1 parent 9220ce7 commit 303b0b8
Show file tree
Hide file tree
Showing 6 changed files with 241 additions and 6 deletions.
6 changes: 3 additions & 3 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,7 @@
let
pkgs = import nixpkgs {
inherit system;
overlays = self.overlays.default ++ [
(import ./testground/benchmark/overlay.nix)
];
overlays = self.overlays.default;
config = { };
};
in
Expand Down Expand Up @@ -74,12 +72,14 @@
(import ./nix/build_overlay.nix)
poetry2nix.overlays.default
gomod2nix.overlays.default
(import ./testground/benchmark/overlay.nix)
(final: super: {
go = super.go_1_22;
test-env = final.callPackage ./nix/testenv.nix { };
cronos-matrix = final.callPackage ./nix/cronos-matrix.nix {
bundle-exe = final.pkgsBuildBuild.callPackage nix-bundle-exe { };
};
testground-image = final.callPackage ./nix/testground-image.nix { };
})
];
};
Expand Down
11 changes: 9 additions & 2 deletions testground/benchmark/benchmark/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,13 @@ def __init__(self, params: RunParams = None):
if params is None:
params = run_params()
self.params = params
self.sync = SyncService(params)
self._sync = None

@property
def sync(self) -> SyncService:
if self._sync is None:
self._sync = SyncService(self.params)
return self._sync

def init_common(self):
self.wait_network_ready()
Expand Down Expand Up @@ -107,4 +113,5 @@ def __enter__(self):
return self

def __exit__(self, exc_type, exc_val, exc_tb):
self.sync.close()
if self._sync is not None:
self._sync.close()
8 changes: 8 additions & 0 deletions testground/benchmark/benchmark/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,16 @@ def entrypoint(ctx: Context):
ctx.record_success()


def info(ctx: Context):
"""
Print the runtime configuration, mainly to check if the image is built successfully.
"""
print(ctx.params)


TEST_CASES = {
"entrypoint": entrypoint,
"info": info,
}


Expand Down
144 changes: 144 additions & 0 deletions testground/benchmark/flake.lock

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

77 changes: 77 additions & 0 deletions testground/benchmark/flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
{
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
flake-utils.url = "github:numtide/flake-utils";
poetry2nix = {
url = "github:nix-community/poetry2nix";
inputs.nixpkgs.follows = "nixpkgs";
inputs.flake-utils.follows = "flake-utils";
};
};

outputs = { self, nixpkgs, flake-utils, poetry2nix }:
let
overrides = { lib, poetry2nix }: poetry2nix.overrides.withDefaults
(self: super:
let
buildSystems = {
pystarport = [ "poetry-core" ];
durations = [ "setuptools" ];
multitail2 = [ "setuptools" ];
docker = [ "hatchling" "hatch-vcs" ];
pyunormalize = [ "setuptools" ];
};
in
lib.mapAttrs
(attr: systems: super.${attr}.overridePythonAttrs
(old: {
nativeBuildInputs = (old.nativeBuildInputs or [ ]) ++ map (a: self.${a}) systems;
}))
buildSystems
);

src = nix-gitignore: nix-gitignore.gitignoreSourcePure [
"/*" # ignore all, then add whitelists
"!/benchmark/"
"!poetry.lock"
"!pyproject.toml"
] ./.;

benchmark = { lib, poetry2nix, python311, nix-gitignore }: poetry2nix.mkPoetryApplication {
projectDir = src nix-gitignore;
python = python311;
overrides = overrides { inherit lib poetry2nix; };
};

benchmark-env = { lib, poetry2nix, python311, nix-gitignore }: poetry2nix.mkPoetryEnv {
projectDir = src nix-gitignore;
python = python311;
overrides = overrides { inherit lib poetry2nix; };
};

in
(flake-utils.lib.eachDefaultSystem
(system:
let
pkgs = import nixpkgs {
inherit system;
overlays = [
poetry2nix.overlays.default
(import ./overlay.nix)
];
config = { };
};
in
rec {
packages.default = pkgs.testground-testcase;
apps.default = {
type = "app";
program = "${pkgs.testground-testcase}/bin/testground-testcase";
};
devShells.default = pkgs.mkShell {
buildInputs = [ pkgs.testground-testcase-env ];
};
legacyPackages = pkgs;
})
);
}
1 change: 0 additions & 1 deletion testground/benchmark/overlay.nix
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,5 @@ let
in
{
testground-testcase = final.callPackage benchmark { };
testground-image = final.callPackage ../../nix/testground-image.nix { };
testground-testcase-env = final.callPackage benchmark-env { };
}

0 comments on commit 303b0b8

Please sign in to comment.