-
Notifications
You must be signed in to change notification settings - Fork 208
141 lines (121 loc) · 4.84 KB
/
ui-tests-on-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
name: UI flutter tests on PR
on:
pull_request:
types: [opened, synchronize, reopened]
jobs:
tests:
name: Test ${{ matrix.name }}
runs-on: ${{ matrix.os }}
timeout-minutes: 45
strategy:
fail-fast: false
matrix:
name: [
web-app-linux,
web-app-macos,
]
include:
- name: web-app-linux
os: [self-hosted, Linux]
- name: web-app-macos
os: [self-hosted, macos]
steps:
- name: Setup GH Actions
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '18'
- run: |
npx @puppeteer/browsers install chromedriver@stable
- name: Get stable flutter
uses: subosito/flutter-action@v2
with:
flutter-version: '3.22.x'
channel: 'stable'
- name: Prepare build directory
run: |
flutter clean
rm -rf build/*
rm -rf web/src/mm2/*
rm -rf web/src/kdfi/*
rm -rf web/dist/*
- name: Fetch packages and generate assets
run: |
echo "Running \`flutter build\` to generate assets for the deployment build"
flutter pub get > /dev/null 2>&1
flutter build web --profile > /dev/null 2>&1 || true
flutter pub get > /dev/null 2>&1
flutter build web --release > /dev/null 2>&1 || true
echo "Done fetching packages and generating assets"
- name: Validate build
run: |
# Check that the web build folder contains a wasm file in the format build/web/dist/*.wasm
if [ ! -f build/web/dist/*.wasm ]; then
echo "Error: Web build failed. No wasm file found in build/web/dist/"
# List files for debugging
echo "Listing files in build/web recursively"
ls -R build/web
echo "Listing files in web recursively"
ls -R web
exit 1
fi
# Check that the index.html is present and that it is equal to the source index.html
if ! cmp -s web/index.html build/web/index.html; then
echo "Error: Web build failed. index.html is not equal to the source index.html"
exit 1
fi
# Check that the index.html has uncommitted changes to ensure that the placeholder was replaced with the generated content
if git diff --exit-code web/index.html; then
echo "Error: Web build failed. index.html has no uncommitted changes which indicates an issue with the \`template.html\` to \`index.html\` generation"
exit 1
fi
# Decode the AssetManifest.bin and check for the coin icon presence
if [ ! -f build/web/assets/AssetManifest.bin ]; then
echo "Error: AssetManifest.bin file not found."
exit 1
fi
if ! strings build/web/assets/AssetManifest.bin | grep -q "assets/coin_icons/png/kmd.png"; then
echo "Error: Coin icon not found in AssetManifest.bin"
exit 1
fi
- name: Test air_dex chrome (unix) (Linux)
if: runner.name == 'ci-builder-radon'
id: tests-chrome
continue-on-error: true
timeout-minutes: 35
run: |
chromedriver --port=4444 --silent --enable-chrome-logs --log-path=chrome_console.log &
dart run_integration_tests.dart -d 'headless' -b '1600,1024' --browser-name=chrome
- name: Enable safaridriver (sudo) (MacOS)
if: runner.name == 'ci-builder-astatine'
timeout-minutes: 1
run: |
defaults write com.apple.Safari IncludeDevelopMenu YES
defaults write com.apple.Safari AllowRemoteAutomation 1
sudo /usr/bin/safaridriver --enable || echo "Failed to enable safaridriver!"
- name: Run safaridriver in background (MacOS)
if: runner.name == 'ci-builder-astatine'
continue-on-error: true
run: |
safaridriver -p 4444 &
- name: Test air_dex safari (MacOS)
if: runner.name == 'ci-builder-astatine'
id: tests-safari
continue-on-error: true
timeout-minutes: 35
run: |
flutter pub get
dart run_integration_tests.dart --browser-name=safari
- name: Upload logs (Linux)
if: runner.name == 'ci-builder-radon'
uses: actions/upload-artifact@v4
with:
name: ${{ runner.os }}-chromedriver-logs.zip
path: ./chrome_console.log
- name: Fail workflow if tests failed (Linux)
if: runner.name == 'ci-builder-radon' && steps.tests-chrome.outcome == 'failure'
run: exit 1
- name: Fail workflow if tests failed (MacOS)
if: runner.name == 'ci-builder-astatine' && steps.tests-safari.outcome == 'failure'
run: exit 1