From 175b0f9a03b54ee33a24ef890305c16706cc7b70 Mon Sep 17 00:00:00 2001 From: Branislav Kojic Date: Wed, 14 Feb 2024 07:44:37 +0100 Subject: [PATCH 1/2] Establish releases (#109) * Establish releases * Change the `DockerHub organization` to a variable --- .github/workflows/release.yml | 21 +++++++++------------ .goreleaser.yml | 26 +++++++++++++------------- Dockerfile.release | 6 +++--- 3 files changed, 25 insertions(+), 28 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index ab3b3be8d6..a4cc388ac4 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -19,27 +19,24 @@ jobs: uses: actions/checkout@v4.1.1 with: fetch-depth: 0 - - name: Set up Go uses: actions/setup-go@v5.0.0 with: go-version: 1.20.x - - name: Prepare id: prepare run: | TAG=${GITHUB_REF#refs/tags/} echo tag_name=${TAG} >> $GITHUB_OUTPUT - + - name: Set Dockerhub organization + run: sed 's/DOCKERHUB_ORGANIZATION/${{ vars.DOCKERHUB_ORGANIZATION }}/g' .goreleaser.yml > .goreleaser.yml.tmp && mv .goreleaser.yml.tmp .goreleaser.yml - name: Set up QEMU - uses: docker/setup-qemu-action@v2 - + uses: docker/setup-qemu-action@v3.0.0 - name: Login to Docker Hub - uses: docker/login-action@v2 + uses: docker/login-action@v3.0.0 with: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_TOKEN }} - - name: Run GoReleaser run: | docker run \ @@ -50,13 +47,13 @@ jobs: -e SLACK_WEBHOOK \ -e DOCKER_CONFIG \ -v /var/run/docker.sock:/var/run/docker.sock \ - -v `pwd`:/go/src/$(PACKAGE_NAME) \ - -w /go/src/$(PACKAGE_NAME) \ + -v `pwd`:/go/src/${PACKAGE_NAME} \ + -w /go/src/${PACKAGE_NAME} \ ghcr.io/goreleaser/goreleaser-cross:${GOLANG_CROSS_VERSION} \ - --rm-dist --skip-validate + --clean --skip-validate env: - PACKAGE_NAME: github.com/Ethernal-Tech/blade + PACKAGE_NAME: github.com/${GITHUB_REPOSITORY} GOLANG_CROSS_VERSION: v1.20.5 GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} VERSION: ${{ steps.prepare.outputs.tag_name }} - SLACK_WEBHOOK: ${{ secrets.SLACK_BLADE_GITHUB_URL }} + SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL }} diff --git a/.goreleaser.yml b/.goreleaser.yml index f51a3094ff..80af36859d 100644 --- a/.goreleaser.yml +++ b/.goreleaser.yml @@ -1,4 +1,4 @@ -project_name: polygon-edge +project_name: blade release: disable: false @@ -17,7 +17,7 @@ builds: - CC=o64-clang - CXX=o64-clang++ ldflags: - -s -w -X 'github.com/0xPolygon/polygon-edge/versioning.Version=v{{ .Version }}' + -s -w -X 'github.com/${GITHUB_REPOSITORY}/versioning.Version=v{{ .Version }}' - id: darwin-arm64 main: ./main.go @@ -30,7 +30,7 @@ builds: - CC=oa64-clang - CXX=oa64-clang++ ldflags: - -s -w -X 'github.com/0xPolygon/polygon-edge/versioning.Version=v{{ .Version }}' + -s -w -X 'github.com/${GITHUB_REPOSITORY}/versioning.Version=v{{ .Version }}' - id: linux-amd64 main: ./main.go @@ -44,7 +44,7 @@ builds: - CXX=g++ ldflags: # We need to build a static binary because we are building in a glibc based system and running in a musl container - -s -w -linkmode external -extldflags "-static" -X 'github.com/0xPolygon/polygon-edge/versioning.Version=v{{ .Version }}' + -s -w -linkmode external -extldflags "-static" -X 'github.com/${GITHUB_REPOSITORY}/versioning.Version=v{{ .Version }}' tags: - netgo - osusergo @@ -61,7 +61,7 @@ builds: - CXX=aarch64-linux-gnu-g++ ldflags: # We need to build a static binary because we are building in a glibc based system and running in a musl container - -s -w -linkmode external -extldflags "-static" -X 'github.com/0xPolygon/polygon-edge/versioning.Version=v{{ .Version }}' + -s -w -linkmode external -extldflags "-static" -X 'github.com/${GITHUB_REPOSITORY}/versioning.Version=v{{ .Version }}' tags: - netgo - osusergo @@ -77,7 +77,7 @@ snapshot: dockers: - image_templates: - - 0xpolygon/{{ .ProjectName }}:{{ .Version }}-amd64 + - DOCKERHUB_ORGANIZATION/{{ .ProjectName }}:{{ .Version }}-amd64 dockerfile: Dockerfile.release use: buildx goarch: amd64 @@ -88,7 +88,7 @@ dockers: skip_push: false - image_templates: - - 0xpolygon/{{ .ProjectName }}:{{ .Version }}-arm64 + - DOCKERHUB_ORGANIZATION/{{ .ProjectName }}:{{ .Version }}-arm64 dockerfile: Dockerfile.release use: buildx goarch: arm64 @@ -99,14 +99,14 @@ dockers: skip_push: false docker_manifests: - - name_template: 0xpolygon/{{ .ProjectName }}:{{ .Version }} + - name_template: DOCKERHUB_ORGANIZATION/{{ .ProjectName }}:{{ .Version }} image_templates: - - 0xpolygon/{{ .ProjectName }}:{{ .Version }}-amd64 - - 0xpolygon/{{ .ProjectName }}:{{ .Version }}-arm64 + - DOCKERHUB_ORGANIZATION/{{ .ProjectName }}:{{ .Version }}-amd64 + - DOCKERHUB_ORGANIZATION/{{ .ProjectName }}:{{ .Version }}-arm64 skip_push: false - - name_template: 0xpolygon/{{ .ProjectName }}:latest + - name_template: DOCKERHUB_ORGANIZATION/{{ .ProjectName }}:latest image_templates: - - 0xpolygon/{{ .ProjectName }}:{{ .Version }}-amd64 - - 0xpolygon/{{ .ProjectName }}:{{ .Version }}-arm64 + - DOCKERHUB_ORGANIZATION/{{ .ProjectName }}:{{ .Version }}-amd64 + - DOCKERHUB_ORGANIZATION/{{ .ProjectName }}:{{ .Version }}-arm64 skip_push: auto diff --git a/Dockerfile.release b/Dockerfile.release index 12b3941e80..9100d7eb4a 100644 --- a/Dockerfile.release +++ b/Dockerfile.release @@ -8,9 +8,9 @@ COPY blade /usr/local/bin/ EXPOSE 8545 9632 1478 -RUN addgroup -S edge \ - && adduser -S edge -G edge +RUN addgroup -S blade-group \ + && adduser -S blade -G blade-group -USER edge +USER blade ENTRYPOINT ["blade"] From f2407f507c0abd72c5b19714da2b4fe37e4a9059 Mon Sep 17 00:00:00 2001 From: Branislav Kojic Date: Wed, 14 Feb 2024 13:38:42 +0100 Subject: [PATCH 2/2] GitHub Workflow Improvements (#107) * GitHub workflow changes * Verify the state file for deployment; Check if the network is already deployed; Change text * Fix Load Test parameter name * `Can't process result by diff processor` error fixed on Linter * Utilize the official `golangci-lint-action` as they provide support for node20. * Rename Tests to CI; Nightly notifications fixes; Minor changes * Replace `ec2-github-runner` action repository * loadtest scenarios fixes; setup-go cach fixes * `setup-go action` for Lint fixes * Indent fixes --- .../workflows/ansible/update_bladenet.yaml | 68 ---- .github/workflows/build.yml | 17 +- .github/workflows/ci.yml | 145 ++++++- .github/workflows/cla.yml | 6 +- .github/workflows/deploy-network.yml | 201 ++++++++++ .github/workflows/deploy.nightly.devnet.yml | 234 ------------ .github/workflows/destroy-network.yml | 163 ++++++++ .../{e2e-legacy.yaml => e2e-legacy-test.yml} | 25 +- .../{e2e-polybft.yml => e2e-polybft-test.yml} | 28 +- .github/workflows/fuzz-test.yml | 22 +- .github/workflows/lint.yml | 33 +- .github/workflows/load-test.yml | 258 +++++++++++++ .github/workflows/loadtest.yml | 224 ----------- .github/workflows/nightly.yml | 357 ++++++++---------- .../workflows/notification-deploy-network.yml | 108 ++++++ .../notification-destroy-network.yml | 100 +++++ .github/workflows/notification-load-test.yml | 139 +++++++ .github/workflows/notification-nightly.yml | 203 ++++++++++ ...-polybft.yml => property-polybft-test.yml} | 22 +- .github/workflows/{test.yml => unit-test.yml} | 27 +- Makefile | 12 +- e2e/README.md | 2 +- loadtest/scenarios/multiple_EOA.js | 37 +- loadtest/scenarios/multiple_ERC20.js | 47 ++- 24 files changed, 1603 insertions(+), 875 deletions(-) delete mode 100644 .github/workflows/ansible/update_bladenet.yaml create mode 100644 .github/workflows/deploy-network.yml delete mode 100644 .github/workflows/deploy.nightly.devnet.yml create mode 100644 .github/workflows/destroy-network.yml rename .github/workflows/{e2e-legacy.yaml => e2e-legacy-test.yml} (71%) rename .github/workflows/{e2e-polybft.yml => e2e-polybft-test.yml} (62%) create mode 100644 .github/workflows/load-test.yml delete mode 100644 .github/workflows/loadtest.yml create mode 100644 .github/workflows/notification-deploy-network.yml create mode 100644 .github/workflows/notification-destroy-network.yml create mode 100644 .github/workflows/notification-load-test.yml create mode 100644 .github/workflows/notification-nightly.yml rename .github/workflows/{property-polybft.yml => property-polybft-test.yml} (73%) rename .github/workflows/{test.yml => unit-test.yml} (76%) diff --git a/.github/workflows/ansible/update_bladenet.yaml b/.github/workflows/ansible/update_bladenet.yaml deleted file mode 100644 index ee964124a5..0000000000 --- a/.github/workflows/ansible/update_bladenet.yaml +++ /dev/null @@ -1,68 +0,0 @@ ---- -- - name: Update Blade binary - hosts: - - all - become: yes - tasks: - ## update & upgrade system - - name: Update & upgrade system - apt: - upgrade: yes - update_cache: yes - - ## stop blade service - - name: Stop Blade service - systemd: - state: stopped - name: blade - - ## get the latest release - - name: Get latest release link - uri: - url: https://api.github.com/repos/Ethernal-Tech/blade/releases/latest - return_content: true - register: blade_release - - ## download the latest release - - name: Download latest Blade release - get_url: - url: "{{ blade_release.json.assets[3].browser_download_url }}" - dest: /tmp/blade.tar.gz - force: yes - - ## create temp dir for release - - name: Create temp dir for Blade release - file: - path: /tmp/blade - state: directory - - ## unpack release tar - - name: Unpack Blade release - unarchive: - remote_src: yes - src: /tmp/blade.tar.gz - dest: /tmp/blade - - ## set blade to PATH - - name: Place Blade binary to PATH - copy: - remote_src: yes - src: /tmp/blade/blade - dest: /usr/local/bin/ - mode: a+x - force: yes - - ## remove release temp dir - - name: Remove temp Blade release dir - file: - state: absent - path: /tmp/blade - - ## start Blade service - - name: Start blade service - systemd: - state: restarted - name: blade - daemon_reload: yes - enabled: yes \ No newline at end of file diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 0a7fe0690d..e7b73e206a 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,47 +1,40 @@ --- -name: Build +name: Build Blade on: # yamllint disable-line rule:truthy - workflow_dispatch: workflow_call: - # Map the workflow outputs to job outputs outputs: workflow_output: - description: "Build output" + description: "Build Blade output" value: ${{ jobs.go_build.outputs.build_output_failure }} jobs: go_build: - name: Blade + name: Build runs-on: ubuntu-latest outputs: build_output_failure: ${{ steps.blade_build_failure.outputs.build_output }} steps: - name: Checkout code uses: actions/checkout@v4.1.1 - - name: Setup Go environment uses: actions/setup-go@v5.0.0 with: go-version: 1.20.x - - name: Build Blade - run: go build -o blade -tags netgo -ldflags="-s -w -X \"github.com/Ethernal-Tech/blade/versioning.Version=${GITHUB_REF_NAME}\" -X \"github.com/Ethernal-Tech/blade/versioning.Commit=${GITHUB_SHA}\"" && tar -czvf blade.tar.gz blade + run: go build -o blade -tags netgo -ldflags="-s -w -X \"github.com/${GITHUB_REPOSITORY}/versioning.Version=${GITHUB_REF_NAME}\" -X \"github.com/${GITHUB_REPOSITORY}/versioning.Commit=${GITHUB_SHA}\"" && tar -czvf blade.tar.gz blade env: GOARC: amd64 GOOS: linux - - name: Build Blade Failed if: failure() id: blade_build_failure run: echo "build_output=false" >> $GITHUB_OUTPUT - - name: "Upload Artifact" uses: actions/upload-artifact@v4.3.0 with: name: blade path: blade.tar.gz retention-days: 3 - go_build_reproducibility: name: Verify Build Reproducibility runs-on: ubuntu-latest @@ -49,12 +42,10 @@ jobs: steps: - name: Checkout code uses: actions/checkout@v4.1.1 - - name: Setup Go environment uses: actions/setup-go@v5.0.0 with: go-version: 1.20.x - - name: Reproduce builds continue-on-error: true run: | diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 237a0631b8..6df137d078 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,19 +1,146 @@ --- name: CI -on: # yamllint disable-line rule:truthy +on: # yamllint disable-line rule:truthy push: branches: - main - develop pull_request: - workflow_dispatch: {} + workflow_dispatch: + inputs: + build-blade: + description: Build Blade + type: boolean + default: true + lint: + description: Lint + type: boolean + default: true + unit-test: + description: Unit Tests + type: boolean + default: true + e2e-polybft-test: + description: E2E PolyBFT Tests + type: boolean + default: true + e2e-legacy-test: + description: E2E Legacy Tests + type: boolean + default: true + property-polybft-test: + description: Property PolyBFT Tests + type: boolean + default: true + fuzz-test: + description: Fuzz Tests + type: boolean + default: true + workflow_call: + inputs: + build-blade: + description: Build Blade + type: boolean + lint: + description: Lint + type: boolean + required: true + unit-test: + description: Unit Tests + type: boolean + required: true + e2e-polybft-test: + description: E2E PolyBFT Tests + type: boolean + required: true + e2e-legacy-test: + description: E2E Legacy Tests + type: boolean + required: true + property-polybft-test: + description: Property PolyBFT Tests + type: boolean + required: true + fuzz-test: + description: Fuzz Tests + type: boolean + required: true + outputs: + build-blade: + description: Build Blade output + value: ${{ jobs.build-blade.outputs.workflow_output }} + lint: + description: Lint output + value: ${{ jobs.lint.outputs.workflow_output }} + unit-test: + description: Unit Tests output + value: ${{ jobs.unit-test.outputs.workflow_output }} + e2e-polybft-test: + description: E2E PolyBFT Tests output + value: ${{ jobs.e2e-polybft-test.outputs.workflow_output }} + e2e-legacy-test: + description: E2E Legacy Tests output + value: ${{ jobs.e2e-legacy-test.outputs.workflow_output }} + property-polybft-test: + description: Property PolyBFT Tests output + value: ${{ jobs.property-polybft-test.outputs.workflow_output }} + fuzz-test: + description: Fuzz Tests output + value: ${{ jobs.fuzz-test.outputs.workflow_output }} jobs: - build: - name: Build + build-blade: + name: Build Blade uses: ./.github/workflows/build.yml - - test: - name: Test - uses: ./.github/workflows/test.yml - needs: build + if: | + inputs.build-blade || + github.event_name == 'pull_request' || + (github.event_name == 'push' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/develop')) + lint: + name: Lint + uses: ./.github/workflows/lint.yml + needs: build-blade + if: | + inputs.lint || + github.event_name == 'pull_request' || + (github.event_name == 'push' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/develop')) + unit-test: + name: Unit Tests + uses: ./.github/workflows/unit-test.yml + needs: build-blade + if: | + inputs.unit-test || + github.event_name == 'pull_request' || + (github.event_name == 'push' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/develop')) + e2e-polybft-test: + name: E2E PolyBFT Tests + uses: ./.github/workflows/e2e-polybft-test.yml + needs: build-blade + if: | + inputs.e2e-polybft-test || + github.event_name == 'pull_request' || + (github.event_name == 'push' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/develop')) + e2e-legacy-test: + name: E2E Legacy Tests + uses: ./.github/workflows/e2e-legacy-test.yml + needs: build-blade + if: | + inputs.e2e-legacy-test || + github.event_name == 'pull_request' || + (github.event_name == 'push' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/develop')) + property-polybft-test: + name: Property PolyBFT Tests + uses: ./.github/workflows/property-polybft-test.yml + needs: build-blade + if: | + inputs.property-polybft-test || + github.event_name == 'pull_request' || + (github.event_name == 'push' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/develop')) + fuzz-test: + name: Fuzz Tests + uses: ./.github/workflows/fuzz-test.yml + needs: build-blade + if: | + inputs.fuzz-test || + github.event_name == 'pull_request' || + (github.event_name == 'push' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/develop')) diff --git a/.github/workflows/cla.yml b/.github/workflows/cla.yml index 4e5b7e4444..a68d5ac0b8 100644 --- a/.github/workflows/cla.yml +++ b/.github/workflows/cla.yml @@ -1,5 +1,5 @@ --- -name: "CLA Assistant" +name: CLA Assistant on: # yamllint disable-line rule:truthy issue_comment: types: @@ -10,7 +10,7 @@ on: # yamllint disable-line rule:truthy - synchronize jobs: - CLAssistant: + cla-assistant: runs-on: ubuntu-latest steps: - name: "Check CLA" @@ -22,6 +22,6 @@ jobs: PERSONAL_ACCESS_TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN }} with: path-to-signatures: "cla.json" - path-to-document: "https://github.com/Ethernal-Tech/blade/blob/develop/CLA.md" + path-to-document: "https://github.com/${GITHUB_REPOSITORY}/blob/develop/CLA.md" branch: "cla-signatures" allowlist: dependabot[bot],dependabot-preview[bot] diff --git a/.github/workflows/deploy-network.yml b/.github/workflows/deploy-network.yml new file mode 100644 index 0000000000..118c0b653a --- /dev/null +++ b/.github/workflows/deploy-network.yml @@ -0,0 +1,201 @@ +--- +concurrency: ci-$ # Only a single workflow can be executed concurrently +name: Deploy Network +on: # yamllint disable-line rule:truthy + workflow_dispatch: + inputs: + environment: + description: The environment to run against + type: choice + options: [dev, test] # nightly should not be initiated manually + block_gas_limit: + description: Block Gas Limit + type: string + default: "200000000" + required: true + block_time: + description: Block Time + type: string + default: "2" + required: true + is_london_fork_active: + description: EIP-1559 + type: boolean + default: true + is_bridge_active: + description: With Bridge + type: boolean + default: true + notification: + description: Notification + type: boolean + default: true + workflow_call: + inputs: + environment: + description: The environment to run against + type: string + required: true + block_gas_limit: + description: Block Gas Limit + type: string + required: true + block_time: + description: Block Time + type: string + required: true + is_london_fork_active: + description: EIP-1559 + type: boolean + required: true + is_bridge_active: + description: With Bridge + type: boolean + required: true + notification: + description: Notification + type: boolean + required: true + outputs: + terraform_output: + description: "Terraform output" + value: ${{ jobs.deploy_network.outputs.terraform_output }} + ansible_output: + description: "Ansible output" + value: ${{ jobs.deploy_network.outputs.ansible_output }} + secrets: + AWS_ROLE_ARN: + required: true + AWS_S3_BLADE_BUCKET: + required: true + VAULT_PASSWORD: + required: true + +permissions: + id-token: write + contents: read + security-events: write + +jobs: + check_network: + name: Check if the network is already deployed + runs-on: ubuntu-latest + environment: ${{ inputs.environment }} + outputs: + check_output: ${{ steps.check_state_file.outputs.resources }} + rpc_url: ${{ steps.rpc_url.outputs.url }} + steps: + - name: Checkout code + uses: actions/checkout@v4.1.1 + - name: Configure AWS Credentials + uses: aws-actions/configure-aws-credentials@v4.0.1 + with: + aws-region: ${{ vars.AWS_REGION }} + role-to-assume: ${{ secrets.AWS_ROLE_ARN }} + - name: Retrieve state file from s3 + id: retrieve_state + run: echo "retrieve_state_output=$(aws s3 cp s3://${{ secrets.AWS_S3_BLADE_BUCKET }}/states/${{ inputs.environment }} state.json)" >> $GITHUB_OUTPUT + - name: Check state file + id: check_state_file + if: contains(steps.retrieve_state.outputs.retrieve_state_output, 'download') + run: echo "resources=$(cat state.json | jq -r ".resources" | jq length)" >> $GITHUB_OUTPUT + - name: Set RPC URL + id: rpc_url + if: contains(steps.retrieve_state.outputs.retrieve_state_output, 'download') + run: echo "url=$(cat state.json | jq -r '.outputs.aws_lb_ext_domain.value // empty')" >> $GITHUB_OUTPUT + deploy_network: + name: Deploy the network + runs-on: ubuntu-latest + needs: check_network + if: needs.check_network.outputs.check_output == 0 + environment: ${{ inputs.environment }} + outputs: + terraform_output: ${{ steps.terraform_failure.outputs.terraform_output }} + ansible_output: ${{ steps.ansible_failure.outputs.ansible_output }} + rpc_url: ${{ steps.rpc_url.outputs.url }} + steps: + - name: Checkout code + uses: actions/checkout@v4.1.1 + with: + repository: Ethernal-Tech/blade-deployment + ref: main + - name: Configure AWS Credentials + uses: aws-actions/configure-aws-credentials@v4.0.1 + with: + aws-region: ${{ vars.AWS_REGION }} + role-to-assume: ${{ secrets.AWS_ROLE_ARN }} + - name: Install Terraform + uses: hashicorp/setup-terraform@v3.0.0 + with: + terraform_version: 1.4.5 + - name: Configure Terraform + run: sed 's/# backend "s3" {}/backend "s3" {}/' main.tf > main.tf.tmp && mv main.tf.tmp main.tf + - name: Terraform Init + run: terraform init -backend-config="bucket=${{ secrets.AWS_S3_BLADE_BUCKET }}" -backend-config="key=states/${{ inputs.environment }}" -backend-config="region=${{ vars.AWS_REGION }}" + - name: Terraform Validate + run: terraform validate -no-color + continue-on-error: true + - name: Terraform Apply + run: terraform apply -auto-approve + env: + TF_VAR_deployment_name: ${{ inputs.environment }} + TF_VAR_base_instance_type: ${{ vars.AWS_INSTANCE_TYPE }} + TF_VAR_geth_count: ${{ vars.GETH_COUNT }} + TF_VAR_fullnode_count: ${{ vars.FULLNODE_COUNT }} + TF_VAR_validator_count: ${{ vars.VALIDATOR_COUNT }} + - name: Terraform Failed + if: failure() + id: terraform_failure + run: echo "terraform_output=false" >> $GITHUB_OUTPUT + - name: Configure private keys + run: | + terraform output pk_ansible > ~/private.key + chmod 600 ~/private.key + eval "$(ssh-agent)" + ssh-add ~/private.key + - name: Install Ansible / botocore / boto3 + run: | + python3 -m pip install --user ansible + python3 -m pip install boto3 botocore + - name: Configure Ansible + working-directory: ansible + run: | + echo "${{ secrets.VAULT_PASSWORD }}" > password.txt + sed 's/devnet/${{ inputs.environment }}/g' inventory/aws_ec2.yml > inventory/aws_ec2.yml.tmp && mv inventory/aws_ec2.yml.tmp inventory/aws_ec2.yml + sed 's/blade_tag: .*/blade_tag: ${{ github.sha }}/g' group_vars/all.yml > group_vars/all.yml.tmp && mv group_vars/all.yml.tmp group_vars/all.yml + sed 's/INFO/${{ vars.LOG_LEVEL }}/g' roles/blade/templates/blade.service > roles/blade/templates/blade.service.tmp && mv roles/blade/templates/blade.service.tmp roles/blade/templates/blade.service + - name: Setup Ansible + working-directory: ansible + run: | + ansible-inventory --graph + ansible-galaxy install -r requirements.yml + - name: Check previous blade data + id: previous_data + run: echo "previous_data_output=$(aws s3 cp s3://${{ secrets.AWS_S3_BLADE_BUCKET }}/states/${{ inputs.environment }}.data.tar.gz .)" >> $GITHUB_OUTPUT + - name: Run Ansible (Bootstrap blade) + if: (steps.previous_data.outputs.previous_data_output == '' || contains(steps.previous_data.outputs.previous_data_output, 'error')) + working-directory: ansible + run: ansible-playbook site.yml --extra-vars "clean_deploy_title=${{ inputs.environment }} blade_repository=${{ github.repository }} block_gas_limit=${{ inputs.block_gas_limit }} block_time=${{ inputs.block_time }} is_london_fork_active=${{ inputs.is_london_fork_active }} is_bridge_active=${{ inputs.is_bridge_active }}" + - name: Run Ansible (Restore data) + if: contains(steps.previous_data.outputs.previous_data_output, 'download') + working-directory: ansible + run: ansible-playbook site.yml --extra-vars "clean_deploy_title=${{ inputs.environment }} blade_repository=${{ github.repository }} block_gas_limit=${{ inputs.block_gas_limit }} block_time=${{ inputs.block_time }} s3_bucket=${{ secrets.AWS_S3_BLADE_BUCKET }} restore_data=true" + - name: Ansible Failed + if: failure() + id: ansible_failure + run: echo "ansible_output=false" >> $GITHUB_OUTPUT + - name: Set RPC URL + id: rpc_url + run: echo "url=$(terraform output -raw aws_lb_ext_domain | grep -o -E '^ext[^:]*')" >> $GITHUB_OUTPUT + notification: + name: Deploy Notification + needs: [check_network, deploy_network] + uses: ./.github/workflows/notification-deploy-network.yml + if: (always() && inputs.notification) + with: + environment: ${{ inputs.environment }} + deploy_network_terraform_output: ${{ needs.deploy_network.outputs.terraform_output }} + deploy_network_ansible_output: ${{ needs.deploy_network.outputs.ansible_output }} + rpc_url: ${{ needs.check_network.outputs.rpc_url || needs.deploy_network.outputs.rpc_url }} + secrets: + SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} diff --git a/.github/workflows/deploy.nightly.devnet.yml b/.github/workflows/deploy.nightly.devnet.yml deleted file mode 100644 index dd2b2ccfd9..0000000000 --- a/.github/workflows/deploy.nightly.devnet.yml +++ /dev/null @@ -1,234 +0,0 @@ ---- - -name: Build Devnet -on: # yamllint disable-line rule:truthy - workflow_dispatch: - inputs: - environment: - description: The environment to run against - required: false - type: environment - duration: - default: "10m" - description: Duration of the test - required: false - type: string - workflow_call: - inputs: - environment: - description: The environment to run against - type: string - required: true - duration: - default: "10m" - description: Duration of the test - required: false - type: string - outputs: - workflow_output_loadtest1: - description: "Loadtest output" - value: ${{ jobs.loadtest1.outputs.workflow_output }} - workflow_output_loadtest2: - description: "Loadtest output" - value: ${{ jobs.loadtest2.outputs.workflow_output }} - secrets: - AWS_ROLE_ARN: - required: true - AWS_REGION: - required: true - TF_VAR_DEPLOYMENT_NAME: - required: true - TF_VAR_OWNER: - required: true - TF_VAR_BASE_INSTANCE_TYPE: - required: true - SLACK_PERFORMANCE_WEBHOOK_URL: - required: true - LOADTESTER_AWS_SUBNET_ID: - required: true - LOADTESTER_AWS_SG_ID: - required: true - LOADTESTER_INSTANCE_TYPE: - required: true - LOADTESTER_AMI: - required: true - LOADTEST_MNEMONIC: - required: true - VAULT_PASSWORD_FILE: - required: true - IS_BRIDGE_ACTIVE: - required: true - PTA: - required: true - BLADE_TAG: - required: true - LOG_LEVEL: - required: true - -jobs: - build: - runs-on: ubuntu-latest - environment: ${{ inputs.environment }} - steps: - - name: Checkout code - uses: actions/checkout@v4.1.1 - with: - repository: Ethernal-Tech/blade-deployment - ref: main - - name: Configure AWS Credentials - uses: aws-actions/configure-aws-credentials@v2 - with: - role-to-assume: ${{ secrets.AWS_ROLE_ARN }} - aws-region: ${{ secrets.AWS_REGION }} - - name: Install Terraform - uses: hashicorp/setup-terraform@v2.0.3 - with: - terraform_version: 1.4.5 - - name: Configure terraform for nightly build - run: | - sed 's/# backend "s3" {}/backend "s3" {}/' main.tf > main.tf.tmp && mv main.tf.tmp main.tf - - name: Terraform Init - id: init - run: terraform init -backend-config="bucket=blade-terraform-states" -backend-config="key=state/${{ secrets.TF_VAR_DEPLOYMENT_NAME }}" -backend-config="region=${{ secrets.AWS_REGION }}" - - name: Terraform Validate - id: validate - run: terraform validate -no-color - continue-on-error: true - - name: Terraform Apply - id: apply - run: terraform apply -auto-approve - env: - TF_VAR_deployment_name: ${{ secrets.TF_VAR_DEPLOYMENT_NAME }} - TF_VAR_owner: ${{ secrets.TF_VAR_OWNER }} - TF_VAR_base_instance_type: ${{ secrets.TF_VAR_BASE_INSTANCE_TYPE }} - - name: Retrieve state file from s3 - run: aws s3 cp s3://blade-terraform-states/state/${{ secrets.TF_VAR_DEPLOYMENT_NAME }} state.json - - name: Configure private keys - run: | - terraform output pk_ansible > ~/devnet_private.key - chmod 600 ~/devnet_private.key - eval "$(ssh-agent)" - ssh-add ~/devnet_private.key - - name: Install ansible / botocore / boto3 - run: | - python3 -m pip install --user ansible - python3 -m pip install boto3 botocore - - name: Configure ansible for nightly build - working-directory: ansible - run: | - echo "${{ secrets.VAULT_PASSWORD_FILE }}" > password.txt - sed 's/devnet13/${{ secrets.TF_VAR_DEPLOYMENT_NAME }}/g' inventory/aws_ec2.yml > inventory/aws_ec2.yml.tmp && mv inventory/aws_ec2.yml.tmp inventory/aws_ec2.yml - sed 's/devnet13/${{ secrets.TF_VAR_DEPLOYMENT_NAME }}/g' group_vars/all.yml > group_vars/all.yml.tmp && mv group_vars/all.yml.tmp group_vars/all.yml - sed 's/blade_tag: .*/blade_tag: ${{ secrets.BLADE_TAG }}/g' group_vars/all.yml > group_vars/all.yml.tmp && mv group_vars/all.yml.tmp group_vars/all.yml - sed 's/is_bridge_active: .*/is_bridge_active: ${{ secrets.IS_BRIDGE_ACTIVE }}/g' group_vars/all.yml > group_vars/all.yml.tmp && mv group_vars/all.yml.tmp group_vars/all.yml - sed 's/INFO/${{ secrets.LOG_LEVEL }}/g' roles/blade/templates/blade.service > roles/blade/templates/blade.service.tmp && mv roles/blade/templates/blade.service.tmp roles/blade/templates/blade.service - - name: Run Ansible - working-directory: ansible - run: | - ansible-inventory --graph - ansible-galaxy install -r requirements.yml - ansible-playbook site.yml --extra-vars "block_gas_limit=200000000 block_time=2" - - name: Set rpc url value - id: url - run: | - terraform output -raw aws_lb_ext_domain | grep -o -E '^ext[^:]*' > rpc_url.txt - - uses: actions/upload-artifact@v4.3.0 - with: - name: rpc_url - path: rpc_url.txt - - loadtest1: - needs: build - uses: ./.github/workflows/loadtest.yml - name: Load Test Nightly Build - multiple_EOA - secrets: - AWS_REGION: ${{ secrets.AWS_REGION }} - AWS_ROLE_ARN: ${{ secrets.AWS_ROLE_ARN }} - LOADTESTER_INSTANCE_TYPE: ${{ secrets.LOADTESTER_INSTANCE_TYPE }} - LOADTESTER_AMI: ${{ secrets.LOADTESTER_AMI }} - LOADTESTER_AWS_SUBNET_ID: ${{ secrets.LOADTESTER_AWS_SUBNET_ID }} - LOADTESTER_AWS_SG_ID: ${{ secrets.LOADTESTER_AWS_SG_ID }} - SLACK_PERFORMANCE_WEBHOOK_URL: ${{ secrets.SLACK_PERFORMANCE_WEBHOOK_URL }} - LOADTEST_RPC_URL: "" # this is a workaround because of actions bug in passing output to another job - LOADTEST_MNEMONIC: ${{ secrets.LOADTEST_MNEMONIC }} - PTA: ${{ secrets.PTA }} - with: - environment: ${{ inputs.environment }} - scenario: multiple_EOA - duration: ${{ inputs.duration }} - - loadtest2: - needs: loadtest1 - uses: ./.github/workflows/loadtest.yml - name: Load Test Nightly Build - multiple_ERC20 - secrets: - AWS_REGION: ${{ secrets.AWS_REGION }} - AWS_ROLE_ARN: ${{ secrets.AWS_ROLE_ARN }} - LOADTESTER_INSTANCE_TYPE: ${{ secrets.LOADTESTER_INSTANCE_TYPE }} - LOADTESTER_AMI: ${{ secrets.LOADTESTER_AMI }} - LOADTESTER_AWS_SUBNET_ID: ${{ secrets.LOADTESTER_AWS_SUBNET_ID }} - LOADTESTER_AWS_SG_ID: ${{ secrets.LOADTESTER_AWS_SG_ID }} - SLACK_PERFORMANCE_WEBHOOK_URL: ${{ secrets.SLACK_PERFORMANCE_WEBHOOK_URL }} - LOADTEST_RPC_URL: "" # this is a workaround because of actions bug in passing output to another job - LOADTEST_MNEMONIC: ${{ secrets.LOADTEST_MNEMONIC }} - PTA: ${{ secrets.PTA }} - with: - environment: ${{ inputs.environment }} - scenario: multiple_ERC20 - duration: ${{ inputs.duration }} - - destroy_devnet: - needs: [loadtest1, loadtest2] - if: always() - name: Destroy Nightly Build - runs-on: ubuntu-latest - environment: ${{ inputs.environment }} - steps: - - name: Checkout code - uses: actions/checkout@v4.1.1 - with: - repository: Ethernal-Tech/blade-deployment - ref: main - - name: Configure AWS Credentials - uses: aws-actions/configure-aws-credentials@v2 - with: - role-to-assume: ${{ secrets.AWS_ROLE_ARN }} - aws-region: ${{ secrets.AWS_REGION }} - - name: Install Terraform - uses: hashicorp/setup-terraform@v2.0.3 - with: - terraform_version: 1.4.5 - - name: Configure terraform for nightly build - run: | - sed 's/# backend "s3" {}/backend "s3" {}/' main.tf > main.tf.tmp && mv main.tf.tmp main.tf - - name: Terraform Init - id: init - run: terraform init -backend-config="bucket=blade-terraform-states" -backend-config="key=state/${{ secrets.TF_VAR_DEPLOYMENT_NAME }}" -backend-config="region=${{ secrets.AWS_REGION }}" - - name: Retrieve state file from s3 - run: aws s3 cp s3://blade-terraform-states/state/${{ secrets.TF_VAR_DEPLOYMENT_NAME }} state.json - - name: Configure private keys - run: | - terraform output pk_ansible > ~/devnet_private.key - chmod 600 ~/devnet_private.key - eval "$(ssh-agent)" - ssh-add ~/devnet_private.key - - name: Install ansible / botocore / boto3 - run: | - python3 -m pip install --user ansible - python3 -m pip install boto3 botocore - - name: Configure ansible for nightly logs - working-directory: ansible - run: | - echo "${{ secrets.VAULT_PASSWORD_FILE }}" > password.txt - sed 's/{{ current_datetime\.stdout }}/${{ github.run_id }}/g' roles/upload-logs/tasks/logs.yml > roles/upload-logs/tasks/logs.yml.tmp && mv roles/upload-logs/tasks/logs.yml.tmp roles/upload-logs/tasks/logs.yml - - name: Upload Logs - working-directory: ansible - run: | - ansible-playbook upload-logs.yml - - name: Terraform Destroy - id: destroy - run: terraform destroy -auto-approve -state=state.json - env: - TF_VAR_deployment_name: ${{ secrets.TF_VAR_DEPLOYMENT_NAME }} - TF_VAR_owner: ${{ secrets.TF_VAR_OWNER }} - TF_VAR_base_instance_type: ${{ secrets.TF_VAR_BASE_INSTANCE_TYPE }} diff --git a/.github/workflows/destroy-network.yml b/.github/workflows/destroy-network.yml new file mode 100644 index 0000000000..b280103051 --- /dev/null +++ b/.github/workflows/destroy-network.yml @@ -0,0 +1,163 @@ +--- +concurrency: ci-$ # Only a single workflow can be executed concurrently +name: Destroy Network +on: # yamllint disable-line rule:truthy + workflow_dispatch: + inputs: + environment: + description: The environment to run against + type: choice + options: [dev, test] # nightly should not be initiated manually + logs: + description: Upload Logs + type: boolean + default: false + notification: + description: Notification + type: boolean + default: true + workflow_call: + inputs: + environment: + description: The environment to run against + type: string + required: true + logs: + description: Upload Logs + type: boolean + required: true + notification: + description: Notification + type: boolean + required: true + outputs: + logs_output: + description: Upload Logs output + value: ${{ jobs.upload_logs_and_data.outputs.logs_output }} + terraform_output: + description: Terraform output + value: ${{ jobs.destroy_network.outputs.terraform_output }} + secrets: + AWS_ROLE_ARN: + required: true + AWS_S3_BLADE_BUCKET: + required: true + VAULT_PASSWORD: + required: true + +permissions: + id-token: write + contents: read + security-events: write + +jobs: + upload_logs_and_data: + name: Upload Logs and Data + runs-on: ubuntu-latest + environment: ${{ inputs.environment }} + if: (inputs.logs || inputs.environment == 'test') + outputs: + logs_output: ${{ steps.logs_failure.outputs.logs_output }} + steps: + - name: Checkout code + uses: actions/checkout@v4.1.1 + with: + repository: Ethernal-Tech/blade-deployment + ref: main + - name: Configure AWS Credentials + uses: aws-actions/configure-aws-credentials@v4.0.1 + with: + aws-region: ${{ vars.AWS_REGION }} + role-to-assume: ${{ secrets.AWS_ROLE_ARN }} + - name: Install Terraform + uses: hashicorp/setup-terraform@v3.0.0 + with: + terraform_version: 1.4.5 + - name: Configure Terraform + run: sed 's/# backend "s3" {}/backend "s3" {}/' main.tf > main.tf.tmp && mv main.tf.tmp main.tf + - name: Terraform Init + id: init + run: terraform init -backend-config="bucket=${{ secrets.AWS_S3_BLADE_BUCKET }}" -backend-config="key=states/${{ inputs.environment }}" -backend-config="region=${{ vars.AWS_REGION }}" + - name: Check if the network is already deployed + id: check_network + run: echo "pk_output=$(terraform output -json | jq -r '.pk_ansible.value // empty' | wc -c | tr -d ' ')" >> $GITHUB_OUTPUT + - name: Configure private keys + if: steps.check_network.outputs.pk_output > 0 + run: | + terraform output pk_ansible > ~/private.key + chmod 600 ~/private.key + eval "$(ssh-agent)" + ssh-add ~/private.key + - name: Install Ansible / botocore / boto3 + run: | + python3 -m pip install --user ansible + python3 -m pip install boto3 botocore + - name: Configure Ansible + working-directory: ansible + run: | + echo "${{ secrets.VAULT_PASSWORD }}" > password.txt + sed 's/devnet/${{ inputs.environment }}/g' inventory/aws_ec2.yml > inventory/aws_ec2.yml.tmp && mv inventory/aws_ec2.yml.tmp inventory/aws_ec2.yml + sed 's/{{ current_datetime\.stdout }}/${{ github.run_id }}/g' roles/upload-logs/tasks/main.yml > roles/upload-logs/tasks/main.yml.tmp && mv roles/upload-logs/tasks/main.yml.tmp roles/upload-logs/tasks/main.yml + - name: Upload Logs + if: (steps.check_network.outputs.pk_output > 0 && inputs.logs) + working-directory: ansible + run: ansible-playbook upload-logs.yml --extra-vars "clean_deploy_title=${{ inputs.environment }} s3_bucket=${{ secrets.AWS_S3_BLADE_BUCKET }}" + - name: Logs Failed + if: failure() + id: logs_failure + run: echo "logs_output=false" >> $GITHUB_OUTPUT + - name: Upload Data + if: (always() && steps.check_network.outputs.pk_output > 0 && inputs.environment == 'test') + working-directory: ansible + run: ansible-playbook upload-data.yml --extra-vars "clean_deploy_title=${{ inputs.environment }} s3_bucket=${{ secrets.AWS_S3_BLADE_BUCKET }}" + - name: Data Failed + if: failure() + id: data_failure + run: echo "data_output=false" >> $GITHUB_OUTPUT + destroy_network: + name: Destroy the network + runs-on: ubuntu-latest + environment: ${{ inputs.environment }} + needs: upload_logs_and_data + if: always() + outputs: + terraform_output: ${{ steps.terraform_failure.outputs.terraform_output }} + steps: + - name: Checkout code + uses: actions/checkout@v4.1.1 + with: + repository: Ethernal-Tech/blade-deployment + ref: main + - name: Configure AWS Credentials + uses: aws-actions/configure-aws-credentials@v4.0.1 + with: + aws-region: ${{ vars.AWS_REGION }} + role-to-assume: ${{ secrets.AWS_ROLE_ARN }} + - name: Install Terraform + uses: hashicorp/setup-terraform@v3.0.0 + with: + terraform_version: 1.4.5 + - name: Configure Terraform + run: sed 's/# backend "s3" {}/backend "s3" {}/' main.tf > main.tf.tmp && mv main.tf.tmp main.tf + - name: Terraform Init + id: init + run: terraform init -backend-config="bucket=${{ secrets.AWS_S3_BLADE_BUCKET }}" -backend-config="key=states/${{ inputs.environment }}" -backend-config="region=${{ vars.AWS_REGION }}" + - name: Terraform Destroy + run: terraform destroy -auto-approve + - name: Terraform Failed + if: failure() + id: terraform_failure + run: echo "terraform_output=false" >> $GITHUB_OUTPUT + notification: + name: Network Notifications + uses: ./.github/workflows/notification-destroy-network.yml + needs: [upload_logs_and_data, destroy_network] + if: (always() && inputs.notification) + with: + environment: ${{ inputs.environment }} + logs: ${{ inputs.logs }} + destroy_network_upload_logs: ${{ needs.upload_logs_and_data.outputs.logs_output }} + destroy_network_terraform_logs: ${{ needs.destroy_network.outputs.terraform_output }} + secrets: + AWS_S3_BLADE_BUCKET: ${{ secrets.AWS_S3_BLADE_BUCKET }} + SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} diff --git a/.github/workflows/e2e-legacy.yaml b/.github/workflows/e2e-legacy-test.yml similarity index 71% rename from .github/workflows/e2e-legacy.yaml rename to .github/workflows/e2e-legacy-test.yml index 535ea11a8d..31cbdd0404 100644 --- a/.github/workflows/e2e-legacy.yaml +++ b/.github/workflows/e2e-legacy-test.yml @@ -1,20 +1,15 @@ --- -name: Legacy E2E tests -on: # yamllint disable-line rule:truthy - push: - branches: - - main - - develop - pull_request: - workflow_dispatch: +name: E2E Legacy Tests +on: # yamllint disable-line rule:truthy workflow_call: outputs: workflow_output: - description: "E2E Legacy output" - value: ${{ jobs.build.outputs.e2e_legacy_output_failure }} + description: "E2E Legacy Tests output" + value: ${{ jobs.e2e_legacy.outputs.e2e_legacy_output_failure }} jobs: - build: + e2e_legacy: + name: Run E2E Legacy Tests runs-on: ubuntu-latest env: E2E_TESTS: true @@ -27,24 +22,20 @@ jobs: uses: actions/checkout@v4.1.1 with: submodules: recursive - - name: Install Go uses: actions/setup-go@v5.0.0 with: go-version: 1.20.x - - name: Run tests - run: make test-e2e - + run: make test-e2e-legacy - name: Run tests failed if: failure() id: run_e2e_legacy_failure run: echo "test_output=false" >> $GITHUB_OUTPUT - - name: Archive test logs if: always() uses: actions/upload-artifact@v4.3.0 with: - name: e2e-logs + name: e2e-legacy-logs path: e2e-logs-*/ retention-days: 30 diff --git a/.github/workflows/e2e-polybft.yml b/.github/workflows/e2e-polybft-test.yml similarity index 62% rename from .github/workflows/e2e-polybft.yml rename to .github/workflows/e2e-polybft-test.yml index 5824183cf7..e79937f4e0 100644 --- a/.github/workflows/e2e-polybft.yml +++ b/.github/workflows/e2e-polybft-test.yml @@ -1,50 +1,40 @@ --- -name: PolyBFT E2E tests -on: # yamllint disable-line rule:truthy - push: - branches: - - main - - develop - pull_request: - workflow_dispatch: +name: E2E PolyBFT Tests +on: # yamllint disable-line rule:truthy workflow_call: outputs: workflow_output: - description: "E2E output" - value: ${{ jobs.build.outputs.e2e_output_failure }} + description: "E2E PolyBFT Tests output" + value: ${{ jobs.e2e_polybft.outputs.e2e_polybft_output_failure }} jobs: - build: + e2e_polybft: + name: Run E2E PolyBFT Tests runs-on: ubuntu-latest env: E2E_TESTS: true E2E_LOGS: true CI_VERBOSE: true outputs: - e2e_output_failure: ${{ steps.run_e2e_failure.outputs.test_output }} + e2e_polybft_output_failure: ${{ steps.run_e2e_polybft_failure.outputs.test_output }} steps: - name: Checkout code uses: actions/checkout@v4.1.1 - - name: Install Go uses: actions/setup-go@v5.0.0 with: go-version: 1.20.x check-latest: true - cache-dependency-path: go.sum - - name: Run tests run: make test-e2e-polybft - - name: Run tests failed if: failure() - id: run_e2e_failure + id: run_e2e_polybft_failure run: echo "test_output=false" >> $GITHUB_OUTPUT - - name: Archive test logs if: always() uses: actions/upload-artifact@v4.3.0 with: - name: e2e-logs + name: e2e-polybft-logs path: e2e-logs-*/ retention-days: 30 diff --git a/.github/workflows/fuzz-test.yml b/.github/workflows/fuzz-test.yml index 96b41cd8ca..66cb2cf9fc 100644 --- a/.github/workflows/fuzz-test.yml +++ b/.github/workflows/fuzz-test.yml @@ -1,38 +1,28 @@ --- -name: Fuzz tests -on: # yamllint disable-line rule:truthy - push: - branches: - - main - - develop - workflow_dispatch: +name: Fuzz Tests +on: # yamllint disable-line rule:truthy workflow_call: outputs: workflow_output: - description: "Fuzz output" + description: "Fuzz Tests output" value: ${{ jobs.fuzz_test.outputs.fuzz_output_failure }} - jobs: fuzz_test: - name: Blade + name: Run Fuzz Tests runs-on: ubuntu-latest outputs: fuzz_output_failure: ${{ steps.run_fuzz_failure.outputs.test_output }} steps: + - name: Checkout Code + uses: actions/checkout@v4.1.1 - name: Setup Go uses: actions/setup-go@v5.0.0 with: go-version: 1.20.x - - - name: Checkout Code - uses: actions/checkout@v4.1.1 - - name: Run Fuzz Test run: make fuzz-test - - name: Run fuzz tests failed if: failure() id: run_fuzz_failure run: echo "test_output=false" >> $GITHUB_OUTPUT - diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index d690e956a1..dc28e1178b 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -1,30 +1,33 @@ --- name: Lint on: # yamllint disable-line rule:truthy - push: - branches: - - main - - develop - - pull_request: - - workflow_call: {} - workflow_dispatch: {} + workflow_call: + outputs: + workflow_output: + description: "Lint output" + value: ${{ jobs.golangci_lint.outputs.lint_output_failure }} jobs: golangci_lint: - name: Linter + name: Run Lint runs-on: ubuntu-latest + outputs: + lint_output_failure: ${{ steps.lint_failure.outputs.lint_output }} steps: + - name: Checkout code + uses: actions/checkout@v4.1.1 + with: + fetch-depth: 0 - name: Install Go uses: actions/setup-go@v5.0.0 with: go-version: 1.20.x - - - name: Checkout code - uses: actions/checkout@v4.1.1 - + cache: false - name: Lint - uses: golangci/golangci-lint-action@v3 + uses: golangci/golangci-lint-action@v4.0.0 with: args: --timeout 10m --verbose + - name: Lint Failed + if: failure() + id: lint_failure + run: echo "lint_output=false" >> $GITHUB_OUTPUT diff --git a/.github/workflows/load-test.yml b/.github/workflows/load-test.yml new file mode 100644 index 0000000000..6fa0c7938d --- /dev/null +++ b/.github/workflows/load-test.yml @@ -0,0 +1,258 @@ +--- +concurrency: ci-$ # Only a single workflow can be executed concurrently +name: Load Tests +on: # yamllint disable-line rule:truthy + workflow_dispatch: + inputs: + environment: + description: The environment to run against + type: choice + options: [dev, test] # nightly should not be initiated manually + scenario: + description: The scenario to run + type: choice + options: [EOA, ERC20] + timeout: + description: Time Out + type: string + default: "220s" + required: true + rate: + description: Rate + type: string + default: "3000" + required: true + timeUnit: + description: Time Unit + type: string + default: "1s" + required: true + duration: + description: Duration + type: string + default: "10m" + required: true + preAllocatedVUs: + description: Preallocated VUs + type: string + default: "60" + required: true + maxVUs: + description: Max VUs + type: string + default: "60" + required: true + notification: + description: Notification + type: boolean + default: true + workflow_call: + inputs: + environment: + description: The environment to run against + type: string + required: true + scenario: + description: The scenario to run + type: string + required: true + timeout: + description: Time Out + type: string + required: true + rate: + description: Rate + type: string + required: true + timeUnit: + description: Time Unit + type: string + required: true + duration: + description: Duration + type: string + required: true + preAllocatedVUs: + description: Preallocated VUs + type: string + required: true + maxVUs: + description: Max VUs + type: string + required: true + notification: + description: Notification + type: boolean + required: true + outputs: + load_test_output: + description: "Load Test output" + value: ${{ jobs.load_test_scenario.outputs.test_output_success }} + tps_avg: + description: "Average Transactions Per Second" + value: ${{ jobs.load_test_scenario.outputs.tps_avg }} + tps_max: + description: "Maximum Transactions Per Second" + value: ${{ jobs.load_test_scenario.outputs.tps_max }} + iterations: + description: "Number Of Transactions" + value: ${{ jobs.load_test_scenario.outputs.iterations }} + block: + description: "Block Number" + value: ${{ jobs.load_test_scenario.outputs.block }} + ttm: + description: "Time To Mine" + value: ${{ jobs.load_test_scenario.outputs.ttm }} + gas_avg: + description: "Average Gas Used" + value: ${{ jobs.load_test_scenario.outputs.gas_avg }} + gas_max: + description: "Maximum Gas Used" + value: ${{ jobs.load_test_scenario.outputs.gas_max }} + secrets: + AWS_ROLE_ARN: + required: true + AWS_S3_BLADE_BUCKET: + required: true + AWS_LOADTESTRUNNER_AMI_ID: + required: true + AWS_LOADTESTRUNNER_SUBNET_ID: + required: true + AWS_LOADTESTRUNNER_SG_ID: + required: true + AWS_LOADTESTRUNNER_MNEMONIC: + required: true + PERSONAL_ACCESS_TOKEN: + required: true + SLACK_WEBHOOK_URL: + required: true + +permissions: + id-token: write + contents: read + security-events: write + +jobs: + check_network: + name: Check if the network is already deployed + runs-on: ubuntu-latest + environment: ${{ inputs.environment }} + outputs: + rpc_url: ${{ steps.rpc_url.outputs.url }} + steps: + - name: Checkout code + uses: actions/checkout@v4.1.1 + - name: Configure AWS Credentials + uses: aws-actions/configure-aws-credentials@v4.0.1 + with: + aws-region: ${{ vars.AWS_REGION }} + role-to-assume: ${{ secrets.AWS_ROLE_ARN }} + - name: Retrieve state file from s3 + id: retrieve_state + run: echo "retrieve_state_output=$(aws s3 cp s3://${{ secrets.AWS_S3_BLADE_BUCKET }}/states/${{ inputs.environment }} state.json)" >> $GITHUB_OUTPUT + - name: Set RPC URL + id: rpc_url + if: contains(steps.retrieve_state.outputs.retrieve_state_output, 'download') + run: echo "url=$(cat state.json | jq -r '.outputs.aws_lb_ext_domain.value // empty')" >> $GITHUB_OUTPUT + load_test_runner: + name: Deploy Load Test Runner + runs-on: ubuntu-latest + environment: ${{ inputs.environment }} + needs: check_network + if: needs.check_network.outputs.rpc_url != '' + outputs: + load_test_runner_label: ${{ steps.start_load_teste_runner.outputs.label }} + load_test_runner_instance_id: ${{ steps.start_load_teste_runner.outputs.ec2-instance-id }} + steps: + - name: Configure AWS credentials + uses: aws-actions/configure-aws-credentials@v4.0.1 + with: + aws-region: ${{ vars.AWS_REGION }} + role-to-assume: ${{ secrets.AWS_ROLE_ARN }} + - name: Start Load Test Runner + id: start_load_teste_runner + uses: Ethernal-Tech/ec2-github-runner@v3.0.0 + with: + mode: start + ec2-instance-type: ${{ vars.AWS_INSTANCE_TYPE }} + ec2-image-id: ${{ secrets.AWS_LOADTESTRUNNER_AMI_ID }} + subnet-id: ${{ secrets.AWS_LOADTESTRUNNER_SUBNET_ID }} + security-group-id: ${{ secrets.AWS_LOADTESTRUNNER_SG_ID }} + github-token: ${{ secrets.PERSONAL_ACCESS_TOKEN }} + load_test_scenario: + name: Run Load Test ${{ inputs.scenario }} Scenario + runs-on: ${{ needs.load_test_runner.outputs.load_test_runner_label }} + needs: [check_network, load_test_runner] + outputs: + test_output_success: ${{ steps.load_test_results_success.outputs.test_output }} + tps_avg: ${{ steps.load_test_results.outputs.tps_avg }} + tps_max: ${{ steps.load_test_results.outputs.tps_max }} + iterations: ${{ steps.load_test_results.outputs.iterations }} + block: ${{ steps.load_test_results.outputs.block }} + ttm: ${{ steps.load_test_results.outputs.ttm }} + gas_avg: ${{ steps.load_test_results.outputs.gas_avg }} + gas_max: ${{ steps.load_test_results.outputs.gas_max }} + steps: + - name: Checkout code + uses: actions/checkout@v4.1.1 + - name: Run scenario + id: load_test_results + run: | + /home/ubuntu/k6 run --out statsd loadtest/scenarios/multiple_${{ inputs.scenario }}.js + echo "tps_avg=$(cat summary.json | jq -r '.metrics.ethereum_tps.values.avg')" >> $GITHUB_OUTPUT + echo "tps_max=$(cat summary.json | jq -r '.metrics.ethereum_tps.values.max')" >> $GITHUB_OUTPUT + echo "iterations=$(cat summary.json | jq -r '.metrics.iterations.values.count')" >> $GITHUB_OUTPUT + echo "block=$(cat summary.json | jq -r '.metrics.ethereum_block.values.count')" >> $GITHUB_OUTPUT + echo "ttm=$(cat summary.json | jq -r '.metrics.ethereum_time_to_mine.values.avg')" >> $GITHUB_OUTPUT + echo "gas_avg=$(cat summary.json | jq -r '.metrics.ethereum_gas_used.values.avg')" >> $GITHUB_OUTPUT + echo "gas_max=$(cat summary.json | jq -r '.metrics.ethereum_gas_used.values.max')" >> $GITHUB_OUTPUT + env: + K6_STATSD_ENABLE_TAGS: true + SETUP_TIMEOUT: ${{ inputs.timeout }} + RATE: ${{ inputs.rate }} + TIME_UNIT: ${{ inputs.timeUnit }} + DURATION: ${{ inputs.duration }} + PREALLOCATED_VUS: ${{ inputs.preAllocatedVUs }} + MAX_VUS: ${{ inputs.maxVUs }} + LOADTEST_MNEMONIC: ${{ secrets.AWS_LOADTESTRUNNER_MNEMONIC }} + RPC_URL: "http://${{ needs.check_network.outputs.rpc_url }}" + - name: Run tests success + if: success() + id: load_test_results_success + run: echo "test_output=true" >> $GITHUB_OUTPUT + notification: + name: Load Test Notification + needs: load_test_scenario + uses: ./.github/workflows/notification-load-test.yml + if: (always() && inputs.notification && needs.load_test_scenario.outputs.test_output_success == 'true') + with: + environment: ${{ inputs.environment }} + scenario: ${{ inputs.scenario }} + tps_avg: ${{ needs.load_test_scenario.outputs.tps_avg }} + tps_max: ${{ needs.load_test_scenario.outputs.tps_max }} + iterations: ${{ needs.load_test_scenario.outputs.iterations }} + block: ${{ needs.load_test_scenario.outputs.block }} + ttm: ${{ needs.load_test_scenario.outputs.ttm }} + gas_avg: ${{ needs.load_test_scenario.outputs.gas_avg }} + gas_max: ${{ needs.load_test_scenario.outputs.gas_max }} + secrets: + SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} + destroy_load_test_runner: + name: Destroy Load Test Runner + environment: ${{ inputs.environment }} + needs: [load_test_runner, load_test_scenario] + if: always() + runs-on: ubuntu-latest + steps: + - name: Configure AWS credentials + uses: aws-actions/configure-aws-credentials@v4.0.1 + with: + aws-region: ${{ vars.AWS_REGION }} + role-to-assume: ${{ secrets.AWS_ROLE_ARN }} + - name: Stop Load Test Runner + uses: Ethernal-Tech/ec2-github-runner@v3.0.0 + with: + mode: stop + label: ${{ needs.load_test_runner.outputs.load_test_runner_label }} + ec2-instance-id: ${{ needs.load_test_runner.outputs.load_test_runner_instance_id }} + github-token: ${{ secrets.PERSONAL_ACCESS_TOKEN }} diff --git a/.github/workflows/loadtest.yml b/.github/workflows/loadtest.yml deleted file mode 100644 index 33a0f72a5f..0000000000 --- a/.github/workflows/loadtest.yml +++ /dev/null @@ -1,224 +0,0 @@ ---- -name: Load Test -on: # yamllint disable-line rule:truthy - workflow_dispatch: - inputs: - environment: - default: devnet - description: The environment to run against - required: false - type: environment - scenario: - default: 'simple' - description: The scenario to run - type: string - duration: - default: '5m' - description: Duration of the test - required: false - type: string - workflow_call: - inputs: - environment: - default: devnet - description: The environment to run against - type: string - required: true - scenario: - default: 'simple' - required: true - description: The mode for the stress test - type: string - duration: - default: '5m' - description: Duration of the test - required: false - type: string - outputs: - workflow_output: - description: "Loadtest output" - value: ${{ jobs.run_k6.outputs.loadtest_output_success }} - secrets: - AWS_REGION: - required: true - AWS_ROLE_ARN: - required: true - LOADTESTER_AWS_SUBNET_ID: - required: true - LOADTESTER_AWS_SG_ID: - required: true - LOADTESTER_INSTANCE_TYPE: - required: true - LOADTESTER_AMI: - required: true - LOADTEST_RPC_URL: - required: true - LOADTEST_MNEMONIC: - required: true - SLACK_PERFORMANCE_WEBHOOK_URL: - required: true - PTA: - required: true - -jobs: - build: - environment: ${{ inputs.environment }} - runs-on: ubuntu-latest - outputs: - label: ${{ steps.start-loadtester.outputs.label }} - ec2-instance-id: ${{ steps.start-loadtester.outputs.ec2-instance-id }} - steps: - - name: Configure AWS credentials - uses: aws-actions/configure-aws-credentials@v2 - with: - role-to-assume: ${{ secrets.AWS_ROLE_ARN }} - aws-region: ${{ secrets.AWS_REGION }} - - name: Start loadtester - id: start-loadtester - uses: machulav/ec2-github-runner@v2 - with: - mode: start - github-token: ${{ secrets.PTA }} - ec2-image-id: ${{ secrets.LOADTESTER_AMI }} - ec2-instance-type: ${{ secrets.LOADTESTER_INSTANCE_TYPE }} - subnet-id: ${{ secrets.LOADTESTER_AWS_SUBNET_ID }} - security-group-id: ${{ secrets.LOADTESTER_AWS_SG_ID }} - run_k6: - environment: ${{ inputs.environment }} - needs: build - runs-on: "${{ needs.build.outputs.label }}" - outputs: - loadtest_output_success: ${{ steps.run_k6_success.outputs.test_output }} - steps: - - name: Checkout code - uses: actions/checkout@v4.1.1 - - - id: random-number-generator - run: echo "random-number=$(echo $RANDOM)" >> $GITHUB_OUTPUT - shell: bash - - - name: Install JQ - run: | - mkdir -p $HOME/.local/bin - curl -sLo $HOME/.local/bin/jq https://github.com/stedolan/jq/releases/download/jq-1.5/jq-linux64 && chmod +x $HOME/.local/bin/jq - echo "$HOME/.local/bin" >> $GITHUB_PATH - - - name: Download artifact to get rpc url - env: - url: ${{ secrets.LOADTEST_RPC_URL }} - if: ${{ env.url == '' }} - uses: actions/download-artifact@v3 - with: - name: rpc_url - - - name: Set rpc_url - id: set_rpc_url - run: | - if [[ -z "${{ secrets.LOADTEST_RPC_URL }}" ]]; then - echo "rpc_url=http://$(cat rpc_url.txt)" >> $GITHUB_OUTPUT - else - echo "rpc_url=${{ secrets.LOADTEST_RPC_URL }}" >> $GITHUB_OUTPUT - fi - - - id: k6 - name: Run scenario - run: | - /home/ubuntu/k6 run --out statsd loadtest/scenarios/${{ inputs.scenario }}.js - echo "tps_avg=$(cat summary.json | jq -r '.metrics.ethereum_tps.values.avg')" >> $GITHUB_OUTPUT - echo "tps_max=$(cat summary.json | jq -r '.metrics.ethereum_tps.values.max')" >> $GITHUB_OUTPUT - echo "iterations=$(cat summary.json | jq -r '.metrics.iterations.values.count')" >> $GITHUB_OUTPUT - echo "block=$(cat summary.json | jq -r '.metrics.ethereum_block.values.count')" >> $GITHUB_OUTPUT - echo "ttm=$(cat summary.json | jq -r '.metrics.ethereum_time_to_mine.values.avg')" >> $GITHUB_OUTPUT - echo "gas_avg=$(cat summary.json | jq -r '.metrics.ethereum_gas_used.values.avg')" >> $GITHUB_OUTPUT - echo "gas_max=$(cat summary.json | jq -r '.metrics.ethereum_gas_used.values.max')" >> $GITHUB_OUTPUT - env: - K6_STATSD_ENABLE_TAGS: true - RPC_URL: ${{ steps.set_rpc_url.outputs.rpc_url }} - SLACK_WEBHOOK_URL: ${{ secrets.SLACK_PERFORMANCE_WEBHOOK_URL }} - LOADTEST_MNEMONIC: ${{ secrets.LOADTEST_MNEMONIC }} - LOADTEST_DURATION: ${{ inputs.duration }} - - - name: Run tests success - if: success() - id: run_k6_success - run: echo "test_output=true" >> $GITHUB_OUTPUT - - - name: Notify Slack - uses: slackapi/slack-github-action@v1.23.0 - env: - SLACK_WEBHOOK_URL: ${{ secrets.SLACK_PERFORMANCE_WEBHOOK_URL }} - SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK - with: - payload: | - { - "attachments": [ - { - "color": "#03C03C", - "blocks": [ - { - "type": "header", - "text": { - "type": "plain_text", - "text": "K6 Loadtest ${{ inputs.scenario }} :zap:" - } - }, - { - "type": "context", - "elements": [ - { - "type": "mrkdwn", - "text": "Environment: *${{ inputs.environment }}*" - } - ] - }, - { - "type": "context", - "elements": [ - { - "type": "mrkdwn", - "text": "JSON-RPC: *<${{ steps.set_rpc_url.outputs.rpc_url }}|Open URL>*" - } - ] - }, - { - "type": "actions", - "elements": [ - { - "type": "button", - "text": { - "type": "plain_text", - "text": "View workflow run" - }, - "url": "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}" - } - ] - }, - { - "type": "section", - "text": { - "type": "mrkdwn", - "text": "Average TPS: *${{ steps.k6.outputs.tps_avg }}*\nMax TPS: *${{ steps.k6.outputs.tps_max }}*\nTransactions: *${{ steps.k6.outputs.iterations }}*\nBlock Number: *${{ steps.k6.outputs.block }}*\nTime to Mine: *${{ steps.k6.outputs.ttm }}*\nAverage Gas Used: *${{ steps.k6.outputs.gas_avg }}*\nMax Gas Used: *${{ steps.k6.outputs.gas_max }}*" - } - } - ] - } - ] - } - destroy: - environment: ${{ inputs.environment }} - needs: [build, run_k6] - if: always() - runs-on: ubuntu-latest - steps: - - name: Configure AWS credentials - uses: aws-actions/configure-aws-credentials@v2 - with: - role-to-assume: ${{ secrets.AWS_ROLE_ARN }} - aws-region: ${{ secrets.AWS_REGION }} - - name: Stop loadtester - uses: machulav/ec2-github-runner@v2 - with: - mode: stop - github-token: ${{ secrets.PTA }} - label: ${{ needs.build.outputs.label }} - ec2-instance-id: ${{ needs.build.outputs.ec2-instance-id }} \ No newline at end of file diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index 4f4d517a2c..ce0f1cf61a 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -1,213 +1,166 @@ --- name: Nightly Build -on: #yamllint disable-line rule:truthy - workflow_dispatch: +on: # yamllint disable-line rule:truthy + workflow_dispatch: {} schedule: # * is a special character in YAML so you have to quote this string - cron: '0 0 * * *' -permissions: - id-token: write - contents: read - security-events: write - jobs: - build: - name: Build - uses: ./.github/workflows/build.yml - - test: - name: Test - uses: ./.github/workflows/test.yml - needs: build - - e2e-polybft: - name: PolyBFT E2E Tests - uses: ./.github/workflows/e2e-polybft.yml - needs: build - - e2e-legacy: - name: Legacy E2E Tests - uses: ./.github/workflows/e2e-legacy.yaml - needs: build - - property: - name: Polybft Property Tests - uses: ./.github/workflows/property-polybft.yml - needs: build - - fuzz: - name: Fuzz Tests - uses: ./.github/workflows/fuzz-test.yml - needs: build - - loadtest: - name: Build Devnet - uses: ./.github/workflows/deploy.nightly.devnet.yml + check: + name: Check new commits + runs-on: ubuntu-latest + outputs: + new_commit_count: ${{ steps.get_new_commits.outputs.commit_count }} + steps: + - name: Checkout Code + uses: actions/checkout@v4.1.1 + - name: Get new commits + id: get_new_commits + run: echo "commit_count=$(git log --oneline --since '24 hours ago' | wc -l | tr -d ' ')" >> $GITHUB_OUTPUT + ci: + name: CI + uses: ./.github/workflows/ci.yml + needs: check + if: needs.check.outputs.new_commit_count > 0 + with: + build-blade: true + lint: true + unit-test: true + e2e-polybft-test: true + e2e-legacy-test: true + property-polybft-test: true + fuzz-test: true + deploy_network: + name: Deploy Network + uses: ./.github/workflows/deploy-network.yml + needs: check + if: needs.check.outputs.new_commit_count > 0 + with: + environment: nightly + block_gas_limit: "200000000" + block_time: "2" + is_london_fork_active: true + is_bridge_active: true + notification: false secrets: - AWS_REGION: ${{ secrets.AWS_REGION }} AWS_ROLE_ARN: ${{ secrets.AWS_ROLE_ARN }} - TF_VAR_DEPLOYMENT_NAME: ${{ secrets.TF_VAR_DEPLOYMENT_NAME }} - TF_VAR_OWNER: ${{ secrets.TF_VAR_OWNER }} - TF_VAR_BASE_INSTANCE_TYPE: ${{ secrets.TF_VAR_BASE_INSTANCE_TYPE }} - SLACK_PERFORMANCE_WEBHOOK_URL: ${{ secrets.SLACK_PERFORMANCE_WEBHOOK_URL }} - LOADTESTER_AWS_SUBNET_ID: ${{ secrets.LOADTESTER_AWS_SUBNET_ID }} - LOADTESTER_AWS_SG_ID: ${{ secrets.LOADTESTER_AWS_SG_ID }} - LOADTESTER_INSTANCE_TYPE: ${{ secrets.LOADTESTER_INSTANCE_TYPE }} - LOADTEST_MNEMONIC: ${{ secrets.LOADTEST_MNEMONIC }} - VAULT_PASSWORD_FILE: ${{ secrets.VAULT_PASSWORD_FILE }} - LOADTESTER_AMI: ${{ secrets.LOADTESTER_AMI }} - IS_BRIDGE_ACTIVE: ${{ secrets.IS_BRIDGE_ACTIVE }} - PTA: ${{ secrets.PTA }} - BLADE_TAG: ${{ secrets.BLADE_TAG }} - LOG_LEVEL: ${{ secrets.LOG_LEVEL }} + AWS_S3_BLADE_BUCKET: ${{ secrets.AWS_S3_BLADE_BUCKET }} + VAULT_PASSWORD: ${{ secrets.VAULT_PASSWORD }} + load_test_multiple_eoa: + name: Load Test EOA + uses: ./.github/workflows/load-test.yml + needs: deploy_network with: - environment: devnet - - notification: - name: Nightly Notifications - runs-on: ubuntu-latest - needs: [build, test, e2e-polybft, e2e-legacy, property, fuzz, loadtest] + environment: nightly + scenario: EOA + timeout: "220s" + rate: "3000" + timeUnit: "1s" + duration: "10m" + preAllocatedVUs: "60" + maxVUs: "60" + notification: false + secrets: + AWS_ROLE_ARN: ${{ secrets.AWS_ROLE_ARN }} + AWS_S3_BLADE_BUCKET: ${{ secrets.AWS_S3_BLADE_BUCKET }} + AWS_LOADTESTRUNNER_AMI_ID: ${{ secrets.AWS_LOADTESTRUNNER_AMI_ID }} + AWS_LOADTESTRUNNER_SUBNET_ID: ${{ secrets.AWS_LOADTESTRUNNER_SUBNET_ID }} + AWS_LOADTESTRUNNER_SG_ID: ${{ secrets.AWS_LOADTESTRUNNER_SG_ID }} + AWS_LOADTESTRUNNER_MNEMONIC: ${{ secrets.AWS_LOADTESTRUNNER_MNEMONIC }} + PERSONAL_ACCESS_TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN }} + SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} + load_test_multiple_erc20: + name: Load Test ERC20 + uses: ./.github/workflows/load-test.yml + needs: [deploy_network, load_test_multiple_eoa] + with: + environment: nightly + scenario: ERC20 + timeout: "220s" + rate: "1500" + timeUnit: "1s" + duration: "10m" + preAllocatedVUs: "60" + maxVUs: "60" + notification: false + secrets: + AWS_ROLE_ARN: ${{ secrets.AWS_ROLE_ARN }} + AWS_S3_BLADE_BUCKET: ${{ secrets.AWS_S3_BLADE_BUCKET }} + AWS_LOADTESTRUNNER_AMI_ID: ${{ secrets.AWS_LOADTESTRUNNER_AMI_ID }} + AWS_LOADTESTRUNNER_SUBNET_ID: ${{ secrets.AWS_LOADTESTRUNNER_SUBNET_ID }} + AWS_LOADTESTRUNNER_SG_ID: ${{ secrets.AWS_LOADTESTRUNNER_SG_ID }} + AWS_LOADTESTRUNNER_MNEMONIC: ${{ secrets.AWS_LOADTESTRUNNER_MNEMONIC }} + PERSONAL_ACCESS_TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN }} + SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} + destroy_network: + name: Destroy Network + uses: ./.github/workflows/destroy-network.yml + needs: [deploy_network, load_test_multiple_eoa, load_test_multiple_erc20] + if: always() + with: + environment: nightly + logs: true + notification: false + secrets: + AWS_ROLE_ARN: ${{ secrets.AWS_ROLE_ARN }} + AWS_S3_BLADE_BUCKET: ${{ secrets.AWS_S3_BLADE_BUCKET }} + VAULT_PASSWORD: ${{ secrets.VAULT_PASSWORD }} + notification_nightly: + name: Nightly Notification + uses: ./.github/workflows/notification-nightly.yml + needs: [ci, deploy_network, load_test_multiple_eoa, load_test_multiple_erc20, destroy_network] if: success() || failure() - steps: - - name: Notify Slack - uses: slackapi/slack-github-action@v1.23.0 - env: - SLACK_WEBHOOK_URL: ${{ secrets.SLACK_BLADE_GITHUB_URL }} - SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK - with: - payload: | - { - "attachments": [ - { - "color": "${{ needs.build.outputs.workflow_output == '' && needs.test.outputs.workflow_output == '' && needs.e2e-polybft.outputs.workflow_output == '' && needs.e2e-legacy.outputs.workflow_output == '' && needs.property.outputs.workflow_output == '' && needs.fuzz.outputs.workflow_output == '' && needs.loadtest.outputs.workflow_output == '' && '#03C03C' || '#E60012' }}", - "blocks": [ - { - "type": "header", - "text": { - "type": "plain_text", - "text": "Nightly Build ${{ needs.build.outputs.workflow_output == '' && needs.test.outputs.workflow_output == '' && needs.e2e-polybft.outputs.workflow_output == '' && needs.e2e-legacy.outputs.workflow_output == '' && needs.property.outputs.workflow_output == '' && needs.fuzz.outputs.workflow_output == '' && needs.loadtest.outputs.workflow_output == '' && ':rocket:' || ':rotating_light:' }}" - } - }, - { - "type": "context", - "elements": [ - { - "type": "mrkdwn", - "text": "Logs: **" - } - ] - }, - { - "type": "actions", - "elements": [ - { - "type": "button", - "text": { - "type": "plain_text", - "text": "View workflow run" - }, - "url": "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}" - } - ] - } - ] - }, - { - "color": "${{ needs.build.outputs.workflow_output == '' && '#03C03C' || '#E60012' }}", - "blocks": [ - { - "type": "section", - "text": { - "type": "mrkdwn", - "text": "*Build*" - } - } - ] - }, - { - "color": "${{ needs.test.outputs.workflow_output == '' && '#03C03C' || '#E60012' }}", - "blocks": [ - { - "type": "section", - "text": { - "type": "mrkdwn", - "text": "*Unit Tests*" - } - } - ] - }, - { - "color": "${{ needs.property.outputs.workflow_output == '' && '#03C03C' || '#E60012' }}", - "blocks": [ - { - "type": "section", - "text": { - "type": "mrkdwn", - "text": "*Property Tests*" - } - } - ] - }, - { - "color": "${{ needs.e2e-legacy.outputs.workflow_output == '' && '#03C03C' || '#E60012' }}", - "blocks": [ - { - "type": "section", - "text": { - "type": "mrkdwn", - "text": "*Legacy E2E Tests*" - } - } - ] - }, - { - "color": "${{ needs.e2e-polybft.outputs.workflow_output == '' && '#03C03C' || '#E60012' }}", - "blocks": [ - { - "type": "section", - "text": { - "type": "mrkdwn", - "text": "*PolyBFT E2E Tests*" - } - } - ] - }, - { - "color": "${{ needs.fuzz.outputs.workflow_output == '' && '#03C03C' || '#E60012' }}", - "blocks": [ - { - "type": "section", - "text": { - "type": "mrkdwn", - "text": "*Fuzz Tests*" - } - } - ] - }, - { - "color": "${{ needs.loadtest.outputs.workflow_output_loadtest1 == 'true' && '#03C03C' || '#E60012' }}", - "blocks": [ - { - "type": "section", - "text": { - "type": "mrkdwn", - "text": "*Load Tests multiple_EOA*" - } - } - ] - }, - { - "color": "${{ needs.loadtest.outputs.workflow_output_loadtest2 == 'true' && '#03C03C' || '#E60012' }}", - "blocks": [ - { - "type": "section", - "text": { - "type": "mrkdwn", - "text": "*Load Tests multiple_ERC20*" - } - } - ] - } - ] - } + with: + environment: nightly + logs: true + build_blade_output: ${{ needs.ci.outputs.build-blade }} + lint_output: ${{ needs.ci.outputs.lint }} + unit_test_output: ${{ needs.ci.outputs.unit-test }} + e2e_polybft_test_output: ${{ needs.ci.outputs.e2e-polybft-test }} + e2e_legacy_test_output: ${{ needs.ci.outputs.e2e-legacy-test }} + property_polybft_test_output: ${{ needs.ci.outputs.property-polybft-test }} + fuzz_test_output: ${{ needs.ci.outputs.fuzz-test }} + deploy_network_terraform_output: ${{ needs.deploy_network.outputs.terraform_output }} + deploy_network_ansible_output: ${{ needs.deploy_network.outputs.ansible_output }} + load_test_multiple_eoa_output: ${{ needs.load_test_multiple_eoa.outputs.load_test_output }} + load_test_multiple_erc20_output: ${{ needs.load_test_multiple_erc20.outputs.load_test_output }} + destroy_network_logs_output: ${{ needs.destroy_network.outputs.logs_output }} + destroy_network_terraform_output: ${{ needs.destroy_network.outputs.terraform_output }} + secrets: + AWS_S3_BLADE_BUCKET: ${{ secrets.AWS_S3_BLADE_BUCKET }} + SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} + notification_load_test_multiple_eoa: + name: Load Test EOA Notification + uses: ./.github/workflows/notification-load-test.yml + needs: [load_test_multiple_eoa, notification_nightly] + if: (always() && needs.load_test_multiple_eoa.outputs.load_test_output == 'true') + with: + environment: nightly + scenario: EOA + tps_avg: ${{ needs.load_test_multiple_eoa.outputs.tps_avg }} + tps_max: ${{ needs.load_test_multiple_eoa.outputs.tps_max }} + iterations: ${{ needs.load_test_multiple_eoa.outputs.iterations }} + block: ${{ needs.load_test_multiple_eoa.outputs.block }} + ttm: ${{ needs.load_test_multiple_eoa.outputs.ttm }} + gas_avg: ${{ needs.load_test_multiple_eoa.outputs.gas_avg }} + gas_max: ${{ needs.load_test_multiple_eoa.outputs.gas_max }} + secrets: + SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} + notification_load_test_multiple_erc20: + name: Load Test ERC20 Notification + uses: ./.github/workflows/notification-load-test.yml + needs: [load_test_multiple_erc20, notification_nightly] + if: (always() && needs.load_test_multiple_erc20.outputs.load_test_output == 'true') + with: + environment: nightly + scenario: ERC20 + tps_avg: ${{ needs.load_test_multiple_erc20.outputs.tps_avg }} + tps_max: ${{ needs.load_test_multiple_erc20.outputs.tps_max }} + iterations: ${{ needs.load_test_multiple_erc20.outputs.iterations }} + block: ${{ needs.load_test_multiple_erc20.outputs.block }} + ttm: ${{ needs.load_test_multiple_erc20.outputs.ttm }} + gas_avg: ${{ needs.load_test_multiple_erc20.outputs.gas_avg }} + gas_max: ${{ needs.load_test_multiple_erc20.outputs.gas_max }} + secrets: + SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} diff --git a/.github/workflows/notification-deploy-network.yml b/.github/workflows/notification-deploy-network.yml new file mode 100644 index 0000000000..bbae04c529 --- /dev/null +++ b/.github/workflows/notification-deploy-network.yml @@ -0,0 +1,108 @@ +--- +name: Notification - Deploy Network +on: # yamllint disable-line rule:truthy + workflow_call: + inputs: + environment: + description: The environment to run against + type: string + required: true + deploy_network_terraform_output: + description: Deploy Network - Terraform output + type: string + required: true + deploy_network_ansible_output: + description: Deploy Network - Ansible output + type: string + required: true + rpc_url: + description: JSON-RPC URL + type: string + required: true + secrets: + SLACK_WEBHOOK_URL: + required: true + +jobs: + notification: + name: Notification + runs-on: ubuntu-latest + steps: + - name: Short SHA + id: short_sha + run: echo "value=`echo ${{ github.sha }} | cut -c1-7`" >> $GITHUB_OUTPUT + - name: Notify Slack + uses: slackapi/slack-github-action@v1.25.0 + env: + SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} + SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK + green_color: '#03C03C' + red_color: '#E60012' + succeed_bnt: 'primary' + failed_bnt: 'danger' + with: + payload: | + { + "attachments": [ + { + "color": "${{ inputs.deploy_network_terraform_output == '' && inputs.deploy_network_ansible_output == '' && env.green_color || env.red_color }}", + "blocks": [ + { + "type": "header", + "text": { + "type": "plain_text", + "text": "Deploy ${{ inputs.environment }}net" + } + }, + { + "type": "context", + "elements": [ + { + "type": "mrkdwn", + "text": "Environment: *${{ inputs.environment }}*" + } + ] + }, + { + "type": "context", + "elements": [ + { + "type": "mrkdwn", + "text": "Commit: **" + } + ] + }, + { + "type": "context", + "elements": [ + { + "type": "mrkdwn", + "text": "Triggered by: *${{ github.triggering_actor }}*" + } + ] + }, + { + "type": "actions", + "elements": [ + { + "type": "button", + "text": { + "type": "plain_text", + "text": "Workflow Run" + }, + "url": "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}" + }, + { + "type": "button", + "text": { + "type": "plain_text", + "text": "JSON-RPC" + }, + "url": "http://${{ inputs.rpc_url }}" + } + ] + } + ] + } + ] + } diff --git a/.github/workflows/notification-destroy-network.yml b/.github/workflows/notification-destroy-network.yml new file mode 100644 index 0000000000..1f53823765 --- /dev/null +++ b/.github/workflows/notification-destroy-network.yml @@ -0,0 +1,100 @@ +--- +name: Notification - Destroy Network +on: # yamllint disable-line rule:truthy + workflow_call: + inputs: + environment: + description: The environment to run against + type: string + required: true + logs: + description: Upload Logs + type: boolean + required: true + destroy_network_upload_logs: + description: Destory Network - Upload Logs + type: string + required: true + destroy_network_terraform_logs: + description: Deploy Network - Terraform output + type: string + required: true + secrets: + AWS_S3_BLADE_BUCKET: + required: true + SLACK_WEBHOOK_URL: + required: true + +jobs: + notification: + name: Notification + runs-on: ubuntu-latest + steps: + - name: Notify Slack + uses: slackapi/slack-github-action@v1.25.0 + env: + SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} + SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK + green_color: '#03C03C' + red_color: '#E60012' + succeed_bnt: 'primary' + failed_bnt: 'danger' + url: https://s3.console.aws.amazon.com/s3/buckets/${{ secrets.AWS_S3_BLADE_BUCKET }}?region=${{ vars.AWS_REGION }}&prefix=logs/${{ github.run_id }}/ + with: + payload: | + { + "attachments": [ + { + "color": "${{ inputs.destroy_network_upload_logs == '' && inputs.destroy_network_terraform_logs == '' && env.green_color || env.red_color }}", + "blocks": [ + { + "type": "header", + "text": { + "type": "plain_text", + "text": "Destroy ${{ inputs.environment }}net" + } + }, + { + "type": "context", + "elements": [ + { + "type": "mrkdwn", + "text": "Environment: *${{ inputs.environment }}*" + } + ] + }, + { + "type": "context", + "elements": [ + { + "type": "mrkdwn", + "text": "Triggered by: *${{ github.triggering_actor }}*" + } + ] + }, + { + "type": "actions", + "elements": [ + { + "type": "button", + "text": { + "type": "plain_text", + "text": "Workflow Run" + }, + "url": "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}" + }, + { + "type": "button", + "text": { + "type": "plain_text", + "text": "${{ inputs.logs && inputs.destroy_network_upload_logs == '' && 'Logs' || 'No Logs' }}" + }, + "style": "${{ inputs.logs && inputs.destroy_network_upload_logs == '' && env.succeed_bnt || env.failed_bnt }}", + "url": "https://s3.console.aws.amazon.com/s3/buckets/${{ secrets.AWS_S3_BLADE_BUCKET }}?region=${{ vars.AWS_REGION }}&prefix=logs/${{ github.run_id }}/" + } + ] + } + ] + } + ] + } diff --git a/.github/workflows/notification-load-test.yml b/.github/workflows/notification-load-test.yml new file mode 100644 index 0000000000..519cc151af --- /dev/null +++ b/.github/workflows/notification-load-test.yml @@ -0,0 +1,139 @@ +--- +name: Notification - Load Test +on: # yamllint disable-line rule:truthy + workflow_call: + inputs: + environment: + description: The environment to run against + type: string + required: true + scenario: + description: The scenario to run + type: string + required: true + tps_avg: + description: "Average Transactions Per Second" + type: string + required: true + tps_max: + description: "Maximum Transactions Per Second" + type: string + required: true + iterations: + description: "Number Of Transactions" + type: string + required: true + block: + description: "Block Number" + type: string + required: true + ttm: + description: "Time To Mine" + type: string + required: true + gas_avg: + description: "Average Gas Used" + type: string + required: true + gas_max: + description: "Maximum Gas Used" + type: string + required: true + secrets: + SLACK_WEBHOOK_URL: + required: true + +jobs: + notification: + name: Notification + runs-on: ubuntu-latest + steps: + - name: Notify Slack + uses: slackapi/slack-github-action@v1.25.0 + env: + SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} + SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK + green_color: '#03C03C' + succeed_bnt: 'primary' + with: + payload: | + { + "attachments": [ + { + "color": "${{ env.green_color }}", + "blocks": [ + { + "type": "header", + "text": { + "type": "plain_text", + "text": "Load Test: ${{ inputs.scenario }}" + } + }, + { + "type": "context", + "elements": [ + { + "type": "mrkdwn", + "text": "Environment: *${{ inputs.environment }}*" + } + ] + }, + { + "type": "context", + "elements": [ + { + "type": "mrkdwn", + "text": "Triggered by: *${{ github.triggering_actor }}*" + } + ] + }, + { + "type": "actions", + "elements": [ + { + "type": "button", + "text": { + "type": "plain_text", + "text": "Workflow Run" + }, + "url": "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}" + } + ] + }, + { + "type": "section", + "fields": [ + { + "type": "mrkdwn", + "text": "*Average TPS*\n${{ inputs.tps_avg }}" + }, + { + "type": "mrkdwn", + "text": "*Max TPS*\n${{ inputs.tps_max }}" + }, + { + "type": "mrkdwn", + "text": "*Average Gas Used*\n${{ inputs.gas_avg }}" + }, + { + "type": "mrkdwn", + "text": "*Max Gas Used*\n${{ inputs.gas_max }}" + }, + { + "type": "mrkdwn", + "text": "*Transactions*\n${{ inputs.iterations }}" + }, + { + "type": "mrkdwn", + "text": "*Block Number*\n${{ inputs.block }}" + }, + { + "type": "mrkdwn", + "text": "*Time to Mine*\n${{ inputs.ttm }}" + } + ] + } + ] + } + ] + } diff --git a/.github/workflows/notification-nightly.yml b/.github/workflows/notification-nightly.yml new file mode 100644 index 0000000000..df39660a01 --- /dev/null +++ b/.github/workflows/notification-nightly.yml @@ -0,0 +1,203 @@ +--- +name: Notification - Nightly +on: # yamllint disable-line rule:truthy + workflow_call: + inputs: + environment: + description: The environment to run against + type: string + required: true + logs: + description: Upload Logs + type: string + required: true + build_blade_output: + description: Build Blade output + type: string + required: true + lint_output: + description: Lint output + type: string + required: true + unit_test_output: + description: Unit Tests output + type: string + required: true + e2e_polybft_test_output: + description: E2E PolyBFT Tests output + type: string + required: true + e2e_legacy_test_output: + description: E2E Legacy Tests output + type: string + required: true + property_polybft_test_output: + description: Property PolyBFT Tests output + type: string + required: true + fuzz_test_output: + description: Fuzz Tests output + type: string + required: true + deploy_network_terraform_output: + description: Deploy Network - Terraform output + type: string + required: true + deploy_network_ansible_output: + description: Deploy Network - Ansible output + type: string + required: true + load_test_multiple_eoa_output: + description: Load Test multiple_EOA output + type: string + required: true + load_test_multiple_erc20_output: + description: Load Test multiple_ERC20 output + type: string + required: true + destroy_network_logs_output: + description: Deploy Network - Logs output + type: string + required: true + destroy_network_terraform_output: + description: Destroy Network - Terraform output + type: string + required: true + secrets: + AWS_S3_BLADE_BUCKET: + required: true + SLACK_WEBHOOK_URL: + required: true + +jobs: + notification: + name: Notification + runs-on: ubuntu-latest + steps: + - name: Short SHA + id: short_sha + run: echo "value=`echo ${{ github.sha }} | cut -c1-7`" >> $GITHUB_OUTPUT + - name: Notify Slack + uses: slackapi/slack-github-action@v1.25.0 + env: + SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} + SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK + green_color: '#03C03C' + red_color: '#E60012' + succeed_bnt: 'primary' + failed_bnt: 'danger' + with: + payload: | + { + "attachments": [ + { + "color": "${{ inputs.build_blade_output == '' && inputs.lint_output == '' && inputs.unit_test_output == '' && inputs.e2e_polybft_test_output == '' && inputs.e2e_legacy_test_output == '' && inputs.property_polybft_test_output == '' && inputs.fuzz_test_output == '' && inputs.deploy_network_terraform_output == '' && inputs.deploy_network_ansible_output == '' && inputs.load_test_multiple_eoa_output == 'true' && inputs.load_test_multiple_erc20_output == 'true' && inputs.destroy_network_logs_output == '' && inputs.destroy_network_terraform_output == '' && env.green_color || env.red_color }}", + "blocks": [ + { + "type": "header", + "text": { + "type": "plain_text", + "text": "Nightly build" + } + }, + { + "type": "context", + "elements": [ + { + "type": "mrkdwn", + "text": "Environment: *${{ inputs.environment }}*" + } + ] + }, + { + "type": "context", + "elements": [ + { + "type": "mrkdwn", + "text": "Commit: **" + } + ] + }, + { + "type": "context", + "elements": [ + { + "type": "mrkdwn", + "text": "Triggered by: *${{ github.triggering_actor }}*" + } + ] + }, + { + "type": "actions", + "elements": [ + { + "type": "button", + "text": { + "type": "plain_text", + "text": "Workflow Run" + }, + "url": "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}" + }, + { + "type": "button", + "text": { + "type": "plain_text", + "text": "${{ inputs.logs == 'true' && inputs.destroy_network_logs_output == '' && 'Logs' || 'No Logs' }}" + }, + "style": "${{ inputs.logs == 'true' && inputs.destroy_network_logs_output == '' && env.succeed_bnt || env.failed_bnt }}", + "url": "https://s3.console.aws.amazon.com/s3/buckets/${{ secrets.AWS_S3_BLADE_BUCKET }}?region=${{ vars.AWS_REGION }}&prefix=logs/${{ github.run_id }}/" + } + ] + } + ] + }, + { + "color": "${{ inputs.build_blade_output == '' && inputs.lint_output == '' && inputs.unit_test_output == '' && inputs.fuzz_test_output == '' && inputs.e2e_legacy_test_output == '' && inputs.e2e_polybft_test_output == '' && inputs.property_polybft_test_output == '' && env.green_color || env.red_color }}", + "blocks": [ + { + "type": "section", + "text": { + "type": "mrkdwn", + "text": "*CI*\n${{ inputs.build_blade_output == '' && 'Build Blade' || '~Build Blade~' }}, ${{ inputs.lint_output == '' && 'Lint' || '~Lint~' }}, ${{ inputs.unit_test_output == '' && 'Unit Tests' || '~Unit Tests~' }},\n${{ inputs.fuzz_test_output == '' && 'Fuzz Tests' || '~Fuzz Tests~' }}, ${{ inputs.e2e_legacy_test_output == '' && 'E2E Legacy Tests' || '~E2E Legacy Tests~' }},\n${{ inputs.e2e_polybft_test_output == '' && 'E2E PolyBFT Tests' || '~E2E PolyBFT Tests~' }}, ${{ inputs.property_polybft_test_output == '' && 'Property PolyBFT Tests' || '~Property PolyBFT Tests~' }}" + } + } + ] + }, + { + "color": "${{ inputs.deploy_network_terraform_output == '' && inputs.deploy_network_ansible_output == '' && env.green_color || env.red_color }}", + "blocks": [ + { + "type": "section", + "text": { + "type": "mrkdwn", + "text": "*Deploy Network*" + } + } + ] + }, + { + "color": "${{ inputs.load_test_multiple_eoa_output == 'true' && inputs.load_test_multiple_erc20_output == 'true' && env.green_color || env.red_color }}", + "blocks": [ + { + "type": "section", + "text": { + "type": "mrkdwn", + "text": "*Load Tests*\n${{ inputs.load_test_multiple_eoa_output == 'true' && 'EOA' || '~EOA~' }},\n${{ inputs.load_test_multiple_erc20_output == 'true' && 'ERC20' || '~ERC20~' }}" + } + } + ] + }, + { + "color": "${{ inputs.destroy_network_logs_output == '' && inputs.destroy_network_terraform_output == '' && env.green_color || env.red_color }}", + "blocks": [ + { + "type": "section", + "text": { + "type": "mrkdwn", + "text": "*Destroy Network*" + } + } + ] + } + ] + } diff --git a/.github/workflows/property-polybft.yml b/.github/workflows/property-polybft-test.yml similarity index 73% rename from .github/workflows/property-polybft.yml rename to .github/workflows/property-polybft-test.yml index 717384755a..515fe0a024 100644 --- a/.github/workflows/property-polybft.yml +++ b/.github/workflows/property-polybft-test.yml @@ -1,19 +1,15 @@ --- -name: PolyBFT Property tests -on: # yamllint disable-line rule:truthy - push: - branches: - - main - - develop - workflow_dispatch: +name: Property PolyBFT Tests +on: # yamllint disable-line rule:truthy workflow_call: outputs: workflow_output: - description: "Property output" - value: ${{ jobs.build.outputs.property_output_failure }} + description: "Property PolyBFT Tests output" + value: ${{ jobs.polybft_property.outputs.property_output_failure }} jobs: - build: + polybft_property: + name: Run Property PolyBFT Tests runs-on: ubuntu-latest env: E2E_TESTS: true @@ -24,24 +20,20 @@ jobs: steps: - name: Checkout code uses: actions/checkout@v4.1.1 - - name: Install Go uses: actions/setup-go@v5.0.0 with: go-version: 1.20.x - - name: Run tests run: make test-property-polybft - - name: Run tests failed if: failure() id: run_property_failure run: echo "test_output=false" >> $GITHUB_OUTPUT - - name: Archive test logs if: always() uses: actions/upload-artifact@v4.3.0 with: - name: e2e-logs + name: property-polybft-logs path: e2e-logs-*/ retention-days: 30 diff --git a/.github/workflows/test.yml b/.github/workflows/unit-test.yml similarity index 76% rename from .github/workflows/test.yml rename to .github/workflows/unit-test.yml index 811a985c75..2d7cfeab75 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/unit-test.yml @@ -1,37 +1,32 @@ --- -name: Test -on: # yamllint disable-line rule:truthy - workflow_dispatch: +name: Unit Tests +on: # yamllint disable-line rule:truthy workflow_call: outputs: workflow_output: - description: "Unit tests output" - value: ${{ jobs.go_test.outputs.test_output_failure }} + description: "Unit Tests output" + value: ${{ jobs.unit_test.outputs.test_output_failure }} jobs: - go_test: - name: Blade + unit_test: + name: Run Unit Tests runs-on: ubuntu-latest outputs: test_output_failure: ${{ steps.run_tests_failure.outputs.test_output }} steps: - - name: Setup Go - uses: actions/setup-go@v5.0.0 - with: - go-version: 1.20.x - - name: Checkout Code uses: actions/checkout@v4.1.1 with: submodules: recursive fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis - + - name: Setup Go + uses: actions/setup-go@v5.0.0 + with: + go-version: 1.20.x - name: Install Dependencies run: ./setup-ci.sh - - name: Run Go Test - run: make test - + run: make unit-test - name: Run Go Test Failed if: failure() id: run_tests_failure diff --git a/Makefile b/Makefile index c83d4526bd..d3d0fce9c1 100644 --- a/Makefile +++ b/Makefile @@ -56,16 +56,16 @@ lint: check-lint generate-bsd-licenses: check-git ./generate_dependency_licenses.sh BSD-3-Clause,BSD-2-Clause > ./licenses/bsd_licenses.json -.PHONY: test -test: check-go +.PHONY: unit-test +unit-test: check-go go test -race -shuffle=on -coverprofile coverage.out -timeout 20m `go list ./... | grep -v e2e` .PHONY: fuzz-test fuzz-test: check-go ./scripts/fuzzAll -.PHONY: test-e2e -test-e2e: check-go +.PHONY: test-e2e-legacy +test-e2e-legacy: check-go go build -race -o artifacts/blade . env EDGE_BINARY=${PWD}/artifacts/blade go test -v -timeout=30m ./e2e/... @@ -112,9 +112,9 @@ help: @printf " %-35s - %s\n" "build" "Build the project" @printf " %-35s - %s\n" "lint" "Run linters on the codebase" @printf " %-35s - %s\n" "generate-bsd-licenses" "Generate BSD licenses" - @printf " %-35s - %s\n" "test" "Run unit tests" + @printf " %-35s - %s\n" "unit-test" "Run unit tests" @printf " %-35s - %s\n" "fuzz-test" "Run fuzz tests" - @printf " %-35s - %s\n" "test-e2e" "Run end-to-end tests" + @printf " %-35s - %s\n" "test-e2e-legacy" "Run end-to-end Legacy tests" @printf " %-35s - %s\n" "test-e2e-polybft" "Run end-to-end tests for PolyBFT" @printf " %-35s - %s\n" "test-property-polybft" "Run property tests for PolyBFT" @printf " %-35s - %s\n" "compile-blade-contracts" "Compile blade contracts" diff --git a/e2e/README.md b/e2e/README.md index 1bb1eb5e9c..c67963d8e8 100644 --- a/e2e/README.md +++ b/e2e/README.md @@ -4,7 +4,7 @@ The implemented E2E tests start a local instance of polygon-edge. ## Step 1: Run the tests -Use the make file to launch the tests `make test-e2e` +Use the make file to launch the tests `make test-e2e-legacy` ## Manual checks if things are acting funny diff --git a/loadtest/scenarios/multiple_EOA.js b/loadtest/scenarios/multiple_EOA.js index aa5871adb3..3062d0430e 100644 --- a/loadtest/scenarios/multiple_EOA.js +++ b/loadtest/scenarios/multiple_EOA.js @@ -3,21 +3,46 @@ import exec from 'k6/execution'; import { fundTestAccounts } from '../helpers/init.js'; import { textSummary } from 'https://jslib.k6.io/k6-summary/0.0.2/index.js'; -let duration = __ENV.LOADTEST_DURATION; +let setupTimeout = __ENV.SETUP_TIMEOUT; +if (setupTimeout == undefined) { + setupTimeout = "220s" +} + +let rate = __ENV.RATE; +if (rate == undefined) { + rate = "3000" +} + +let timeUnit = __ENV.TIME_UNIT; +if (timeUnit == undefined) { + timeUnit = "1s" +} + +let duration = __ENV.DURATION; if (duration == undefined) { duration = "2m"; } +let preAllocatedVUs = __ENV.PREALLOCATED_VUS; +if (preAllocatedVUs == undefined) { + preAllocatedVUs = "60"; +} + +let maxVUs = __ENV.MAX_VUS; +if (maxVUs == undefined) { + maxVUs = "60"; +} + export const options = { - setupTimeout: '220s', + setupTimeout: setupTimeout, scenarios: { constant_request_rate: { executor: 'constant-arrival-rate', - rate: 3000, - timeUnit: '1s', + rate: parseInt(rate), + timeUnit: timeUnit, duration: duration, - preAllocatedVUs: 60, - maxVUs: 60, + preAllocatedVUs: parseInt(preAllocatedVUs), + maxVUs: parseInt(maxVUs), }, }, }; diff --git a/loadtest/scenarios/multiple_ERC20.js b/loadtest/scenarios/multiple_ERC20.js index 3b291d2ac3..6f25996447 100644 --- a/loadtest/scenarios/multiple_ERC20.js +++ b/loadtest/scenarios/multiple_ERC20.js @@ -3,23 +3,48 @@ import exec from 'k6/execution'; import { fundTestAccounts } from '../helpers/init.js'; import { textSummary } from 'https://jslib.k6.io/k6-summary/0.0.2/index.js'; -let duration = __ENV.LOADTEST_DURATION; +let setupTimeout = __ENV.SETUP_TIMEOUT; +if (setupTimeout == undefined) { + setupTimeout = "220s" +} + +let rate = __ENV.RATE; +if (rate == undefined) { + rate = "1500" +} + +let timeUnit = __ENV.TIME_UNIT; +if (timeUnit == undefined) { + timeUnit = "1s" +} + +let duration = __ENV.DURATION; if (duration == undefined) { duration = "2m"; } +let preAllocatedVUs = __ENV.PREALLOCATED_VUS; +if (preAllocatedVUs == undefined) { + preAllocatedVUs = "60"; +} + +let maxVUs = __ENV.MAX_VUS; +if (maxVUs == undefined) { + maxVUs = "60"; +} + export const options = { - setupTimeout: '220s', - scenarios: { - constant_request_rate: { - executor: 'constant-arrival-rate', - rate: 1500, - timeUnit: '1s', - duration: duration, - preAllocatedVUs: 60, - maxVUs: 60, - }, + setupTimeout: setupTimeout, + scenarios: { + constant_request_rate: { + executor: 'constant-arrival-rate', + rate: parseInt(rate), + timeUnit: timeUnit, + duration: duration, + preAllocatedVUs: parseInt(preAllocatedVUs), + maxVUs: parseInt(maxVUs), }, + }, }; // You can use an existing premined account