-
Notifications
You must be signed in to change notification settings - Fork 66
328 lines (265 loc) · 8.96 KB
/
build.yml
File metadata and controls
328 lines (265 loc) · 8.96 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
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
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
name: Build
on:
push:
branches:
- main
pull_request:
paths-ignore:
- "**.md"
- "**.mdx"
schedule:
# runs the CI everyday at 10AM
- cron: "0 10 * * *"
workflow_dispatch:
inputs:
dart_version:
description: 'Dart version to test (stable or beta)'
required: false
default: 'stable'
jobs:
# Check license headers on all source files
check-license-header:
name: Check License Headers
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- name: Checkout repository
uses: actions/checkout@v6
- name: Download addlicense
run: |
curl -sL https://github.com/google/addlicense/releases/download/v1.2.0/addlicense_v1.2.0_Linux_x86_64.tar.gz | tar xz -C /usr/local/bin addlicense
chmod +x /usr/local/bin/addlicense
- name: Check license headers
run: |
addlicense -f scripts/header_template.txt \
--check \
--ignore "**/*.yml" \
--ignore "**/*.yaml" \
--ignore "**/*.xml" \
--ignore "**/*.g.dart" \
--ignore "**/*.sh" \
--ignore "**/*.html" \
--ignore "**/*.js" \
--ignore "**/*.ts" \
--ignore "**/*.txt" \
--ignore "**/.dart_tool/**" \
--ignore "LICENSE" \
.
lint:
name: Lint (Dart ${{ matrix.dart-version }})
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
dart-version: ['3.9', stable, dev]
defaults:
run:
working-directory: packages/firebase_admin_sdk
steps:
- uses: actions/checkout@v6
- uses: dart-lang/setup-dart@v1
with:
sdk: ${{ matrix.dart-version }}
- name: Cache pub dependencies
uses: actions/cache@v5
with:
path: ~/.pub-cache
key: pub-${{ matrix.dart-version }}-${{ hashFiles('**/pubspec.lock') }}
restore-keys: |
pub-${{ matrix.dart-version }}-
pub-
- run: dart pub global activate melos
working-directory: .
- run: melos bootstrap
working-directory: .
- run: dart format --set-exit-if-changed .
if: matrix.dart-version == 'dev'
- run: dart analyze
if: matrix.dart-version != 'dev'
- run: dart analyze --fatal-infos
if: matrix.dart-version == 'dev'
test:
name: Test (Dart ${{ matrix.dart-version }})
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: write
strategy:
fail-fast: false
matrix:
dart-version: [stable, beta]
defaults:
run:
working-directory: packages/firebase_admin_sdk
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 2
- uses: actions/setup-java@v5
with:
java-version: '21'
distribution: 'temurin'
- uses: actions/setup-node@v6
- uses: dart-lang/setup-dart@v1
with:
sdk: ${{ matrix.dart-version }}
- name: Cache pub dependencies
uses: actions/cache@v5
with:
path: ~/.pub-cache
key: pub-${{ matrix.dart-version }}-${{ hashFiles('**/pubspec.lock') }}
restore-keys: |
pub-${{ matrix.dart-version }}-
pub-
- name: Cache Firebase CLI
uses: actions/cache@v5
with:
path: ~/.cache/firebase/emulators
key: firebase-emulators
restore-keys: |
firebase-
- name: Add pub cache bin to PATH
run: |
echo "$HOME/.pub-cache/bin" >> $GITHUB_PATH
echo "PUB_CACHE=$HOME/.pub-cache" >> $GITHUB_ENV
- run: dart pub global activate melos
working-directory: .
- run: melos bootstrap
working-directory: .
- run: npm install -g firebase-tools
- name: Run firebase_admin_sdk tests with coverage
run: ${{ github.workspace }}/scripts/coverage.sh
- name: Run google_cloud_firestore tests with coverage
run: ${{ github.workspace }}/scripts/firestore-coverage.sh
- name: Process coverage and check threshold
if: matrix.dart-version == 'stable'
id: coverage
run: dart ../../scripts/process_coverage.dart
- name: Comment coverage on PR
if: matrix.dart-version == 'stable' && github.event_name == 'pull_request' && github.event.pull_request.head.repo.fork == false
uses: actions/github-script@v9
with:
script: |
const coverage = '${{ steps.coverage.outputs.coverage }}';
const status = '${{ steps.coverage.outputs.status }}';
const hitLines = '${{ steps.coverage.outputs.hit_lines }}';
const totalLines = '${{ steps.coverage.outputs.total_lines }}';
const coverageTable = `${{ steps.coverage.outputs.coverage_table }}`;
const body = `## Coverage Report
${status}
**Total Coverage:** ${coverage}%
**Lines Covered:** ${hitLines}/${totalLines}
${coverageTable}
_Minimum threshold: 40%_`;
// Find existing comment
const { data: comments } = await github.rest.issues.listComments({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
});
const botComment = comments.find(comment =>
comment.user.type === 'Bot' &&
comment.body.includes('Coverage Report')
);
if (botComment) {
// Update existing comment
await github.rest.issues.updateComment({
owner: context.repo.owner,
repo: context.repo.repo,
comment_id: botComment.id,
body: body
});
} else {
// Create new comment
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
body: body
});
}
- name: Upload coverage to codecov
if: matrix.dart-version == 'stable'
continue-on-error: true
uses: codecov/codecov-action@v6
with:
files: coverage.lcov
flags: unittests
fail_ci_if_error: false
test-wif:
name: Test - WIF Auth (Dart ${{ matrix.dart-version }})
runs-on: ubuntu-latest
# Skip for fork PRs — secrets are not available
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.fork == false
permissions:
contents: 'read'
id-token: 'write'
strategy:
fail-fast: false
matrix:
dart-version: [stable, beta]
defaults:
run:
working-directory: packages/firebase_admin_sdk
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 2
- uses: dart-lang/setup-dart@v1
with:
sdk: ${{ matrix.dart-version }}
- name: Authenticate to Google Cloud/Firebase
uses: google-github-actions/auth@v3
with:
workload_identity_provider: '${{ secrets.WORKLOAD_IDENTITY_PROVIDER }}'
service_account: '${{ secrets.SERVICE_ACCOUNT }}'
- name: Cache pub dependencies
uses: actions/cache@v5
with:
path: ~/.pub-cache
key: pub-${{ matrix.dart-version }}-${{ hashFiles('**/pubspec.lock') }}
restore-keys: |
pub-${{ matrix.dart-version }}-
pub-
- name: Add pub cache bin to PATH
run: |
echo "$HOME/.pub-cache/bin" >> $GITHUB_PATH
echo "PUB_CACHE=$HOME/.pub-cache" >> $GITHUB_ENV
- run: dart pub global activate melos
working-directory: .
- run: melos bootstrap
working-directory: .
- name: Run WIF auth test
run: dart test test/integration/app/firebase_app_prod_test.dart --concurrency=1
publish:
name: Publish verification
runs-on: ubuntu-latest
needs: [check-license-header, lint, test, test-wif]
# Run even if test-wif was skipped (fork PRs), but not if other jobs failed
if: |
always() &&
needs.check-license-header.result == 'success' &&
needs.lint.result == 'success' &&
needs.test.result == 'success' &&
(needs.test-wif.result == 'success' || needs.test-wif.result == 'skipped')
defaults:
run:
working-directory: packages/firebase_admin_sdk
steps:
- uses: actions/checkout@v6
- uses: dart-lang/setup-dart@v1
with:
sdk: stable
- name: Cache pub dependencies
uses: actions/cache@v5
with:
path: ~/.pub-cache
key: pub-stable-${{ hashFiles('**/pubspec.lock') }}
restore-keys: |
pub-stable-
pub-
- run: dart pub global activate melos
working-directory: .
- run: melos bootstrap
working-directory: .
- run: dart pub publish --dry-run