-
Notifications
You must be signed in to change notification settings - Fork 86
219 lines (211 loc) · 7.44 KB
/
e2e.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
name: e2e
on:
push:
branches:
- master
pull_request:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
# When getting Rust dependencies, retry on network error:
CARGO_NET_RETRY: 10
# Use the local .curlrc
CURL_HOME: .
jobs:
build_dfx:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
# We build a dynamic-linked linux binary because otherwise HSM support fails with:
# Error: IO: Dynamic loading not supported
os: [ macos-12, ubuntu-20.04, ubuntu-22.04, windows-2022 ]
include:
- os: macos-12
target: x86_64-apple-darwin
binary_path: target/x86_64-apple-darwin/release
- os: ubuntu-20.04
target: x86_64-unknown-linux-gnu
binary_path: target/x86_64-unknown-linux-gnu/release
- os: ubuntu-22.04
target: x86_64-unknown-linux-gnu
binary_path: target/x86_64-unknown-linux-gnu/release
- os: windows-2022
target: x86_64-pc-windows-msvc
binary_path: target/x86_64-pc-windows-msvc/release
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup environment variables
run: |
echo "RUSTFLAGS=--remap-path-prefix=${GITHUB_WORKSPACE}=/builds/dfinity" >> $GITHUB_ENV
- name: Cache Cargo
uses: actions/cache@v4
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ matrix.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}-${{ hashFiles('rust-toolchain.toml') }}-1
- name: Install Rust
run: rustup show
if: contains(matrix.os, 'macos')
- name: Build
run: |
cargo build --target ${{ matrix.target }} --locked --release
- name: Strip binaries
run: |
cd ${{ matrix.binary_path }}
sudo chown -R $(whoami) .
strip dfx
if: contains(matrix.os, 'ubuntu')
- name: Upload Artifacts
uses: actions/upload-artifact@v4
with:
name: dfx-${{ matrix.os }}-rs-${{ hashFiles('rust-toolchain.toml') }}
path: ${{ matrix.binary_path }}/dfx
list_tests:
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- uses: actions/checkout@v4
- id: set-matrix
run: echo "matrix=$(scripts/workflows/e2e-matrix.py)" >> $GITHUB_OUTPUT
smoke:
runs-on: ${{ matrix.os }}
needs: build_dfx
strategy:
fail-fast: false
matrix:
# macos-latest is currently macos-11, ubuntu-latest is currently ubuntu-20.04
# ubuntu-18.04 not supported due to:
# /home/runner/.cache/dfinity/versions/0.8.3-34-g36e39809/ic-starter:
# /lib/x86_64-linux-gnu/libm.so.6: version `GLIBC_2.29' not found
os: [macos-12, ubuntu-20.04, ubuntu-22.04]
steps:
- uses: actions/checkout@v4
- name: Download dfx binary
uses: actions/download-artifact@v4
with:
name: dfx-${{ matrix.os }}-rs-${{ hashFiles('rust-toolchain.toml') }}
path: /usr/local/bin
- name: Setup dfx binary
run: chmod +x /usr/local/bin/dfx
- name: Disable query verification in ic-ref
if: ${{ matrix.backend == 'ic-ref' }}
run: |
echo DFX_DISABLE_QUERY_VERIFICATION=1 >> $GITHUB_ENV
- name: start and deploy
run: |
pwd
time dfx cache install
time dfx new smoke
cd smoke
time dfx start --background
time dfx deploy
time dfx canister call smoke_backend greet '("fire")'
time curl --fail http://localhost:"$(dfx info webserver-port)"/sample-asset.txt?canisterId=$(dfx canister id smoke_frontend)
time dfx stop
test:
runs-on: ${{ matrix.os }}
needs: [build_dfx, list_tests]
strategy:
fail-fast: false
matrix: ${{fromJson(needs.list_tests.outputs.matrix)}}
env:
E2E_TEST: tests-${{ matrix.test }}.bash
steps:
- uses: actions/checkout@v4
- name: Download dfx binary
uses: actions/download-artifact@v4
with:
name: dfx-${{ matrix.os }}-rs-${{ hashFiles('rust-toolchain.toml') }}
path: /usr/local/bin
- name: Setup dfx binary
run: chmod +x /usr/local/bin/dfx
- name: Provision Darwin
if: contains(matrix.os, 'macos')
run: bash scripts/workflows/provision-darwin.sh
- name: Provision Linux
if: contains(matrix.os, 'ubuntu')
run: bash scripts/workflows/provision-linux.sh
- name: Prepare environment
run: |
echo "archive=$(pwd)/e2e/archive" >> "$GITHUB_ENV"
echo "assets=$(pwd)/e2e/assets" >> "$GITHUB_ENV"
echo "utils=$(pwd)/e2e/utils" >> "$GITHUB_ENV"
export
- name: Download bats-support as a git submodule
run: git submodule update --init --recursive
- name: Cache mops files
uses: actions/cache@v4
with:
path: |
e2e/assets/playground_backend/.mops
key: playground-backend-mops-${{ hashFiles('e2e/assets/playground_backend/mops.toml') }}
- name: Run e2e test
run: timeout 2400 bats "e2e/$E2E_TEST"
ui_test:
runs-on: ${{ matrix.os }}
needs: [build_dfx]
strategy:
fail-fast: false
matrix:
os: [macos-12, ubuntu-20.04, ubuntu-22.04]
steps:
- name: Checking out repo
uses: actions/checkout@v4
- name: Setting up Python
uses: actions/setup-python@v5
with:
python-version: '3.9'
- name: Installing playwright
run: |
pip install playwright==1.40.0
playwright install
playwright install-deps
- name: Download dfx binary
uses: actions/download-artifact@v4
with:
name: dfx-${{ matrix.os }}-rs-${{ hashFiles('rust-toolchain.toml') }}
path: /usr/local/bin
- name: Setup dfx binary
run: chmod +x /usr/local/bin/dfx
- name: Deploy default dfx project
run: |
dfx new e2e_project
cd e2e_project
dfx start --background --clean
dfx deploy 2>&1 | tee deploy.log
echo FRONTEND_URL=$(grep "_frontend:" deploy.log | grep -Eo "(http|https)://[a-zA-Z0-9./?=_&%:-]*") >> $GITHUB_ENV
echo CANDID_URL=$(grep "_backend:" deploy.log | grep -Eo "(http|https)://[a-zA-Z0-9./?=_&%:-]*") >> $GITHUB_ENV
- name: Running the Python script
run: |
python scripts/test-uis.py \
--frontend_url "$FRONTEND_URL" \
--candid_url "$CANDID_URL" \
--browser chromium firefox webkit
export FRONTEND_URL_LOCALHOST="${FRONTEND_URL/127\.0\.0\.1/localhost}"
export CANDID_URL_LOCALHOST="${CANDID_URL/127\.0\.0\.1/localhost}"
python scripts/test-uis.py \
--frontend_url "$FRONTEND_URL_LOCALHOST" \
--candid_url "$CANDID_URL_LOCALHOST" \
--browser chromium firefox webkit
aggregate:
name: e2e:required
if: ${{ always() }}
needs: [test, smoke, ui_test]
runs-on: ubuntu-latest
steps:
- name: check smoke test result
if: ${{ needs.smoke.result != 'success' }}
run: exit 1
- name: check UI test result
if: ${{ needs.ui_test.result != 'success' }}
run: exit 1
- name: check e2e test result
if: ${{ needs.test.result != 'success' }}
run: exit 1