Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem: testground image not pushed to registry #1479

Merged
merged 5 commits into from
Jun 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 52 additions & 0 deletions .github/workflows/container.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: Push Testground Image

on:
push:
branches:
- main
tags:
- "v*.*.*"

env:
IMAGE_NAME: cronos-testground

jobs:

push:
runs-on: ubuntu-latest
permissions:
packages: write
contents: read

steps:
- uses: actions/checkout@v4
- uses: cachix/install-nix-action@v23
with:
nix_path: nixpkgs=channel:nixos-24.05
extra_nix_config: |
access-tokens = github.com=${{ secrets.GITHUB_TOKEN }}
- uses: cachix/cachix-action@v12
with:
name: cronos
signingKey: "${{ secrets.CACHIX_SIGNING_KEY }}"
- name: build and push image
run: |
# login to ghcr.io
echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin

VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,')
[[ "${{ github.ref }}" == "refs/tags/"* ]] && VERSION=$(echo $VERSION | sed -e 's/^v//')
[ "$VERSION" == "main" ] && VERSION=latest
echo "VERSION: $VERSION"

IMAGE_ID=ghcr.io/${{ github.repository_owner }}/$IMAGE_NAME
IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]')
echo "IMAGE_ID: $IMAGE_ID"

BUILD_TAG="$(nix eval --raw .#testground-image.imageTag)"
echo "BUILD_TAG: $BUILD_TAG"

docker load -i "$(nix build --no-link --print-out-paths .#testground-image)"
docker run --rm -e TEST_CASE=info $IMAGE_NAME:$BUILD_TAG
docker tag $IMAGE_NAME:$BUILD_TAG $IMAGE_ID:$VERSION
docker push $IMAGE_ID:$VERSION
18 changes: 9 additions & 9 deletions flake.lock

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

4 changes: 3 additions & 1 deletion flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
in
rec {
packages = pkgs.cronos-matrix // {
inherit (pkgs) rocksdb;
inherit (pkgs) rocksdb testground-image;
};
apps = {
cronosd = mkApp packages.cronosd;
Expand Down Expand Up @@ -72,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
15 changes: 15 additions & 0 deletions nix/testground-image.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{ dockerTools, cronos-matrix, testground-testcase }:
dockerTools.buildLayeredImage {
name = "cronos-testground";
contents = [
testground-testcase
cronos-matrix.cronosd
];
config = {
Expose = [ 9090 26657 26656 1317 26658 26660 26659 30000 ];
Cmd = [ "/bin/testground-testcase" ];
Env = [
"PYTHONUNBUFFERED=1"
];
};
}
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
145 changes: 15 additions & 130 deletions testground/benchmark/flake.lock

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

Loading
Loading