From b334267ea7ca262a0bdde0c64aea8248d6ea8fc7 Mon Sep 17 00:00:00 2001 From: Alex Gartner Date: Wed, 23 Oct 2024 17:05:11 -0700 Subject: [PATCH 1/2] chore: always set explicit base compose file (#3037) --- Makefile | 30 +++++++++++++++--------------- docs/development/LOCAL_TESTING.md | 2 +- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/Makefile b/Makefile index f1e56c2953..1e87c984e9 100644 --- a/Makefile +++ b/Makefile @@ -8,7 +8,7 @@ DOCKER ?= docker # allow setting of NODE_COMPOSE_ARGS to pass additional args to docker compose # useful for setting profiles and/ort optional overlays # example: NODE_COMPOSE_ARGS="--profile monitoring -f docker-compose-persistent.yml" -DOCKER_COMPOSE ?= $(DOCKER) compose $(NODE_COMPOSE_ARGS) +DOCKER_COMPOSE ?= $(DOCKER) compose -f docker-compose.yml $(NODE_COMPOSE_ARGS) DOCKER_BUF := $(DOCKER) run --rm -v $(CURDIR):/workspace --workdir /workspace bufbuild/buf GOFLAGS := "" GOLANG_CROSS_VERSION ?= v1.22.4 @@ -221,11 +221,11 @@ start-localnet: zetanode start-localnet-skip-build start-localnet-skip-build: @echo "--> Starting localnet" export LOCALNET_MODE=setup-only && \ - cd contrib/localnet/ && $(DOCKER_COMPOSE) -f docker-compose.yml up -d + cd contrib/localnet/ && $(DOCKER_COMPOSE) up -d # stop-localnet should include all profiles so other containers are also removed stop-localnet: - cd contrib/localnet/ && $(DOCKER_COMPOSE) --profile all -f docker-compose.yml down --remove-orphans + cd contrib/localnet/ && $(DOCKER_COMPOSE) --profile all down --remove-orphans ############################################################################### ### E2E tests ### @@ -253,22 +253,22 @@ start-e2e-test: zetanode start-e2e-admin-test: zetanode @echo "--> Starting e2e admin test" export E2E_ARGS="--skip-regular --test-admin" && \ - cd contrib/localnet/ && $(DOCKER_COMPOSE) --profile eth2 -f docker-compose.yml up -d + cd contrib/localnet/ && $(DOCKER_COMPOSE) --profile eth2 up -d start-e2e-performance-test: zetanode @echo "--> Starting e2e performance test" export E2E_ARGS="--test-performance" && \ - cd contrib/localnet/ && $(DOCKER_COMPOSE) --profile stress -f docker-compose.yml up -d + cd contrib/localnet/ && $(DOCKER_COMPOSE) --profile stress up -d start-e2e-import-mainnet-test: zetanode @echo "--> Starting e2e import-data test" export ZETACORED_IMPORT_GENESIS_DATA=true && \ export ZETACORED_START_PERIOD=15m && \ - cd contrib/localnet/ && ./scripts/import-data.sh mainnet && $(DOCKER_COMPOSE) -f docker-compose.yml up -d + cd contrib/localnet/ && ./scripts/import-data.sh mainnet && $(DOCKER_COMPOSE) up -d start-stress-test: zetanode @echo "--> Starting stress test" - cd contrib/localnet/ && $(DOCKER_COMPOSE) --profile stress -f docker-compose.yml up -d + cd contrib/localnet/ && $(DOCKER_COMPOSE) --profile stress up -d start-tss-migration-test: zetanode @echo "--> Starting tss migration test" @@ -279,17 +279,17 @@ start-tss-migration-test: zetanode start-solana-test: zetanode solana @echo "--> Starting solana test" export E2E_ARGS="--skip-regular --test-solana" && \ - cd contrib/localnet/ && $(DOCKER_COMPOSE) --profile solana -f docker-compose.yml up -d + cd contrib/localnet/ && $(DOCKER_COMPOSE) --profile solana up -d start-ton-test: zetanode @echo "--> Starting TON test" export E2E_ARGS="--skip-regular --test-ton" && \ - cd contrib/localnet/ && $(DOCKER_COMPOSE) --profile ton -f docker-compose.yml up -d + cd contrib/localnet/ && $(DOCKER_COMPOSE) --profile ton up -d start-v2-test: zetanode @echo "--> Starting e2e smart contracts v2 test" export E2E_ARGS="--skip-regular --test-v2" && \ - cd contrib/localnet/ && $(DOCKER_COMPOSE) -f docker-compose.yml up -d + cd contrib/localnet/ && $(DOCKER_COMPOSE) up -d ############################################################################### ### Upgrade Tests ### @@ -321,20 +321,20 @@ start-upgrade-test: zetanode-upgrade @echo "--> Starting upgrade test" export LOCALNET_MODE=upgrade && \ export UPGRADE_HEIGHT=225 && \ - cd contrib/localnet/ && $(DOCKER_COMPOSE) --profile upgrade -f docker-compose.yml -f docker-compose-upgrade.yml up -d + cd contrib/localnet/ && $(DOCKER_COMPOSE) --profile upgrade -f docker-compose-upgrade.yml up -d start-upgrade-test-light: zetanode-upgrade @echo "--> Starting light upgrade test (no ZetaChain state populating before upgrade)" export LOCALNET_MODE=upgrade && \ export UPGRADE_HEIGHT=90 && \ - cd contrib/localnet/ && $(DOCKER_COMPOSE) --profile upgrade -f docker-compose.yml -f docker-compose-upgrade.yml up -d + cd contrib/localnet/ && $(DOCKER_COMPOSE) --profile upgrade -f docker-compose-upgrade.yml up -d start-upgrade-test-admin: zetanode-upgrade @echo "--> Starting admin upgrade test" export LOCALNET_MODE=upgrade && \ export UPGRADE_HEIGHT=90 && \ export E2E_ARGS="--skip-regular --test-admin" && \ - cd contrib/localnet/ && $(DOCKER_COMPOSE) --profile upgrade -f docker-compose.yml -f docker-compose-upgrade.yml up -d + cd contrib/localnet/ && $(DOCKER_COMPOSE) --profile upgrade -f docker-compose-upgrade.yml up -d # this test upgrades from v18 and execute the v2 contracts migration process # this tests is part of upgrade test part because it should run the upgrade from v18 to fully replicate the upgrade process @@ -343,7 +343,7 @@ start-upgrade-v2-migration-test: zetanode-upgrade export LOCALNET_MODE=upgrade && \ export UPGRADE_HEIGHT=90 && \ export E2E_ARGS="--test-v2-migration" && \ - cd contrib/localnet/ && $(DOCKER_COMPOSE) --profile upgrade -f docker-compose.yml -f docker-compose-upgrade.yml up -d + cd contrib/localnet/ && $(DOCKER_COMPOSE) --profile upgrade -f docker-compose-upgrade.yml up -d start-upgrade-import-mainnet-test: zetanode-upgrade @@ -352,7 +352,7 @@ start-upgrade-import-mainnet-test: zetanode-upgrade export ZETACORED_IMPORT_GENESIS_DATA=true && \ export ZETACORED_START_PERIOD=15m && \ export UPGRADE_HEIGHT=225 && \ - cd contrib/localnet/ && ./scripts/import-data.sh mainnet && $(DOCKER_COMPOSE) --profile upgrade -f docker-compose.yml -f docker-compose-upgrade.yml up -d + cd contrib/localnet/ && ./scripts/import-data.sh mainnet && $(DOCKER_COMPOSE) --profile upgrade -f docker-compose-upgrade.yml up -d ############################################################################### diff --git a/docs/development/LOCAL_TESTING.md b/docs/development/LOCAL_TESTING.md index 010cf2d8ff..6c5a94b8ad 100644 --- a/docs/development/LOCAL_TESTING.md +++ b/docs/development/LOCAL_TESTING.md @@ -41,7 +41,7 @@ This uses `docker compose` to start the localnet and run standard e2e tests insi More options directly to `docker compose` via the `NODE_COMPOSE_ARGS` variable. This allows setting additional profiles or configuring an overlay. Example: ``` -example: NODE_COMPOSE_ARGS="--profile monitoring -f docker-compose-persistent.yml"` +export NODE_COMPOSE_ARGS="--profile monitoring -f docker-compose-persistent.yml" make start-e2e-test ``` From 57b5d4e07811dbf44b8cb66607673097fe64b25f Mon Sep 17 00:00:00 2001 From: Julian Rubino Date: Thu, 24 Oct 2024 12:25:26 -0300 Subject: [PATCH 2/2] Rename sim tests file, add result aggregation and merge jobs --- .github/workflows/sim.yaml | 90 ++++++++++++++++++++++++++ .github/workflows/simulation-test.yaml | 76 ---------------------- 2 files changed, 90 insertions(+), 76 deletions(-) create mode 100644 .github/workflows/sim.yaml delete mode 100644 .github/workflows/simulation-test.yaml diff --git a/.github/workflows/sim.yaml b/.github/workflows/sim.yaml new file mode 100644 index 0000000000..c9b88fdeec --- /dev/null +++ b/.github/workflows/sim.yaml @@ -0,0 +1,90 @@ +name: Simulation Tests Workflow + +on: + push: + branches: + - main + - develop + pull_request: + schedule: + - cron: "0 6 * * *" + workflow_dispatch: + inputs: + make-targets: + description: 'Comma separated list of make targets to run (e.g., test-sim-nondeterminism, test-sim-fullappsimulation)' + required: true + default: '' + +concurrency: + group: simulation-${{ github.head_ref || github.sha }} + cancel-in-progress: true + +jobs: + matrix-conditionals: + runs-on: ubuntu-22.04 + outputs: + SIM_TEST_NOND: ${{ steps.matrix-conditionals.outputs.SIM_TEST_NOND }} + SIM_TEST_FULL: ${{ steps.matrix-conditionals.outputs.SIM_TEST_FULL }} + SIM_TEST_IMPORT_EXPORT: ${{ steps.matrix-conditionals.outputs.SIM_TEST_IMPORT_EXPORT }} + SIM_TEST_AFTER_IMPORT: ${{ steps.matrix-conditionals.outputs.SIM_TEST_AFTER_IMPORT }} + steps: + - id: matrix-conditionals + uses: actions/github-script@v7 + with: + script: | + const makeTargets = context.payload.inputs['make-targets'].split(','); + core.setOutput('SIM_TEST_NOND', makeTargets.includes('test-sim-nondeterminism')); + core.setOutput('SIM_TEST_FULL', makeTargets.includes('test-sim-fullappsimulation')); + core.setOutput('SIM_TEST_IMPORT_EXPORT', makeTargets.includes('test-sim-import-export')); + core.setOutput('SIM_TEST_AFTER_IMPORT', makeTargets.includes('test-sim-after-import')); + + simulation-tests: + needs: matrix-conditionals + strategy: + fail-fast: false + matrix: + include: + - make-target: "test-sim-nondeterminism" + runs-on: ubuntu-22.04 + run: ${{ needs.matrix-conditionals.outputs.SIM_TEST_NOND == 'true' }} + - make-target: "test-sim-fullappsimulation" + runs-on: ubuntu-22.04 + run: ${{ needs.matrix-conditionals.outputs.SIM_TEST_FULL == 'true' }} + - make-target: "test-sim-import-export" + runs-on: ubuntu-22.04 + run: ${{ needs.matrix-conditionals.outputs.SIM_TEST_IMPORT_EXPORT == 'true' }} + - make-target: "test-sim-after-import" + runs-on: ubuntu-22.04 + run: ${{ needs.matrix-conditionals.outputs.SIM_TEST_AFTER_IMPORT == 'true' }} + name: ${{ matrix.make-target }} + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Set up Go + uses: actions/setup-go@v4 + with: + go-version: '1.20' + + - name: Install dependencies + run: make runsim + + - name: Run ${{ matrix.make-target }} + run: | + make ${{ matrix.make-target }} + + sim-ok: + runs-on: ubuntu-22.04 + needs: + - matrix-conditionals + - simulation-tests + if: always() + steps: + - name: Aggregate Results + run: | + result="${{ needs.simulation-tests.result }}" + if [[ $result == "success" || $result == "skipped" ]]; then + exit 0 + else + exit 1 + fi diff --git a/.github/workflows/simulation-test.yaml b/.github/workflows/simulation-test.yaml deleted file mode 100644 index 901a63039e..0000000000 --- a/.github/workflows/simulation-test.yaml +++ /dev/null @@ -1,76 +0,0 @@ -name: Simulation Tests Workflow - -on: - # The workflow runs when code is pushed to either the main or develop branches - push: - branches: - - main - - develop - # The workflow runs when a pull request is opened or updated - pull_request: - # Run daily at 6AM UTC Daily - schedule: - - cron: "0 6 * * *" - # It can be run manually targetting a specific test - workflow_dispatch: - inputs: - test-target: - description: 'Makefile test target to run (e.g., test-sim-nondeterminism)' - required: true - default: 'test-sim-fullappsimulation' - -concurrency: - # Ensures that only one run of this workflow is active per branch or commit - group: runsim-${{ github.head_ref || github.sha }} - # If a new run is triggered for the same branch/commit while an old one is still in progress, the previous run will be canceled - cancel-in-progress: true - -jobs: - # This job is responsible for setting up the environment and installing the necessary dependencies, including runsim - install-dependencies: - runs-on: ubuntu-22.04 - steps: - - name: Checkout code - uses: actions/checkout@v3 - - - name: Set up Go - uses: actions/setup-go@v4 - with: - go-version: '1.20' - - - name: Install runsim and dependencies - run: | - make runsim - - run-simulation-tests: - needs: install-dependencies - runs-on: ubuntu-22.04 - strategy: - matrix: - # The matrix strategy allows running multiple simulation tests in parallel. In this case, it runs the following targets from the Makefile - test-target: - - "test-sim-nondeterminism" - - "test-sim-fullappsimulation" - - "test-sim-import-export" - - "test-sim-after-import" - steps: - - name: Checkout code - uses: actions/checkout@v3 - - # It runs the specified test from the Makefile by calling make ${{ matrix.test-target }}, where test-target is one of the matrix values - - name: Run Simulation Test - ${{ matrix.test-target }} - run: | - make ${{ matrix.test-target }} - - manual-run: - runs-on: ubuntu-22.04 - if: github.event_name == 'workflow_dispatch' - steps: - - name: Checkout code - uses: actions/checkout@v3 - # This job only runs if the workflow was triggered by a manual dispatch (workflow_dispatch) - - name: Run Simulation Test - ${{ github.event.inputs.test-target }} - env: - TEST_TARGET: ${{ github.event.inputs.test-target }} - run: | - make "$TEST_TARGET"