-
Notifications
You must be signed in to change notification settings - Fork 7
159 lines (155 loc) · 5.27 KB
/
basic.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
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 }}