-
Notifications
You must be signed in to change notification settings - Fork 279
284 lines (273 loc) · 9.77 KB
/
iroha2-dev-pr.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
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
name: I2::Dev::Tests
on:
pull_request:
branches: [main]
paths:
- '**.rs'
- '**.json'
- '**.toml'
- '**.lock'
- '**.py'
- '.github/workflows/iroha2-dev-pr.yml'
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
CARGO_TERM_COLOR: always
IROHA_CLI_DIR: "/__w/${{ github.event.repository.name }}/${{ github.event.repository.name }}/test"
DOCKER_COMPOSE_PATH: defaults
jobs:
consistency:
runs-on: [self-hosted, Linux, iroha2]
container:
image: hyperledger/iroha2-ci:nightly-2024-09-09
steps:
- uses: actions/checkout@v4
- name: Check genesis.json
if: always()
run: ./scripts/tests/consistency.sh genesis
- name: Check schema.json
if: always()
run: ./scripts/tests/consistency.sh schema
- name: Check Docker Compose configurations
if: always()
run: ./scripts/tests/consistency.sh docker-compose
fmt_and_clippy:
runs-on: [self-hosted, Linux, iroha2]
container:
image: hyperledger/iroha2-ci:nightly-2024-09-09
steps:
- uses: actions/checkout@v4
- name: Format
run: cargo fmt --all -- --check
- name: Lints without features
if: always()
run: cargo clippy --workspace --benches --tests --examples --no-default-features --quiet
- name: Lints with all features enabled
if: always()
run: cargo clippy --workspace --benches --tests --examples --all-features --quiet --message-format=json | tee clippy.json
- name: Documentation
if: always()
run: cargo doc --no-deps --quiet
- name: Upload clippy report artifact
uses: actions/upload-artifact@v4
with:
name: report-clippy
path: clippy.json
build_executor:
runs-on: ubuntu-latest
container:
image: hyperledger/iroha2-ci:nightly-2024-09-09
timeout-minutes: 30
steps:
- uses: actions/checkout@v4
- name: Build iroha executor
run: mold --run cargo run --bin iroha_wasm_builder -- build ./wasm_samples/default_executor --optimize --out-file ${{ env.DOCKER_COMPOSE_PATH }}/executor.wasm
- name: Upload executor to reuse in other jobs
uses: actions/upload-artifact@v4
with:
name: executor.wasm
path: ${{ env.DOCKER_COMPOSE_PATH }}/executor.wasm
retention-days: 1
unit_tests_with_coverage:
runs-on: [self-hosted, Linux, iroha2]
container:
image: hyperledger/iroha2-ci:nightly-2024-09-09
needs: build_executor
env:
LLVM_PROFILE_FILE_NAME: "iroha-%p-%m.profraw"
steps:
- uses: actions/checkout@v4
- name: Download executor.wasm
uses: actions/download-artifact@v4
with:
name: executor.wasm
path: ${{ env.DOCKER_COMPOSE_PATH }}
- uses: taiki-e/install-action@nextest
- uses: taiki-e/install-action@cargo-llvm-cov
- name: Run unit tests (no default features)
run: >
mold --run cargo llvm-cov nextest
--no-fail-fast
--workspace --lib
--no-default-features
--branch
--no-report
- name: Run unit tests (all features)
run: >
mold --run cargo llvm-cov nextest
--no-fail-fast
--workspace --lib
--all-features
--branch
--no-report
- name: Generate lcov report
run: cargo llvm-cov report --lcov --output-path lcov.info
- name: Upload lcov report
uses: actions/upload-artifact@v4
with:
name: report-coverage
path: lcov.info
# include: iroha/tests/integration/
# exclude: iroha/tests/integration/extra_functional
integration:
runs-on: [self-hosted, Linux, iroha2]
container:
image: hyperledger/iroha2-ci:nightly-2024-09-09
needs: build_executor
timeout-minutes: 30
steps:
- uses: actions/checkout@v4
- name: Download executor.wasm
uses: actions/download-artifact@v4
with:
name: executor.wasm
path: ${{ env.DOCKER_COMPOSE_PATH }}
- uses: taiki-e/install-action@nextest
- name: Run integration tests, with all features
run: >
mold --run cargo nextest run
--all-features
--no-fail-fast
--failure-output immediate-final
-E 'package(iroha) and test(integration) and not test(extra_functional)'
# include: iroha/tests/integration/extra_functional
extra_functional:
runs-on: [self-hosted, Linux, iroha2]
container:
image: hyperledger/iroha2-ci:nightly-2024-09-09
needs: build_executor
timeout-minutes: 60
steps:
- uses: actions/checkout@v4
- name: Download executor.wasm
uses: actions/download-artifact@v4
with:
name: executor.wasm
path: ${{ env.DOCKER_COMPOSE_PATH }}
- uses: taiki-e/install-action@nextest
- name: Run integration tests, with all features
run: >
mold --run cargo nextest run
--all-features
--no-fail-fast
--failure-output final
--test-threads 1
-E 'test(extra_functional)'
# Run the job to check that the docker containers are properly buildable
pr-generator-build:
# Job will only execute if the head of the pull request is a branch for PR-generator case
if: startsWith(github.head_ref, 'iroha2-pr-deploy/')
runs-on: [self-hosted, Linux, iroha2]
container:
image: hyperledger/iroha2-ci:nightly-2024-09-09
steps:
- uses: actions/checkout@v4
- name: Login to Soramitsu Harbor
uses: docker/login-action@v3
with:
registry: docker.soramitsu.co.jp
username: ${{ secrets.HARBOR_USERNAME }}
password: ${{ secrets.HARBOR_TOKEN }}
- name: Set up Docker Buildx
id: buildx
if: always()
uses: docker/setup-buildx-action@v2
with:
install: true
- name: Build and push iroha2:dev image
uses: docker/build-push-action@v6
if: always()
with:
push: true
tags: docker.soramitsu.co.jp/iroha2/iroha2:dev-${{ github.event.pull_request.head.sha }}
labels: commit=${{ github.sha }}
build-args: TAG=dev
file: Dockerfile
# This context specification is required
context: .
docker-compose-and-pytests:
needs: build_executor
runs-on: [self-hosted, Linux, iroha2]
timeout-minutes: 60
env:
PYTHON_VERSION: "3.11"
POETRY_PATH: "/root/.local/bin/poetry"
TEST_DIR: "tmp/test"
IROHA_BIN: "iroha"
IROHA_CONTAINER: "defaults-irohad0-1"
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Download executor.wasm
uses: actions/download-artifact@v4
with:
name: executor.wasm
path: ${{ env.DOCKER_COMPOSE_PATH }}
- name: Install Python and Poetry
run: |
yum install -y python${{ env.PYTHON_VERSION }} python${{ env.PYTHON_VERSION }}-devel
curl -sSL https://install.python-poetry.org | python3 -
echo 'export PATH="${{ env.POETRY_PATH }}:$PATH"' >> /etc/profile
source /etc/profile
- name: Set up Docker buildx
id: buildx
uses: docker/setup-buildx-action@v3
with:
install: true
- name: Build and tag Docker images
uses: docker/build-push-action@v6
if: always()
with:
context: .
load: true
file: Dockerfile
tags: |
hyperledger/iroha:local
hyperledger/iroha:dev
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Test docker-compose.single.yml
run: |
docker compose -f ${{ env.DOCKER_COMPOSE_PATH }}/docker-compose.single.yml up --wait || exit 1
docker compose -f ${{ env.DOCKER_COMPOSE_PATH }}/docker-compose.single.yml down
- name: Test docker-compose.local.yml
run: |
docker compose -f ${{ env.DOCKER_COMPOSE_PATH }}/docker-compose.local.yml up --wait || exit 1
docker compose -f ${{ env.DOCKER_COMPOSE_PATH }}/docker-compose.local.yml down
- name: Run docker-compose.yml containers
run: docker compose -f ${{ env.DOCKER_COMPOSE_PATH }}/docker-compose.yml up --wait || exit 1
- name: Install Torii pytest dependencies
working-directory: pytests/iroha_torii_tests
run: ${{ env.POETRY_PATH }} install
- name: Run Torii pytests
working-directory: pytests/iroha_torii_tests
run: ${{ env.POETRY_PATH }} run pytest
- name: Copy client binary from Iroha container
if: always()
run: |
mkdir -p ${{ env.TEST_DIR }}
cp ./defaults/client.toml ${{ env.TEST_DIR }}
docker cp ${{ env.IROHA_CONTAINER }}:/usr/local/bin/${{ env.IROHA_BIN }} ${{ env.TEST_DIR }}
chmod +x ${{ env.TEST_DIR }}/${{ env.IROHA_BIN }}
- name: Install client pytest dependencies
working-directory: pytests/iroha_cli_tests
run: ${{ env.POETRY_PATH }} install
- name: Run client pytests
uses: nick-fields/retry@v3
env:
TMP_DIR: ../../${{ env.TEST_DIR }}
IROHA_CLI_BINARY: ${{ env.IROHA_BIN }}
IROHA_CLI_CONFIG: client.toml
with:
timeout_minutes: 10
max_attempts: 5
command: |
cd pytests/iroha_cli_tests
${{ env.POETRY_PATH }} run pytest
on_retry_command: |
docker compose -f ${{ env.DOCKER_COMPOSE_PATH }}/docker-compose.yml down
docker compose -f ${{ env.DOCKER_COMPOSE_PATH }}/docker-compose.local.yml up --wait || exit 1
- name: Wipe docker-compose.yml containers
if: always()
run: docker compose -f ${{ env.DOCKER_COMPOSE_PATH }}/docker-compose.yml down