-
Notifications
You must be signed in to change notification settings - Fork 13
213 lines (193 loc) · 6.01 KB
/
ci.yml
File metadata and controls
213 lines (193 loc) · 6.01 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
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
name: CI/CD
on:
push:
branches:
- master
tags:
- '[0-9]+.[0-9]+.[0-9]+*'
pull_request:
workflow_dispatch:
jobs:
format:
name: Format
runs-on: ubuntu-latest
container: ghcr.io/cirruslabs/flutter:3.22.3
timeout-minutes: 20
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Check format
run: scripts/check_format.sh
lint:
name: Lint
runs-on: ubuntu-latest
container: ghcr.io/cirruslabs/flutter:3.22.3
timeout-minutes: 20
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Get dependencies
run: flutter pub get
- name: Lint using flutter analyze
run: flutter analyze
- name: Assert that every file that should be public has been exported
run: scripts/assert_export.sh
pub-dry-run:
name: Publish Dry Run
runs-on: ubuntu-latest
container: ghcr.io/cirruslabs/flutter:3.22.3
timeout-minutes: 20
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Run publish dry run
run: flutter pub publish --dry-run
test-flutter:
name: Test Flutter
needs: [ lint, format, pub-dry-run ]
runs-on: ubuntu-latest
container: ghcr.io/cirruslabs/flutter:3.22.3
timeout-minutes: 20
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install lcov
run: sudo apt-get update && sudo apt-get install -y lcov
- name: Get dependencies
run: flutter pub get
- name: Run all tests
run: flutter test --reporter=expanded --coverage
- name: Check coverage
run: dart scripts/check_coverage.dart coverage/lcov.info
- name: Generate HTML report
run: genhtml coverage/lcov.info -o coverage/html
- name: Upload coverage report
uses: actions/upload-artifact@v4
with:
name: flutter-coverage-report
path: coverage/html
test-android:
name: Test Android
needs: [ lint, format, pub-dry-run ]
runs-on: ubuntu-latest
container: ghcr.io/cirruslabs/flutter:3.22.3
timeout-minutes: 20
env:
GRADLE_VERSION: 8.7
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Cache Gradle
id: cache-gradle
uses: actions/cache@v4
with:
path: |
./example/android/ci-cache/gradle
./example/android/gradle/wrapper/gradle-wrapper.jar
./example/android/gradlew
key: ${{ runner.os }}-cache-gradle-${{ env.GRADLE_VERSION }}
- name: Get dependencies
run: flutter pub get
- name: Setup Gradle
if: steps.cache-gradle.outputs.cache-hit != 'true'
working-directory: ./example/android
run: ../../scripts/setup_gradle.sh ${{ env.GRADLE_VERSION }}
- name: Validate Gradle
working-directory: ./example/android
run: dart ../../scripts/check_gradle_version.dart
- name: Run all tests and coverage
working-directory: ./example/android
run: ./gradlew :usercentrics_sdk:testDebugUnitTest :usercentrics_sdk:koverHtmlReportDebug
- name: List coverage files
working-directory: ./example
run: find build -name "*.html" -o -name "index.html" | head -20
- name: Upload coverage report
uses: actions/upload-artifact@v4
with:
name: android-coverage-report
path: example/build/usercentrics_sdk/reports/kover/htmlDebug
test-ios:
name: Test iOS
needs: [ lint, format, pub-dry-run ]
runs-on: macos-14
timeout-minutes: 20
steps:
- name: Setup code
uses: maxim-lobanov/setup-xcode@v1
with:
xcode-version: '15.4'
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Flutter
uses: subosito/flutter-action@v2
with:
flutter-version: '3.22.3'
channel: 'stable'
- name: Get dependencies
run: flutter pub get
- name: Setup Pods
working-directory: ./example/ios
run: pod install
- name: Run all tests
working-directory: ./example/ios
run: ../../scripts/ios_unit_tests.sh
- name: Show coverage report
working-directory: ./example/ios
run: xcrun xccov view --report TestResults.xcresult
build-android:
name: Build Android Example
needs: [ lint, format, pub-dry-run ]
runs-on: ubuntu-latest
container: ghcr.io/cirruslabs/flutter:3.22.3
timeout-minutes: 20
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Get dependencies
run: flutter pub get
- name: Build
working-directory: ./example
run: flutter build apk
build-ios:
name: Build iOS Example
needs: [ lint, format, pub-dry-run ]
runs-on: macos-14
timeout-minutes: 20
steps:
- name: Setup code
uses: maxim-lobanov/setup-xcode@v1
with:
xcode-version: '15.4'
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Flutter
uses: subosito/flutter-action@v2
with:
flutter-version: '3.22.3'
channel: 'stable'
- name: Get dependencies
run: flutter pub get
- name: Build
working-directory: ./example
run: flutter build ios --debug --no-codesign --simulator
# https://dart.dev/tools/pub/automated-publishing
release:
name: Release
permissions:
id-token: write
if: startsWith(github.ref, 'refs/tags/')
needs: [ test-flutter, test-android, test-ios, build-android, build-ios ]
runs-on: ubuntu-latest
container: ghcr.io/cirruslabs/flutter:3.22.3
timeout-minutes: 20
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Validate version
run: dart scripts/check_release_version.dart ${{ github.ref }}
- name: Set publishing token
uses: dart-lang/setup-dart@v1
- name: Get dependencies
run: flutter pub get
- name: Publish
run: flutter pub publish -f