Skip to content

Basic tests / fix dockerize #2205

Basic tests / fix dockerize

Basic tests / fix dockerize #2205

Workflow file for this run

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:
- night-stand
- devnet
- private-devnet
runner:
type: choice
default: ubuntu-20.04
required: true
description: "Where to run tests (our runner or github)"
options:
- neon-hosted
- aws-hosted
- ubuntu-20.04
numprocesses:
type: choice
default: 4
required: true
description: "Number of parallel jobs"
options:
- 2
- 4
- 8
- 12
- auto
env:
NETWORK: night-stand
RUNNER: neon-hosted
BUILD_URL: "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"
SOLANA_URL: "${{ secrets.SOLANA_URL }}"
NUMPROCESSES: 4
IMAGE: ${{ vars.DOCKERHUB_ORG_NAME }}/neon_tests
CONTAINER: basic-${{ github.run_id }}
jobs:
dockerize:
if: ${{ github.ref_name != 'develop'}}
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v3
- name: "Dockerize neon tests"
id: requirements
uses: ./.github/actions/dockerize-neon-tests
with:
image_tag: ${{ github.sha }}
org_name: ${{ vars.DOCKERHUB_ORG_NAME }}
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
- name: Setup env
id: setup
run: |
# $1 - inputs
# $2 - env.VAR
function setVar {
if [ -z "$1" ]
then
RESULT="$2"
else
RESULT="$1"
fi
echo $RESULT
}
NETWORK=$( setVar "${{ github.event.inputs.network }}" "${{ env.NETWORK }}" )
RUNNER=$( setVar "${{ github.event.inputs.runner }}" "${{ env.RUNNER }}" )
NUMPROCESSES=$( setVar "${{ github.event.inputs.numprocesses }}" "2" )
echo "Network: ${NETWORK}"
echo "Runner: ${RUNNER}"
echo "Numprocesses: ${NUMPROCESSES}"
echo "Build url: ${{ env.BUILD_URL }}"
echo "network=${NETWORK}" >> $GITHUB_OUTPUT
echo "runner=${RUNNER}" >> $GITHUB_OUTPUT
echo "jobs=${JOBS_NUMBER}" >> $GITHUB_OUTPUT
echo "numprocesses=${NUMPROCESSES}" >> $GITHUB_OUTPUT
outputs:
network: ${{ steps.setup.outputs.network }}
runner: ${{ steps.setup.outputs.runner }}
numprocesses: ${{ steps.setup.outputs.numprocesses }}
tests:
name: "Basic tests"
needs:
- dockerize
- prepare-env
runs-on: ${{ needs.prepare-env.outputs.runner }}
env:
NETWORK: ${{ needs.prepare-env.outputs.network }}
RUNNER: ${{ needs.prepare-env.outputs.runner }}
NUMPROCESSES: ${{ needs.prepare-env.outputs.numprocesses }}
if: |
always() &&
!contains(needs.*.result, 'failure') &&
!contains(needs.*.result, 'cancelled')
steps:
- uses: actions/checkout@v3
- 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 PROXY_URL -e SOLANA_URL --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 ${{ needs.prepare-env.outputs.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 }}