Operator economy #593
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: "Operator economy" | |
on: | |
schedule: | |
- cron: "0 6 * * 0,1,2,3,4" | |
workflow_dispatch: | |
inputs: | |
network: | |
type: choice | |
default: terraform | |
required: true | |
description: "Stand name" | |
options: | |
- terraform | |
- night-stand | |
env: | |
NETWORK: ${{ github.event.inputs.network || 'terraform' }} | |
BUILD_URL: "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}" | |
IMAGE: ${{ github.repository_owner }}/neon_tests | |
CONTAINER: "economy-${{ github.run_id }}" | |
DOCKER_HUB_ORG_NAME: ${{ github.repository_owner }} | |
jobs: | |
dockerize: | |
if: ${{ github.ref_name != 'develop'}} | |
runs-on: ["self-hosted", "k8s-prod"] | |
steps: | |
- uses: actions/checkout@v4 | |
- name: "Dockerize neon tests" | |
id: requirements | |
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 }} | |
prepare-env: | |
runs-on: ["self-hosted", "k8s-prod"] | |
if: always() | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: hashicorp/setup-terraform@v3 | |
- uses: actions/setup-node@v4 | |
with: | |
node-version: 16 | |
- name: "Prepare terraform stand" | |
id: prepare_terraform | |
if: ${{ env.NETWORK == 'terraform' }} | |
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 }} | |
use_real_price: "1" | |
timeout-minutes: 15 | |
outputs: | |
proxy_ip: ${{ steps.prepare_terraform.outputs.proxy_ip }} | |
solana_ip: ${{ steps.prepare_terraform.outputs.solana_ip }} | |
network: ${{ env.NETWORK }} | |
tests: | |
name: "Operator tests" | |
needs: | |
- prepare-env | |
- dockerize | |
runs-on: ["self-hosted", "k8s-prod"] | |
env: | |
NETWORK: ${{ needs.prepare-env.outputs.network }} | |
SOLANA_IP: ${{ needs.prepare-env.outputs.solana_ip }} | |
PROXY_IP: ${{ needs.prepare-env.outputs.proxy_ip }} | |
if: | | |
always() && | |
!contains(needs.*.result, 'failure') && | |
!contains(needs.*.result, 'cancelled') | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Define image tag | |
id: image_tag | |
uses: ./.github/actions/define-image-tag | |
- name: Run docker container | |
run: | | |
docker pull ${{ env.IMAGE }}:${{ steps.image_tag.outputs.tag }} | |
docker run -i -d -e SOLANA_IP -e PROXY_IP -e CI \ | |
--name=${{ env.CONTAINER }} ${{ env.IMAGE }}:${{ steps.image_tag.outputs.tag }} \ | |
/bin/bash | |
- name: Run economy tests | |
run: | | |
docker exec -i ${{ env.CONTAINER }} python3 ./clickfile.py run economy --network ${{ env.NETWORK }} | |
- name: "Generate allure report" | |
uses: ./.github/actions/generate-allure-report | |
if: always() | |
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: economy | |
- 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 }} \ | |
--test-group economy | |
- name: Remove docker container | |
if: always() | |
run: docker rm -f ${{ env.CONTAINER }} | |
destroy: | |
runs-on: ["self-hosted", "k8s-prod"] | |
needs: [ prepare-env, tests ] | |
if: always() && needs.prepare-env.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.outputs.proxy_ip }} | |
SOLANA_IP: ${{ needs.prepare-env.outputs.solana_ip }} | |
uses: ./.github/actions/destroy-tf-stand | |
with: | |
ci_stands_key_hcloud: ${{ secrets.CI_STANDS_KEY_HCLOUD }} | |