Operator economy #287
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: night-stand | |
required: true | |
description: "Stand name" | |
options: | |
- night-stand | |
- 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 | |
env: | |
NETWORK: night-stand | |
RUNNER: neon-hosted | |
BUILD_URL: "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}" | |
IMAGE: neonlabsorg/neon_tests | |
CONTAINER: economy-${{ 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 }} | |
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 6 * * *' | |
run: | | |
echo "NETWORK=night-stand" >> $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 }}" ) | |
echo "Network: ${NETWORK}" | |
echo "Runner: ${RUNNER}" | |
echo "Build url: ${{ env.BUILD_URL }}" | |
echo "network=${NETWORK}" >> $GITHUB_OUTPUT | |
echo "runner=${RUNNER}" >> $GITHUB_OUTPUT | |
echo "jobs=${JOBS_NUMBER}" >> $GITHUB_OUTPUT | |
outputs: | |
network: ${{ steps.setup.outputs.network }} | |
runner: ${{ steps.setup.outputs.runner }} | |
tests: | |
name: "Operator tests" | |
needs: | |
- prepare-env | |
- dockerize | |
runs-on: ${{ needs.prepare-env.outputs.runner }} | |
env: | |
NETWORK: ${{ needs.prepare-env.outputs.network }} | |
RUNNER: ${{ needs.prepare-env.outputs.runner }} | |
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 --name=${{ env.CONTAINER }} ${{ env.IMAGE }}:${{ steps.image_tag.outputs.tag }} /bin/bash | |
- name: "Run economy tests" | |
id: economy | |
run: | | |
docker exec -i ${{ env.CONTAINER }} python3 ./clickfile.py run economy -n ${{ env.NETWORK }} | |
- 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 }} | |
- name: "Generate allure report" | |
id: requirements | |
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: Remove docker container | |
if: always() | |
run: docker rm -f ${{ env.CONTAINER }} |