Basic tests / use branch name as tags for images #1580
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: "Basic tests" | |
run-name: Basic tests / ${{ github.event.pull_request.title || github.event_name }} | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref }} | |
cancel-in-progress: true | |
on: | |
schedule: | |
- cron: "0 23,2 * * 0,1,2,3,4" | |
- cron: "0 4 * * 0,1,2,3,4" | |
pull_request: | |
types: [ opened, reopened, synchronize ] | |
workflow_dispatch: | |
inputs: | |
network: | |
type: choice | |
default: night-stand | |
required: true | |
description: "Stand name" | |
options: | |
- terraform | |
- night-stand | |
- devnet | |
numprocesses: | |
type: choice | |
default: 8 | |
required: true | |
description: "Number of parallel jobs" | |
options: | |
- 2 | |
- 4 | |
- 8 | |
- 12 | |
- auto | |
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 }}" | |
IMAGE: neonlabsorg/neon_tests | |
CONTAINER: basic-${{ github.run_id }} | |
jobs: | |
dockerize: | |
if: ${{ github.ref_name != 'develop'}} | |
runs-on: ubuntu-20.04 | |
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 }} | |
prepare-env: | |
runs-on: ubuntu-20.04 | |
if: always() | |
steps: | |
- name: Setup `night-stand` by cron schedule | |
id: setup_night_stand | |
if: github.event.schedule=='0 23,2 * * 0,1,2,3,4' | |
run: | | |
echo "NETWORK=night-stand" >> $GITHUB_ENV | |
- name: Setup `devnet` by cron schedule | |
id: setup_devnet | |
if: github.event.schedule=='0 4 * * 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' }} | |
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_PREFIX: ${{vars.TFSTATE_KEY_PREFIX}} | |
TFSTATE_REGION: ${{vars.TFSTATE_REGION}} | |
TF_VAR_ci_pp_solana_url: ${{ secrets.SOLANA_URL }} | |
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 }} | |
tests: | |
name: "Basic tests" | |
needs: | |
- dockerize | |
- prepare-env | |
runs-on: neon-hosted | |
env: | |
SOLANA_IP: ${{ needs.prepare-env.outputs.solana_ip }} | |
PROXY_IP: ${{ needs.prepare-env.outputs.proxy_ip }} | |
NETWORK: ${{ needs.prepare-env.outputs.network }} | |
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 CI -e GITHUB_RUN_ID -e GITHUB_WORKFLOW -e BANK_PRIVATE_KEY=${{ secrets.BANK_PRIVATE_KEY }} \ | |
-e SOLANA_URL \ | |
-e SOLANA_IP -e PROXY_IP \ | |
--name=${{ env.CONTAINER }} ${{ env.IMAGE }}:${{ steps.image_tag.outputs.tag }} /bin/bash | |
- name: "Run basic tests" | |
timeout-minutes: 60 | |
id: basic | |
run: | | |
docker exec -i ${{ env.CONTAINER }} \ | |
python3 ./clickfile.py run basic -n ${{ env.NETWORK }} --numprocesses ${{ env.NUMPROCESSES }} | |
- name: "Notify on failure." | |
if: failure() | |
run: | | |
docker exec -i ${{ env.CONTAINER }} \ | |
python3 ./clickfile.py send-notification -u ${{ secrets.SLACK_QA_CHANNEL_URL }} \ | |
-b ${{ env.BUILD_URL }} -n ${{ env.NETWORK }} | |
- name: "Generate allure report" | |
if: always() | |
id: requirements | |
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: | |
runs-on: ubuntu-20.04 | |
needs: [ prepare-env, tests ] | |
if: always() && needs.prepare-env.outputs.network == 'terraform' | |
steps: | |
- uses: actions/checkout@v4 | |
- 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_PREFIX: ${{vars.TFSTATE_KEY_PREFIX}} | |
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 }} | |