-
Notifications
You must be signed in to change notification settings - Fork 76
206 lines (204 loc) · 8.26 KB
/
build-image-and-run-tests.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
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
name: Build test image and run tests
on:
push:
jobs:
build:
if: false
name: 'Build images for tests'
runs-on: ubuntu-20.04
timeout-minutes: 20
steps:
- name: Download Docker images
run: |
DOCKER_IMAGES=('public.ecr.aws/l9h3g6c6/injective-exchange:experimental' 'public.ecr.aws/l9h3g6c6/injective-core:prod' 'public.ecr.aws/l9h3g6c6/injective-trading-bot:latest' 'public.ecr.aws/l9h3g6c6/injective-liquidator-bot:latest')
echo "Downloading all docker images required by standalone network"
echo "Using throttle to avoid Amazon ECR's rate limting."
for image in "${DOCKER_IMAGES[@]}"
do
echo "Pulling image: $image"
attempts=0
until docker pull "$image"
do
[[ attempts -eq 15 ]] && echo "Reached maximum attempts of 15!" && exit 1
echo "Cooling down for 10 seconds."
sleep 10
((attempts++))
echo "aaaagain!"
done
done
echo "All images downloaded"
- name: Export Docker images
run: |
docker save -o /tmp/exchange-image.tar public.ecr.aws/l9h3g6c6/injective-exchange:experimental
docker save -o /tmp/core-image.tar public.ecr.aws/l9h3g6c6/injective-core:prod
docker save -o /tmp/trading-bot-image.tar public.ecr.aws/l9h3g6c6/injective-trading-bot:latest
docker save -o /tmp/liquidator-bot-image.tar public.ecr.aws/l9h3g6c6/injective-liquidator-bot:latest
- name: Upload Exchange image
uses: actions/upload-artifact@v2
with:
name: exchange-image
path: /tmp/exchange-image.tar
- name: Upload Core image
uses: actions/upload-artifact@v2
with:
name: core-image
path: /tmp/core-image.tar
- name: Upload Trading Bot image
uses: actions/upload-artifact@v2
with:
name: trading-bot-image
path: /tmp/trading-bot-image.tar
- name: Upload Liquidator Bot image
uses: actions/upload-artifact@v2
with:
name: liquidator-bot-image
path: /tmp/liquidator-bot-image.tar
- name: Get branch name
id: git-branch-name
uses: EthanSK/git-branch-name-action@v1
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Checkout injective-helix
uses: actions/checkout@master
with:
repository: InjectiveLabs/injective-helix
ref: ${{ github.ref }}
path: ./injective-helix
- name: Build HELIX image
uses: docker/build-push-action@v2
with:
context: ./injective-helix/
file: ./injective-helix/.github/Dockerfile
push: false
tags: public.ecr.aws/l9h3g6c6/injective-helix:${{ env.GIT_BRANCH_NAME }}
outputs: type=docker,dest=/tmp/helix-image.tar
build-args: |
HELIX_FEE_RECIPIENT=${{ secrets.VITE_FEE_RECIPIENT }}
VITE_ALCHEMY_KOVAN_KEY=${{ secrets.VITE_ALCHEMY_KOVAN_KEY }}
VITE_ALCHEMY_SEPOLIA_KEY=${{ secrets.VITE_ALCHEMY_SEPOLIA_KEY }}
- name: Upload HELIX artifact
uses: actions/upload-artifact@v2
with:
name: helix-image
path: /tmp/helix-image.tar
- name: Checkout cypress-ts repo
uses: actions/checkout@master
with:
repository: Tofel/cypress-ts
ref: 'f/trading-form-improvement-new-tests'
token: ${{ secrets.BARTEKS_PAT }}
path: ./cypress-ts
- name: Build Cypress test image
uses: docker/build-push-action@v2
with:
context: ./cypress-ts
file: ./cypress-ts/.github/Dockerfile
push: false
tags: injective-cypress:${{ env.GIT_BRANCH_NAME }}
outputs: type=docker,dest=/tmp/cypress-image.tar
- name: Upload Cypress artifact
uses: actions/upload-artifact@v2
with:
name: cypress-image
path: /tmp/cypress-image.tar
retention-days: 1
run_cypress_tests:
name: 'Run Cypress intergration tests'
runs-on: ubuntu-20.04
timeout-minutes: 80
strategy:
fail-fast: false
matrix:
specs: [
# '/root/cypress/e2e/website/wallets/wallets-connections.cy.ts,/root/cypress/e2e/website/markets/markets-tests.cy.ts,/root/cypress/e2e/website/activity/positions-funding-payment-tests.cy',
# '/root/cypress/e2e/website/portfolio/portfolio-tests.cy.ts',
# '/root/cypress/e2e/website/activity/derivatives-activity-tests.cy.ts',
# '/root/cypress/e2e/website/activity/spot-activity-tests.cy.ts',
# '/root/cypress/e2e/website/activity/positions-activity-tests.cy.ts',
'/root/cypress/e2e/website/trade/trade-perp-orders-tests.cy.ts',
'/root/cypress/e2e/website/trade/trade-spot-orders-tests.cy.ts'
]
needs: build
env:
HELIX_IMAGE_TAG: $GIT_BRANCH_NAME
EXCHANGE_ALCHEMY_API_SEPOLIA_KEY: ${{ secrets.VITE_ALCHEMY_SEPOLIA_KEY }}
EXCHANGE_FEE_PAYER_PK: ${{ secrets.VITE_CI_EXCHANGE_FEE_PAYER_PK }}
CYPRESS_TEST_TAG: $GIT_BRANCH_NAME
CYPRESS_BUILD_ID: '$GIT_BRANCH_NAME-${{ github.sha }}-${{ github.run_attempt }}'
CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }}
steps:
- name: Generate UUID
id: uuid
run: |
echo "::set-output name=UUID::$(uuidgen)"
- name: Get branch name
id: git-branch-name
uses: EthanSK/git-branch-name-action@v1
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Download HELIX artifact
uses: actions/download-artifact@v2
with:
name: helix-image
path: /tmp
- name: Download Cypress artifact
uses: actions/download-artifact@v2
with:
name: cypress-image
path: /tmp
- name: Download Exchange artifact
uses: actions/download-artifact@v2
with:
name: exchange-image
path: /tmp
- name: Download Core artifact
uses: actions/download-artifact@v2
with:
name: core-image
path: /tmp
- name: Download Trading Bot artifact
uses: actions/download-artifact@v2
with:
name: trading-bot-image
path: /tmp
- name: Download Liquidator Bot artifact
uses: actions/download-artifact@v2
with:
name: liquidator-bot-image
path: /tmp
- name: Load Docker images
run: |
ls -al /tmp
docker load --input /tmp/helix-image.tar
docker load --input /tmp/cypress-image.tar
docker load --input /tmp/exchange-image.tar
docker load --input /tmp/core-image.tar
docker load --input /tmp/trading-bot-image.tar
docker load --input /tmp/liquidator-bot-image.tar
- name: Checkout injective-ci-configs
uses: actions/checkout@master
with:
repository: InjectiveLabs/injective-ci-configs
ref: 'f/use_indexer'
token: ${{ secrets.BARTEKS_PAT }}
path: ./injective-ci-configs
- name: Start standalone network
run: |
cd injective-ci-configs/network/standalone
export GENESIS_TWEAK_FUNDING_RATE=false
if [[ "${{ matrix.specs }}" == *funding* ]]; then
echo "Genesis will have a very frequent funding payment interval to ease testing"
export GENESIS_TWEAK_FUNDING_RATE=true
fi
docker-compose -f docker-compose-base.yaml -f docker-compose-helix.yaml build --build-arg IMAGE_TAG=${{ env.HELIX_IMAGE_TAG }}
docker-compose -f docker-compose-base.yaml -f docker-compose-helix.yaml up -d
- name: Execute Cypress tests
run: |
cd injective-ci-configs/network/standalone
export CYPRESS_TEST_TAG=${{ env.GIT_BRANCH_NAME }}
export CYPRESS_RECORD_KEY=8eab12ba-ed7d-4559-8162-b55b65b6653a
export CYPRESS_SPEC_FILE=${{ matrix.specs }}
export CYPRESS_GROUP="${{ steps.uuid.outputs.UUID }}"
export CYPRESS_BUILD_ID="${{ env.CYPRESS_BUILD_ID }}"
export BASE_URL="https://localhost/"
docker-compose -f docker-compose-base.yaml -f docker-compose-helix.yaml -f docker-compose-cypress.yaml run injective-cypress