From 135b7183626e4ac675fe368cf11496050b9e7821 Mon Sep 17 00:00:00 2001 From: Javier Viola <363911+pepoviola@users.noreply.github.com> Date: Fri, 7 Feb 2025 13:48:31 -0300 Subject: [PATCH] Zombienet gha substrate migration (#7217) Migrate subtrate's zombienet test from gitlab to gha. --------- Co-authored-by: alvicsam <alvicsam@gmail.com> --- .github/actions/build-push-image/action.yml | 12 +- .github/workflows/build-publish-images.yml | 2 - .../zombienet-reusable-preflight.yml | 123 ++++++++++++++++-- .github/workflows/zombienet_substrate.yml | 117 +++++++++++++++-- .github/zombienet-env | 19 +-- 5 files changed, 229 insertions(+), 44 deletions(-) diff --git a/.github/actions/build-push-image/action.yml b/.github/actions/build-push-image/action.yml index fead9cfe336..801fdeba42a 100644 --- a/.github/actions/build-push-image/action.yml +++ b/.github/actions/build-push-image/action.yml @@ -1,4 +1,4 @@ -name: 'build and push image' +name: "build and push image" inputs: dockerfile: description: "dockerfile to build" @@ -8,14 +8,12 @@ inputs: required: true outputs: branch: - description: 'Branch name for the PR' + description: "Branch name for the PR" value: ${{ steps.branch.outputs.branch }} - runs: using: "composite" steps: - # gcloud # https://github.com/paritytech/ci_cd/wiki/GitHub:-Push-Docker-image-to-GCP-Registry - name: "Set up Cloud SDK" @@ -25,15 +23,14 @@ runs: run: "gcloud info" - name: "Auth in gcloud registry" shell: bash - run: "gcloud auth configure-docker europe-docker.pkg.dev --quiet" + run: "gcloud auth configure-docker europe-docker.pkg.dev --quiet" - name: build shell: bash env: ZOMBIENET_IMAGE: "docker.io/paritytech/zombienet:v1.3.105" run: | - export BRANCH_NAME=${{ github.head_ref || github.ref_name }} - export DOCKER_IMAGES_VERSION=${BRANCH_NAME/\//-} + export DOCKER_IMAGES_VERSION=${{ github.event.pull_request.head.sha }} if [[ ${{ github.event_name }} == "merge_group" ]]; then export DOCKER_IMAGES_VERSION="${GITHUB_SHA::8}"; fi docker build \ --build-arg VCS_REF="${GITHUB_SHA}" \ @@ -44,4 +41,3 @@ runs: -f ${{ inputs.dockerfile }} \ . docker push "${{ inputs.image-name }}:$DOCKER_IMAGES_VERSION" - diff --git a/.github/workflows/build-publish-images.yml b/.github/workflows/build-publish-images.yml index deb3b3df5ff..5ee02151f8d 100644 --- a/.github/workflows/build-publish-images.yml +++ b/.github/workflows/build-publish-images.yml @@ -19,8 +19,6 @@ jobs: # # preflight: - ## TODO: remove when ready - if: contains(github.event.label.name, 'GHA-migration') || contains(github.event.pull_request.labels.*.name, 'GHA-migration') uses: ./.github/workflows/reusable-preflight.yml ### Build ######################## diff --git a/.github/workflows/zombienet-reusable-preflight.yml b/.github/workflows/zombienet-reusable-preflight.yml index 8e938567d81..f5ac43741ad 100644 --- a/.github/workflows/zombienet-reusable-preflight.yml +++ b/.github/workflows/zombienet-reusable-preflight.yml @@ -20,6 +20,28 @@ on: outputs: changes_substrate: value: ${{ jobs.preflight.outputs.changes_substrate }} + description: | + True iff there are changes in substrate directory or the current workflow + + changes_cumulus: + value: ${{ jobs.preflight.outputs.changes_cumulus }} + description: | + True iff there are changes in cumulus directory or the current workflow + + changes_polkadot: + value: ${{ jobs.preflight.outputs.changes_polkadot }} + description: | + True iff there are changes in polkadot directory or the current workflow + + changes_bridges: + value: ${{ jobs.preflight.outputs.changes_bridges }} + description: | + True iff there are changes in bridges directory or the current workflow + + changes_templates: + value: ${{ jobs.preflight.outputs.changes_templates }} + description: | + True iff there are changes in templates directory or the current workflow ZOMBIENET_IMAGE: value: ${{ jobs.preflight.outputs.ZOMBIENET_IMAGE }} @@ -30,14 +52,18 @@ on: description: | Main runner for zombienet tests. + TEMP_IMAGES_BASE: + value: ${{ jobs.preflight.outputs.TEMP_IMAGES_BASE }} + description: | + Base location for 'temp' images used in tests. + DOCKER_IMAGES_VERSION: value: ${{ jobs.preflight.outputs.DOCKER_IMAGES_VERSION }} description: | Version for temp docker images. - # Global vars (from global preflight) SOURCE_REF_SLUG: - value: ${{ jobs.global_preflight.outputs.SOURCE_REF_SLUG }} + value: ${{ jobs.preflight.outputs.SOURCE_REF_SLUG }} # Zombie vars PUSHGATEWAY_URL: @@ -65,9 +91,6 @@ on: description: "Base memory (request) for pod runner." jobs: - global_preflight: - uses: ./.github/workflows/reusable-preflight.yml - # # # @@ -75,14 +98,22 @@ jobs: runs-on: ubuntu-latest outputs: changes_substrate: ${{ steps.set_changes.outputs.substrate_any_changed || steps.set_changes.outputs.currentWorkflow_any_changed }} + changes_cumulus: ${{ steps.set_changes.outputs.cumulus_any_changed || steps.set_changes.outputs.currentWorkflow_any_changed }} + changes_polkadot: ${{ steps.set_changes.outputs.polkadot_any_changed || steps.set_changes.outputs.currentWorkflow_any_changed }} + changes_bridges: ${{ steps.set_changes.outputs.bridges_any_changed || steps.set_changes.outputs.currentWorkflow_any_changed }} + changes_templates: ${{ steps.set_changes.outputs.templates_any_changed || steps.set_changes.outputs.currentWorkflow_any_changed }} ZOMBIENET_IMAGE: ${{ steps.set_vars.outputs.ZOMBIENET_IMAGE }} ZOMBIENET_RUNNER: ${{ steps.set_vars.outputs.ZOMBIENET_RUNNER }} - DOCKER_IMAGES_VERSION: ${{ steps.set_images_version.outputs.ZOMBIENET_RUNNER }} + TEMP_IMAGES_BASE: ${{ steps.set_vars.outputs.TEMP_IMAGES_BASE }} + + # images versions + DOCKER_IMAGES_VERSION: ${{ steps.set_images_version.outputs.DOCKER_IMAGES_VERSION }} # common vars PUSHGATEWAY_URL: ${{ steps.set_vars.outputs.PUSHGATEWAY_URL }} + SOURCE_REF_SLUG: ${{ steps.set_vars.outputs.SOURCE_REF_SLUG }} DEBUG: ${{ steps.set_vars.outputs.DEBUG }} ZOMBIE_PROVIDER: ${{ steps.set_vars.outputs.ZOMBIE_PROVIDER }} RUST_LOG: ${{ steps.set_vars.outputs.RUST_LOG }} @@ -91,7 +122,6 @@ jobs: KUBERNETES_MEMORY_REQUEST: ${{ steps.set_vars.outputs.KUBERNETES_MEMORY_REQUEST }} steps: - - uses: actions/checkout@v4 # @@ -111,20 +141,31 @@ jobs: files_yaml: | substrate: - 'substrate/**/*' + cumulus: + - 'cumulus/**/*' + polkadot: + - 'polkadot/**/*' + bridges: + - 'bridges/**/*' + templates: + - 'templates/**/*' currentWorkflow: - '${{ steps.current_file.outputs.currentWorkflowFile }}' - '.github/workflows/zombienet-reusable-preflight.yml' - '.github/zombienet-env' - # # Set environment vars (including runner/image) # - name: Set vars id: set_vars shell: bash - run: cat .github/env >> $GITHUB_OUTPUT - + run: | + export SOURCE_REF_NAME=${{ github.head_ref || github.ref_name }} + echo "SOURCE_REF_SLUG=${SOURCE_REF_NAME//\//_}" >> $GITHUB_OUTPUT + # + cat .github/zombienet-env >> $GITHUB_OUTPUT + cat .github/zombienet-env # # @@ -133,8 +174,7 @@ jobs: id: set_images_version shell: bash run: | - export BRANCH_NAME=${{ github.head_ref || github.ref_name }} - export DOCKER_IMAGES_VERSION=${BRANCH_NAME/\//-} + export DOCKER_IMAGES_VERSION=${{ github.event.pull_request.head.sha }} if [[ ${{ github.event_name }} == "merge_group" ]]; then export DOCKER_IMAGES_VERSION="${GITHUB_SHA::8}"; fi echo "DOCKER_IMAGES_VERSION=${DOCKER_IMAGES_VERSION}" >> $GITHUB_OUTPUT @@ -142,4 +182,61 @@ jobs: shell: bash run: | echo "workflow file: ${{ steps.current_file.outputs.currentWorkflowFile }}" - echo "Modified: ${{ steps.set_changes.outputs.modified_keys }}" \ No newline at end of file + echo "Modified: ${{ steps.set_changes.outputs.modified_keys }}" + echo "ZOMBIENET_IMAGE: ${{ steps.set_vars.outputs.ZOMBIENET_IMAGE }}" + + # + # + # + ci-env: + needs: [preflight] + runs-on: ubuntu-latest + steps: + - name: Info vars + run: | + echo "ZOMBIENET_IMAGE: ${{ needs.preflight.outputs.ZOMBIENET_IMAGE }}" + echo "ZOMBIENET_RUNNER: ${{ needs.preflight.outputs.ZOMBIENET_RUNNER }}" + echo "DOCKER_IMAGES_VERSION: ${{ needs.preflight.outputs.DOCKER_IMAGES_VERSION }}" + echo "SOURCE_REF_SLUG: ${{ needs.preflight.outputs.SOURCE_REF_SLUG }}" + echo "PUSHGATEWAY_URL: ${{ needs.preflight.outputs.PUSHGATEWAY_URL }}" + echo "DEBUG: ${{ needs.preflight.outputs.DEBUG }}" + echo "ZOMBIE_PROVIDER: ${{ needs.preflight.outputs.ZOMBIE_PROVIDER }}" + echo "RUST_LOG: ${{ needs.preflight.outputs.RUST_LOG }}" + echo "RUN_IN_CI: ${{ needs.preflight.outputs.RUN_IN_CI }}" + echo "KUBERNETES_CPU_REQUEST: ${{ needs.preflight.outputs.KUBERNETES_CPU_REQUEST }}" + echo "KUBERNETES_MEMORY_REQUEST: ${{ needs.preflight.outputs.KUBERNETES_MEMORY_REQUEST }}" + # + echo "github.ref: ${{ github.ref }}" + echo "github.ref_name: ${{ github.ref_name }}" + echo "github.sha: ${{ github.sha }}" + # + # + # Wait until the 'build and push' image workflow success + wait_build_images: + needs: [ci-env] + runs-on: ubuntu-latest + timeout-minutes: 30 + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Wait until "Build and push images" workflow is done + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + gh --version + export SHA=${{ github.event.pull_request.head.sha }} + if [[ ${{ github.event_name }} == "merge_group" ]]; then export SHA="${GITHUB_SHA::8}"; fi + while true; do + STATUS=$(gh run ls -c $SHA -w "Build and push images" --json name,status --jq '.[] | select(.name == "Build and push images") | .status') + echo "CI workflow status: $STATUS" + if [[ $STATUS == "completed" ]]; then + echo "CI workflow is done." + break + fi + if [[ -z "$STATUS" ]]; then + echo "::warning::No CI workflow runs found for this commit" + exit 1 + fi + sleep 10 + done + echo "CI workflow is done." diff --git a/.github/workflows/zombienet_substrate.yml b/.github/workflows/zombienet_substrate.yml index 823679d67d5..358438caa8a 100644 --- a/.github/workflows/zombienet_substrate.yml +++ b/.github/workflows/zombienet_substrate.yml @@ -1,15 +1,28 @@ name: Zombienet Substrate on: - workflow_run: - workflows: [Build and push images] - types: [completed] + push: + branches: + - master + pull_request: + types: [opened, synchronize, reopened, ready_for_review] merge_group: - workflow_dispatch: concurrency: group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} cancel-in-progress: true +env: + RUN_IN_CONTAINER: 1 + FF_DISABLE_UMASK_FOR_DOCKER_EXECUTOR: 1 + LOCAL_DIR: "./substrate/zombienet" + GHA_CLUSTER_SERVER_ADDR: "https://kubernetes.default:443" + + # DB generated from commit: https://github.com/paritytech/polkadot-sdk/commit/868788a5bff3ef94869bd36432726703fe3b4e96 + # TODO: As a workaround for https://github.com/paritytech/polkadot-sdk/issues/2568 the DB was generated in archive mode. + # After the issue is fixed, we should replace it with a pruned version of the DB. + DB_SNAPSHOT: "https://storage.googleapis.com/zombienet-db-snaps/substrate/0001-basic-warp-sync/chains-9677807d738b951e9f6c82e5fd15518eb0ae0419.tgz" + DB_BLOCK_HEIGHT: 56687 + jobs: preflight: uses: ./.github/workflows/zombienet-reusable-preflight.yml @@ -17,29 +30,109 @@ jobs: zombienet-substrate-0000-block-building: needs: [preflight] # only run if we have changes in ./substrate directory and the build workflow already finish with success status. - if: ${{ needs.preflight.outputs.changes_substrate && github.event.workflow_run.conclusion == 'success' }} - runs-on: ${{ needs.preflight.outputs.ZOMBIENET_RUNNER }} + if: ${{ needs.preflight.outputs.changes_substrate || github.event_name == 'workflow_dispatch' }} + runs-on: ${{ needs.preflight.outputs.ZOMBIENET_RUNNER }} # NOTE: should be zombienet-arc-runner (without quotes) timeout-minutes: 60 container: image: ${{ needs.preflight.outputs.ZOMBIENET_IMAGE }} env: - FF_DISABLE_UMASK_FOR_DOCKER_EXECUTOR: 1 - LOCAL_DIR: "./substrate/zombienet" + ZOMBIENET_INTEGRATION_TEST_IMAGE: "${{ needs.preflight.outputs.TEMP_IMAGES_BASE }}/substrate:${{ needs.preflight.outputs.DOCKER_IMAGES_VERSION }}" steps: - name: Checkout uses: actions/checkout@v4 - - uses: actions/download-artifact@v4.1.8 + - name: script + run: | + echo "Img: $ZOMBIENET_INTEGRATION_TEST_IMAGE" + export DEBUG=${{ needs.preflight.outputs.DEBUG }} + /home/nonroot/zombie-net/scripts/ci/run-test-local-env-manager.sh --local-dir="$(pwd)/$LOCAL_DIR/0000-block-building" --test="block-building.zndsl" + + - name: upload logs + uses: actions/upload-artifact@v4 with: - name: build-linux-substrate-${{ needs.preflight.outputs.SOURCE_REF_NAME }} + name: zombienet-logs-${{ github.job }}-${{ github.sha }} + path: | + /tmp/zombie*/logs/* + + zombienet-substrate-0001-basic-warp-sync: + needs: [preflight] + # only run if we have changes in ./substrate directory and the build workflow already finish with success status. + if: ${{ needs.preflight.outputs.changes_substrate || github.event_name == 'workflow_dispatch' }} + runs-on: ${{ needs.preflight.outputs.ZOMBIENET_RUNNER }} # NOTE: should be zombienet-arc-runner (without quotes) + timeout-minutes: 60 + container: + image: ${{ needs.preflight.outputs.ZOMBIENET_IMAGE }} + env: + ZOMBIENET_INTEGRATION_TEST_IMAGE: "${{ needs.preflight.outputs.TEMP_IMAGES_BASE }}/substrate:${{ needs.preflight.outputs.DOCKER_IMAGES_VERSION }}" + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: script + run: | + echo "Img: $ZOMBIENET_INTEGRATION_TEST_IMAGE" + export DEBUG=${{ needs.preflight.outputs.DEBUG }} + /home/nonroot/zombie-net/scripts/ci/run-test-local-env-manager.sh --local-dir="$(pwd)/$LOCAL_DIR/0001-basic-warp-sync" --test="test-warp-sync.zndsl" + + - name: upload logs + uses: actions/upload-artifact@v4 + with: + name: zombienet-logs-${{ github.job }}-${{ github.sha }} + path: | + /tmp/zombie*/logs/* + + zombienet-substrate-0002-validators-warp-sync: + needs: [preflight] + # only run if we have changes in ./substrate directory and the build workflow already finish with success status. + if: ${{ needs.preflight.outputs.changes_substrate || github.event_name == 'workflow_dispatch' }} + runs-on: ${{ needs.preflight.outputs.ZOMBIENET_RUNNER }} # NOTE: should be zombienet-arc-runner (without quotes) + timeout-minutes: 60 + container: + image: ${{ needs.preflight.outputs.ZOMBIENET_IMAGE }} + env: + ZOMBIENET_INTEGRATION_TEST_IMAGE: "${{ needs.preflight.outputs.TEMP_IMAGES_BASE }}/substrate:${{ needs.preflight.outputs.DOCKER_IMAGES_VERSION }}" + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: script + run: | + echo "Img: $ZOMBIENET_INTEGRATION_TEST_IMAGE" + cp --remove-destination ${LOCAL_DIR}/0001-basic-warp-sync/chain-spec.json ${LOCAL_DIR}/0002-validators-warp-sync + export DEBUG=${{ needs.preflight.outputs.DEBUG }} + /home/nonroot/zombie-net/scripts/ci/run-test-local-env-manager.sh --local-dir="$(pwd)/$LOCAL_DIR/0002-validators-warp-sync" --test="test-validators-warp-sync.zndsl" + + - name: upload logs + uses: actions/upload-artifact@v4 + with: + name: zombienet-logs-${{ github.job }}-${{ github.sha }} + path: | + /tmp/zombie*/logs/* + + zombienet-substrate-0003-block-building-warp-sync: + needs: [preflight] + # only run if we have changes in ./substrate directory and the build workflow already finish with success status. + if: ${{ needs.preflight.outputs.changes_substrate || github.event_name == 'workflow_dispatch' }} + runs-on: ${{ needs.preflight.outputs.ZOMBIENET_RUNNER }} # NOTE: should be zombienet-arc-runner (without quotes) + timeout-minutes: 60 + container: + image: ${{ needs.preflight.outputs.ZOMBIENET_IMAGE }} + env: + ZOMBIENET_INTEGRATION_TEST_IMAGE: "${{ needs.preflight.outputs.TEMP_IMAGES_BASE }}/substrate:${{ needs.preflight.outputs.DOCKER_IMAGES_VERSION }}" + steps: + - name: Checkout + uses: actions/checkout@v4 - name: script run: | - DEBUG=${{ needs.preflight.outputs.DEBUG }} zombie -p native ${LOCAL_DIR}/0000-block-building/block-building.zndsl + echo "Img: $ZOMBIENET_INTEGRATION_TEST_IMAGE" + cp --remove-destination ${LOCAL_DIR}/0001-basic-warp-sync/chain-spec.json ${LOCAL_DIR}/0003-block-building-warp-sync + export DEBUG=${{ needs.preflight.outputs.DEBUG }} + /home/nonroot/zombie-net/scripts/ci/run-test-local-env-manager.sh --local-dir="$(pwd)/$LOCAL_DIR/0003-block-building-warp-sync" --test="test-block-building-warp-sync.zndsl" - name: upload logs uses: actions/upload-artifact@v4 with: - name: zombienet-logs-scale-net + name: zombienet-logs-${{ github.job }}-${{ github.sha }} path: | /tmp/zombie*/logs/* diff --git a/.github/zombienet-env b/.github/zombienet-env index e6da1a49c4b..565a91a8d71 100644 --- a/.github/zombienet-env +++ b/.github/zombienet-env @@ -1,9 +1,10 @@ - ZOMBIENET_IMAGE="docker.io/paritytech/zombienet:v1.3.116" - ZOMBIE_RUNNER="zombienet-arc-runner" - PUSHGATEWAY_URL="http://zombienet-prometheus-pushgateway.managed-monitoring:9091/metrics/job/zombie-metrics" - DEBUG="zombie,zombie::network-node,zombie::kube::client::logs" - ZOMBIE_PROVIDER="k8s" - RUST_LOG="info,zombienet_orchestrator=debug" - RUN_IN_CI="1" - KUBERNETES_CPU_REQUEST="512m" - KUBERNETES_MEMORY_REQUEST="1Gi" +ZOMBIENET_IMAGE=docker.io/paritytech/zombienet:v1.3.119 +ZOMBIENET_RUNNER=zombienet-arc-runner +PUSHGATEWAY_URL=http://zombienet-prometheus-pushgateway.managed-monitoring:9091/metrics/job/zombie-metrics +DEBUG=zombie,zombie::network-node,zombie::kube::client::logs +ZOMBIE_PROVIDER=k8s +RUST_LOG=info,zombienet_orchestrator=debug +RUN_IN_CI=1 +KUBERNETES_CPU_REQUEST=512m +KUBERNETES_MEMORY_REQUEST=1Gi +TEMP_IMAGES_BASE=europe-docker.pkg.dev/parity-ci-2024/temp-images -- GitLab