Repository navigation
183 lines (158 loc) · 6.28 KB
/
Copy pathci.yml
File metadata and controls
183 lines (158 loc) · 6.28 KB
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
name: CI
on:
push:
branches: [development, master, main]
paths:
- 'app/**'
- 'tools/generate_icons.py'
- 'packaging/windows/assets/**'
- '.github/workflows/**'
- '.github/scripts/**'
- 'codecov.yml'
pull_request:
branches: [development, master, main]
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
FLUTTER_VERSION: '3.47.9'
jobs:
icons:
name: Platform icon assets
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.12'
- name: Install icon tools
run: |
sudo apt-get update
sudo apt-get install -y librsvg2-bin
python -m pip install pillow==12.0.0
- name: Check platform dimensions, artwork and safe zones
run: python tools/generate_icons.py --check
tests:
name: Dart quality and coverage
runs-on: ubuntu-latest
defaults:
run:
working-directory: app
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup Flutter
uses: subosito/flutter-action@v2
with:
flutter-version: ${{ env.FLUTTER_VERSION }}
cache: true
- name: Install dependencies
run: flutter pub get --enforce-lockfile
- name: Check formatting
run: dart format --output=none --set-exit-if-changed .
- name: Analyze code
run: flutter analyze --no-fatal-warnings --no-fatal-infos
- name: Install JUnit converter
run: dart pub global activate junitreport 2.0.2
- name: Check report normalization
run: python3 -m unittest discover -s ../.github/scripts -p 'test_*.py'
- name: Run tests with coverage
id: tests
run: |
mkdir -p build/test-results
flutter test --coverage --file-reporter json:build/test-results/tests.json
- name: Summarize test durations
if: ${{ !cancelled() && hashFiles('app/build/test-results/tests.json') != '' }}
run: python3 ../.github/scripts/summarize_test_timing.py build/test-results/tests.json >> "$GITHUB_STEP_SUMMARY"
- name: Generate JUnit report
if: ${{ !cancelled() && (steps.tests.outcome == 'success' || steps.tests.outcome == 'failure') }}
run: |
python3 ../.github/scripts/normalize_test_report.py \
build/test-results/tests.json build/test-results/tests.junit.json
dart pub global run junitreport:tojunit \
--input build/test-results/tests.junit.json \
--output build/test-results/junit.xml \
--base "$PWD/" \
--package app
test -s build/test-results/junit.xml
- name: Save test results
if: ${{ !cancelled() && hashFiles('app/build/test-results/tests.json') != '' }}
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
name: client-test-results-${{ github.run_attempt }}
path: app/build/test-results/
if-no-files-found: error
retention-days: 14
- name: Upload test results to Codecov
if: ${{ !cancelled() && hashFiles('app/build/test-results/junit.xml') != '' }}
uses: codecov/codecov-action@303a32d7a59b442fa8d48b6a1cc6825c09c847a5 # v7.1.1
with:
report_type: test_results
files: app/build/test-results/junit.xml
flags: client
token: ${{ secrets.CODECOV_TOKEN }}
fail_ci_if_error: true
disable_search: true
- name: Validate coverage report
if: ${{ !cancelled() && (steps.tests.outcome == 'success' || steps.tests.outcome == 'failure') }}
run: test -s coverage/lcov.info
- name: Save coverage report
if: ${{ !cancelled() && hashFiles('app/coverage/lcov.info') != '' }}
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
name: client-coverage-${{ github.run_attempt }}
path: app/coverage/lcov.info
if-no-files-found: error
retention-days: 14
- name: Upload coverage to Codecov
if: ${{ !cancelled() && hashFiles('app/coverage/lcov.info') != '' }}
uses: codecov/codecov-action@303a32d7a59b442fa8d48b6a1cc6825c09c847a5 # v7.1.1
with:
files: app/coverage/lcov.info
flags: client
token: ${{ secrets.CODECOV_TOKEN }}
fail_ci_if_error: true
disable_search: true
browser:
name: Browser behavior checks
runs-on: ubuntu-latest
defaults:
run:
working-directory: app
steps:
- uses: actions/checkout@v4
- uses: subosito/flutter-action@v2
with:
flutter-version: ${{ env.FLUTTER_VERSION }}
cache: true
- run: flutter pub get --enforce-lockfile
- name: Check browser bootstrap and cover worker
run: node --test test/web/*.cjs
- name: Check browser cover transport and drag-and-drop
run: |
mkdir -p build/test-results
flutter test --platform chrome --file-reporter json:build/test-results/browser.json \
test/services/book_cover_storage_web_test.dart test/platform/book_import_drop_registration_web_test.dart
- name: Summarize browser test durations
if: ${{ !cancelled() && hashFiles('app/build/test-results/browser.json') != '' }}
run: python3 ../.github/scripts/summarize_test_timing.py build/test-results/browser.json >> "$GITHUB_STEP_SUMMARY"
- name: Save browser test results
if: ${{ !cancelled() && hashFiles('app/build/test-results/browser.json') != '' }}
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
name: client-browser-test-results-${{ github.run_attempt }}
path: app/build/test-results/browser.json
if-no-files-found: error
retention-days: 14
quality:
name: Code quality checks
if: ${{ always() }}
needs: [tests, browser]
runs-on: ubuntu-latest
steps:
- name: Require both test jobs
env:
TEST_RESULT: ${{ needs.tests.result }}
BROWSER_RESULT: ${{ needs.browser.result }}
run: test "$TEST_RESULT" = success && test "$BROWSER_RESULT" = success