-
Notifications
You must be signed in to change notification settings - Fork 2
167 lines (135 loc) · 4.75 KB
/
pr-checks.yml
File metadata and controls
167 lines (135 loc) · 4.75 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
name: PR Checks
on:
pull_request:
types: [opened, synchronize, reopened]
# Cancel in-progress runs when a new workflow run is triggered
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs:
quick-checks:
name: Quick Checks
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup Dart SDK
uses: dart-lang/setup-dart@v1
with:
sdk: stable
- name: Install dependencies
run: dart pub get
- name: Check formatting
run: dart format --output=none --set-exit-if-changed .
- name: Analyze code
run: dart analyze --fatal-infos
builder-validation:
name: Validate Builder
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup Dart SDK
uses: dart-lang/setup-dart@v1
with:
sdk: stable
- name: Install dependencies
run: dart pub get
- name: Install example dependencies
working-directory: example/basic
run: dart pub get
- name: Generate manifest
working-directory: example/basic
run: dart run build_runner build --delete-conflicting-outputs
- name: Verify manifest exists
run: |
if [ ! -f "example/basic/.dart_tool/firebase/functions.yaml" ]; then
echo "::error::functions.yaml was not generated by builder"
exit 1
fi
- name: Check manifest structure
run: |
# Verify basic structure
if ! grep -q "specVersion:" example/basic/.dart_tool/firebase/functions.yaml; then
echo "::error::Missing specVersion in manifest"
exit 1
fi
if ! grep -q "endpoints:" example/basic/.dart_tool/firebase/functions.yaml; then
echo "::error::Missing endpoints in manifest"
exit 1
fi
echo "::notice::Manifest structure looks good"
# Only run full snapshot tests on PRs targeting main
snapshot-check:
name: Snapshot Compatibility
runs-on: ubuntu-latest
if: github.base_ref == 'main'
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup Dart SDK
uses: dart-lang/setup-dart@v1
with:
sdk: stable
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
- name: Install dependencies
run: dart pub get
- name: Generate Dart manifest (basic)
working-directory: example/basic
run: |
dart pub get
dart run build_runner build --delete-conflicting-outputs
- name: Generate Dart manifest (with_options)
working-directory: example/with_options
run: |
dart pub get
dart run build_runner build --delete-conflicting-outputs
- name: Generate Node.js manifest (nodejs_reference)
working-directory: example/nodejs_reference
run: |
npm ci
GCLOUD_PROJECT="test-project" PORT="8080" FUNCTIONS_CONTROL_API="true" \
npx firebase-functions > /tmp/ff.log 2>&1 &
FF_PID=$!
for i in {1..30}; do
if curl -s http://localhost:8080/__/functions.yaml > /dev/null 2>&1; then
break
fi
sleep 1
done
curl -s http://localhost:8080/__/functions.yaml | python3 -m json.tool > nodejs_manifest.json
kill $FF_PID 2>/dev/null || true
- name: Generate Node.js manifest (with_options_nodejs)
working-directory: example/with_options_nodejs
run: |
npm ci
GCLOUD_PROJECT="test-project" PORT="8081" FUNCTIONS_CONTROL_API="true" \
npx firebase-functions > /tmp/ff_options.log 2>&1 &
FF_PID=$!
for i in {1..30}; do
if curl -s http://localhost:8081/__/functions.yaml > /dev/null 2>&1; then
break
fi
sleep 1
done
curl -s http://localhost:8081/__/functions.yaml | python3 -m json.tool > nodejs_manifest.json
kill $FF_PID 2>/dev/null || true
- name: Run snapshot tests
run: dart test test/snapshots/manifest_snapshot_test.dart --reporter=github
pr-status:
name: PR Status
runs-on: ubuntu-latest
needs: [quick-checks, builder-validation]
if: always()
steps:
- name: Check results
run: |
if [ "${{ needs.quick-checks.result }}" != "success" ] || \
[ "${{ needs.builder-validation.result }}" != "success" ]; then
echo "::error::Some checks failed"
exit 1
fi
echo "::notice::All PR checks passed! ✅"