-
Notifications
You must be signed in to change notification settings - Fork 7
206 lines (183 loc) · 7.21 KB
/
ci.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: CI
on:
push:
pull_request:
workflow_dispatch:
env:
go_version: 1.18.5
jobs:
define-env:
runs-on: ubuntu-latest
permissions:
contents: read
outputs:
IMAGE_TAG: ${{ steps.ct_image_tag.outputs.IMAGE_TAG }}
IMAGE_PATH_0: ghcr.io/${{ github.repository }}
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- id: ct_image_tag
run: |
TAG_NORMALIZED=$(echo ${GITHUB_REF#refs/*/} | sed "s/[^[:alpha:]0-9.-]/-/g")
if [[ "$TAG_NORMALIZED" == "main" ]]; then echo "IMAGE_TAG=latest" >> $GITHUB_OUTPUT
else echo "IMAGE_TAG=$TAG_NORMALIZED" >> $GITHUB_OUTPUT
fi
build-container:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
needs:
- define-env
outputs:
IMAGE_SHA256_0: ${{ steps.image_sha256.outputs.IMAGE_SHA256_0 }}
steps:
- uses: actions/checkout@v3
- uses: docker/setup-qemu-action@v2
- uses: docker/setup-buildx-action@v2
- name: Login to ghcr.io
shell: bash
run: echo ${{ secrets.GITHUB_TOKEN }} | docker login ghcr.io --username ${{ github.actor }} --password-stdin
- name: Build and push container image
shell: bash
run: |
docker build --progress=plain --no-cache --build-arg ROSETTA_SRC=. --tag ${{ needs.define-env.outputs.IMAGE_PATH_0 }}:${{ needs.define-env.outputs.IMAGE_TAG }} -f ./server/Dockerfile .
docker push ${{ needs.define-env.outputs.IMAGE_PATH_0 }}:${{ needs.define-env.outputs.IMAGE_TAG }}
- name: get image sha256
id: image_sha256
run: |
docker pull ${{ needs.define-env.outputs.IMAGE_PATH_0 }}:${{ needs.define-env.outputs.IMAGE_TAG }}
export IMAGE_SHA256_0_FULL=$(docker image inspect --format='{{json .RepoDigests}}' ${{ needs.define-env.outputs.IMAGE_PATH_0 }}:${{ needs.define-env.outputs.IMAGE_TAG }} | jq --raw-output '.[0]')
echo "IMAGE_SHA256_0=${IMAGE_SHA256_0_FULL#*@}" >> $GITHUB_OUTPUT
test-container-localflare-online:
runs-on: ubuntu-latest
needs:
- build-container
- define-env
strategy:
fail-fast: false
matrix:
index: [1, 2, 3, 4, 5]
START_ROSETTA_SERVER_AFTER_BOOTSTRAP: [true, false]
services:
flare_node:
image: ${{ needs.define-env.outputs.IMAGE_PATH_0 }}@${{ needs.build-container.outputs.IMAGE_SHA256_0 }}
ports:
- 9650:9650
- 9651:9651
- 8080:8080
env:
DEBUG: true
NETWORK_ID: localflare
FLARE_LOCAL_TXS_ENABLED: true
START_ROSETTA_SERVER_AFTER_BOOTSTRAP: ${{ matrix.START_ROSETTA_SERVER_AFTER_BOOTSTRAP }}
EXTRA_ARGUMENTS: --staking-tls-cert-file=/app/flare/staking/local/staker1.crt --staking-tls-key-file=/app/flare/staking/local/staker1.key
options: >-
--health-interval 15s
--health-timeout 15s
--health-retries 10
--health-start-period 30s
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v3
with:
go-version: ${{ env.go_version }}
- run: sudo apt update -y && sudo apt install curl -y
- name: Wait for go-flare to bind to port
shell: bash
run: curl -s --retry 6 --retry-delay 10 --retry-connrefused http://localhost:9650 || exit 1
- name: Import testnet
shell: bash
run: |
curl -s -o /tmp/test_pchain_import.sh https://raw.githubusercontent.com/flare-foundation/go-flare/114017731f4f8f6192a4df2748da914c0257e16b/avalanchego/scripts/test_pchain_import.sh
sed -i 's/localhost/127.0.0.1/g' /tmp/test_pchain_import.sh
sed -i 's/ | jq .//g' /tmp/test_pchain_import.sh
bash /tmp/test_pchain_import.sh
while [[ "$(curl -X POST --data '{ "jsonrpc": "2.0", "method": "platform.getHeight", "params": {}, "id": 1 }' -H 'content-type:application/json;' 127.0.0.1:9650/ext/bc/P | jq -r .result.height)" != "2" ]]
do
echo "Block height not reached.. Block Height:" $(curl -X POST --data '{ "jsonrpc": "2.0", "method": "platform.getHeight", "params": {}, "id": 1 }' -H 'content-type:application/json;' 127.0.0.1:9650/ext/bc/P | jq -r .result.height)
sleep 1
done
- name: Wait for rosetta to bind to port
shell: bash
run: curl -s --retry 6 --retry-delay 10 --retry-connrefused http://localhost:8080 || exit 1
- name: List networks Rosetta API lists
shell: bash
run: |
curl -s --location --request POST 'http://127.0.0.1:8080/network/list' \
--header 'Content-Type: application/json' \
--data-raw '{ "metadata" : {} }' \
--fail || exit 1
- name: Install rosetta cli
shell: bash
run: |
mkdir -p /tmp/rosetta
curl -o /tmp/rosetta/install.sh -sSfL https://raw.githubusercontent.com/coinbase/rosetta-cli/d5ccb7c5cdfc60cd23ff7cb010dea1bf19f80547/scripts/install.sh
bash /tmp/rosetta/install.sh -b /tmp/rosetta/
- name: Run rosetta-cli check:construction
timeout-minutes: 5
shell: bash
run: |
pushd server/rosetta-cli-conf/localflare
/tmp/rosetta/rosetta-cli --configuration-file=./config.json check:construction
popd
test-container-localflare-offline:
runs-on: ubuntu-latest
needs:
- build-container
- define-env
strategy:
fail-fast: false
matrix:
index: [1, 2, 3, 4, 5]
services:
flare_node:
image: ${{ needs.define-env.outputs.IMAGE_PATH_0 }}@${{ needs.build-container.outputs.IMAGE_SHA256_0 }}
ports:
- 9650:9650
- 9651:9651
- 8080:8080
env:
DEBUG: true
NETWORK_ID: localflare
FLARE_LOCAL_TXS_ENABLED: true
MODE: offline
EXTRA_ARGUMENTS: --staking-tls-cert-file=/app/flare/staking/local/staker1.crt --staking-tls-key-file=/app/flare/staking/local/staker1.key
options: >-
--health-interval 15s
--health-timeout 15s
--health-retries 10
--health-start-period 30s
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v3
with:
go-version: ${{ env.go_version }}
- run: sudo apt update -y && sudo apt install curl -y
- name: Wait for rosetta to bind to port
shell: bash
run: curl -s --retry 6 --retry-delay 10 --retry-connrefused http://localhost:8080 || exit 1
- name: List networks Rosetta API lists
shell: bash
run: |
curl -s --location --request POST 'http://127.0.0.1:8080/network/list' \
--header 'Content-Type: application/json' \
--data-raw '{ "metadata" : {} }' \
--fail || exit 1
test-make_build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v3
with:
go-version: ${{ env.go_version }}
- run: (cd server && make build)
test-make_test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-go@v2
with:
go-version: ${{ env.go_version }}
- run: (cd server && make test)