Skip to content

Basic&EVM tests / schedule #3327

Basic&EVM tests / schedule

Basic&EVM tests / schedule #3327

Workflow file for this run

name: "Basic&EVM tests"
run-name: Basic&EVM tests / ${{ github.event.pull_request.title || github.event_name }}
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
on:
schedule:
- cron: "0 1 * * 0,1,2,3,4"
- cron: "0 2 * * 0,1,2,3,4"
pull_request:
types: [ opened, reopened, synchronize ]
workflow_dispatch:
inputs:
network:
type: choice
default: terraform
required: true
description: "Stand name"
options:
- terraform
- night-stand
- devnet
- mainnet
numprocesses:
type: choice
default: 8
required: true
description: "Number of parallel jobs"
options:
- 2
- 4
- 8
- 12
- auto
generate_cost_report:
type: boolean
default: false
required: false
description: "Flag defining whether cost report should be generated"
env:
NETWORK: ${{ github.event.inputs.network || 'terraform' }}
NUMPROCESSES: ${{ github.event.inputs.numprocesses || 8 }}
BUILD_URL: "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"
SOLANA_URL: "${{ secrets.SOLANA_URL }}"
FAUCET_URL: "${{ secrets.DEVNET_FAUCET_URL }}"
IMAGE: ${{ github.repository_owner }}/neon_tests
DOCKER_HUB_ORG_NAME: ${{ github.repository_owner }}
GENERATE_COST_REPORT: ${{ github.event.inputs.generate_cost_report || 'false' }}
jobs:
dockerize:
name: Dockerize neon tests
if: ${{ github.ref_name != 'develop'}}
runs-on: ["self-hosted", "k8s-prod"]
steps:
- uses: actions/checkout@v4
- name: Dockerize neon tests
uses: ./.github/actions/dockerize-neon-tests
with:
image_tag: ${{ github.sha }}
docker_username: ${{ secrets.DOCKER_USERNAME }}
docker_password: ${{ secrets.DOCKER_PASSWORD }}
image_name: ${{ env.IMAGE }}
docker_hub_org_name: ${{ env.DOCKER_HUB_ORG_NAME }}
- name: "Define image tag"
id: image_tag
uses: ./.github/actions/define-image-tag
outputs:
tag: ${{ steps.image_tag.outputs.tag }}
prepare-env-proxy:
name: Prepare environment for proxy tests
runs-on: ["self-hosted", "k8s-prod"]
if: always()
steps:
- uses: hashicorp/setup-terraform@v3
- uses: actions/setup-node@v4
with:
node-version: 16
- name: Setup `terraform` by cron schedule
id: setup_terraform_stand
if: github.event.schedule=='0 1 * * 0,1,2,3,4'
run: |
echo "NETWORK=terraform" >> $GITHUB_ENV
- name: Setup `devnet` by cron schedule
if: github.event.schedule=='0 2 * * 0,1,2,3,4'
run: |
echo "NETWORK=devnet" >> $GITHUB_ENV
- uses: actions/checkout@v4
- name: "Prepare terraform stand"
id: prepare_terraform
if: ${{ env.NETWORK == 'terraform' }}
timeout-minutes: 15
env:
AWS_ACCESS_KEY_ID: ${{secrets.AWS_ACCESS_KEY_ID}}
AWS_DEFAULT_REGION: ${{secrets.AWS_DEFAULT_REGION}}
AWS_SECRET_ACCESS_KEY: ${{secrets.AWS_SECRET_ACCESS_KEY}}
HCLOUD_TOKEN: ${{secrets.HCLOUD_TOKEN}}
TFSTATE_BUCKET: ${{vars.TFSTATE_BUCKET}}
TFSTATE_KEY: ${{vars.TFSTATE_KEY_PREFIX}}-${{ github.run_number }}
TFSTATE_REGION: ${{vars.TFSTATE_REGION}}
uses: ./.github/actions/create-tf-stand
with:
ci_stands_key_hcloud: ${{ secrets.CI_STANDS_KEY_HCLOUD }}
outputs:
proxy_ip: ${{ steps.prepare_terraform.outputs.proxy_ip }}
solana_ip: ${{ steps.prepare_terraform.outputs.solana_ip }}
network: ${{ env.NETWORK }}
run-evm-tests:
name: Run EVM tests
runs-on: ["self-hosted", "k8s-prod"]
needs:
- dockerize
env:
DOCKER_PROJECT_NAME: "evm-tests-${{ github.run_number }}-${{ github.run_attempt }}"
steps:
- uses: actions/checkout@v4
if: ${{ env.NETWORK != 'devnet' }}
with:
fetch-depth: 0
- name: Install python requirements
if: ${{ env.NETWORK != 'devnet' }}
uses: ./.github/actions/python-requirements
- name: Set evm image tag
if: ${{ env.NETWORK != 'devnet' }}
id: share
run: |
env_tag=$(python3 ./clickfile.py infra get-stand-param \
--current_branch "${{ github.ref_name }}" \
--head_branch "${{ github.head_ref }}" \
--base_branch "${{ github.base_ref }}" \
--param "evm_tag")
evm_branch=$(python3 ./clickfile.py infra get-stand-param \
--current_branch "${{ github.ref_name }}" \
--head_branch "${{ github.head_ref }}" \
--base_branch "${{ github.base_ref }}" \
--param "evm_branch")
echo "evm_tag=$env_tag"
echo "evm_tag=$env_tag" >> $GITHUB_OUTPUT
echo "evm_branch=$evm_branch"
echo "evm_branch=$evm_branch" >> $GITHUB_OUTPUT
- name: Run tests
if: ${{ env.NETWORK != 'devnet' }}
env:
NEON_TESTS_IMAGE: ${{ env.IMAGE }}:${{ needs.dockerize.outputs.tag }}
EVM_LOADER_IMAGE: ${{ github.repository_owner }}/evm_loader:${{ steps.share.outputs.evm_tag }}
run: |
curl -O https://raw.githubusercontent.com/${{ github.repository_owner }}/neon-evm/${{ steps.share.outputs.evm_branch }}/ci/docker-compose-ci.yml
docker-compose -p ${{env.DOCKER_PROJECT_NAME}} -f docker-compose-ci.yml pull
docker-compose -p ${{env.DOCKER_PROJECT_NAME}} -f docker-compose-ci.yml up -d
docker exec -i ${{env.DOCKER_PROJECT_NAME}}-tests-1 bash -c "python3 clickfile.py run evm --numprocesses 8 --network docker_net"
- name: Set failed test group to evm
if: failure()
run: echo "FAILED_TEST_GROUP=evm" >> $GITHUB_ENV
- name: "Generate allure report"
if: always() && ${{ env.NETWORK != 'devnet' }}
uses: ./.github/actions/generate-allure-report
with:
container: ${{env.DOCKER_PROJECT_NAME}}-tests-1
network: docker_net
aws_access_key_id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws_secret_access_key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
tests_name: evm
- name: Stop and remove containers
env:
NEON_TESTS_IMAGE: ${{ env.IMAGE }}:${{ needs.dockerize.outputs.tag }}
EVM_LOADER_IMAGE: ${{ github.repository_owner }}/evm_loader:${{ steps.share.outputs.evm_tag }}
if: always() && env.NETWORK != 'devnet'
run: |
docker-compose -p ${{env.DOCKER_PROJECT_NAME}} -f docker-compose-ci.yml down
- name: Cancel the build if job failed
if: failure()
uses: "andymckay/[email protected]"
run-proxy-tests:
name: Run basic tests
needs:
- dockerize
- prepare-env-proxy
runs-on: ["self-hosted", "k8s-prod"]
env:
SOLANA_IP: ${{ needs.prepare-env-proxy.outputs.solana_ip }}
PROXY_IP: ${{ needs.prepare-env-proxy.outputs.proxy_ip }}
NETWORK: ${{ needs.prepare-env-proxy.outputs.network }}
CONTAINER: basic-tests-${{ github.run_id }}
if: |
always() &&
!contains(needs.*.result, 'failure') &&
!contains(needs.*.result, 'cancelled')
steps:
- uses: actions/checkout@v4
- name: Run docker container
run: |
docker pull ${{ env.IMAGE }}:${{ needs.dockerize.outputs.tag }}
docker run -i -d -e CI -e GITHUB_RUN_ID -e GITHUB_WORKFLOW \
-e ETH_BANK_PRIVATE_KEY_MAINNET=${{ secrets.ETH_BANK_PRIVATE_KEY_MAINNET }} \
-e BANK_PRIVATE_KEY_MAINNET=${{ secrets.BANK_PRIVATE_KEY_MAINNET }} \
-e BANK_PRIVATE_KEY=${{ secrets.BANK_PRIVATE_KEY }} \
-e SOLANA_URL \
-e SOLANA_IP -e PROXY_IP \
--name=${{ env.CONTAINER }} ${{ env.IMAGE }}:${{ needs.dockerize.outputs.tag }} /bin/bash
- name: Run basic proxy tests
timeout-minutes: 60
run: |
CMD="python3 ./clickfile.py run basic --network ${{ env.NETWORK }} --numprocesses ${{ env.NUMPROCESSES }}"
if [[ "${{ env.GENERATE_COST_REPORT }}" == "true" ]]; then
CMD="$CMD --cost_reports_dir reports/cost_reports"
fi
docker exec -i ${{ env.CONTAINER }} /bin/bash -c "export DEVNET_FAUCET_URL=${{ env.FAUCET_URL }} && $CMD"
- name: Set failed test group to basic
if: failure()
run: echo "FAILED_TEST_GROUP=basic" >> $GITHUB_ENV
- name: Copy cost reports from container
if: ${{ env.GENERATE_COST_REPORT == 'true' }}
run: |
mkdir -p ./reports/cost_reports/ && \
docker cp ${{ env.CONTAINER }}:/opt/neon-tests/reports/cost_reports/. ./reports/cost_reports/
- name: Upload cost reports as artifacts
if: ${{ env.GENERATE_COST_REPORT == 'true' }}
uses: actions/upload-artifact@v4
with:
name: cost-reports
path: reports/cost_reports/**.json
- name: Save Cost Reports to cost_reports.md and echo to Summary
if: ${{ env.GENERATE_COST_REPORT == 'true' }}
run: |
docker exec -i -e NETWORK=${{ env.NETWORK }} ${{ env.CONTAINER }} \
python3 ./clickfile.py dapps save_dapps_cost_report_to_md \
--directory reports/cost_reports && \
docker exec -i ${{ env.CONTAINER }} cat cost_reports.md >> $GITHUB_STEP_SUMMARY
- name: "Generate allure report"
if: always()
uses: ./.github/actions/generate-allure-report
with:
container: ${{ env.CONTAINER }}
network: ${{ env.NETWORK }}
aws_access_key_id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws_secret_access_key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
tests_name: basic
- name: Remove docker container
if: always()
run: docker rm -f ${{ env.CONTAINER }}
destroy:
name: Destroy stand
runs-on: ["self-hosted", "k8s-prod"]
needs: [ prepare-env-proxy, run-proxy-tests]
if: always() && needs.prepare-env-proxy.outputs.network == 'terraform'
steps:
- uses: actions/checkout@v4
- uses: hashicorp/setup-terraform@v3
- uses: actions/setup-node@v4
with:
node-version: 16
- name: "Destroy stand"
env:
AWS_ACCESS_KEY_ID: ${{secrets.AWS_ACCESS_KEY_ID}}
AWS_DEFAULT_REGION: ${{secrets.AWS_DEFAULT_REGION}}
AWS_SECRET_ACCESS_KEY: ${{secrets.AWS_SECRET_ACCESS_KEY}}
HCLOUD_TOKEN: ${{secrets.HCLOUD_TOKEN}}
TFSTATE_BUCKET: ${{vars.TFSTATE_BUCKET}}
TFSTATE_KEY: ${{vars.TFSTATE_KEY_PREFIX}}-${{ github.run_number }}
TFSTATE_REGION: ${{vars.TFSTATE_REGION}}
PROXY_IP: ${{ needs.prepare-env-proxy.outputs.proxy_ip }}
SOLANA_IP: ${{ needs.prepare-env-proxy.outputs.solana_ip }}
uses: ./.github/actions/destroy-tf-stand
with:
ci_stands_key_hcloud: ${{ secrets.CI_STANDS_KEY_HCLOUD }}
send-notification:
name: Send notification on failure
needs:
- run-proxy-tests
- run-evm-tests
runs-on: ["self-hosted", "k8s-prod"]
steps:
- uses: actions/checkout@v4
- name: "Notify on failure."
if: failure() && github.ref_name == 'develop'
run: |
docker exec -i ${{ env.CONTAINER }} \
python3 ./clickfile.py send-notification -u ${{ secrets.SLACK_QA_CHANNEL_URL }} \
-b ${{ env.BUILD_URL }} --network ${{ env.NETWORK }} --test-group ${{ env.FAILED_TEST_GROUP }}