Repository navigation
219 lines (211 loc) · 7.87 KB
/
Copy pathtest.yml
File metadata and controls
219 lines (211 loc) · 7.87 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
name: Test and publish
on:
push:
branches:
- main
paths-ignore:
- "**/*.md"
pull_request:
branches:
- "**"
release:
types:
- published
schedule:
- cron: 0 0 * * 1-5
permissions:
contents: read
jobs:
build:
runs-on: ubuntu-latest
name: Build
steps:
- name: Checkout
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
with:
persist-credentials: false
- name: Setup node
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
with:
node-version: '20'
check-latest: false
- name: Install deps
run: npm ci
- name: Build
run: ./tools/build.sh
- name: 'Upload Artifact'
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: angularfire-${{ github.run_id }}
path: dist
retention-days: 1
test:
runs-on: ${{ matrix.os }}
needs: build
strategy:
matrix:
os: [ ubuntu-latest, macos-latest, windows-latest ]
node: ["20", "22", "24"]
fail-fast: false
name: Test Node ${{ matrix.node }} (${{ matrix.os }})
steps:
- name: Checkout
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
with:
persist-credentials: false
- name: Setup node
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
with:
node-version: ${{ matrix.node }}
check-latest: true
- name: Install deps
run: npm ci
- name: Download Artifacts
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
name: angularfire-${{ github.run_id }}
path: dist
- name: Test Node
run: |
npm run build:jasmine
npm run test:node
browser:
runs-on: ${{ matrix.os }}
needs: build
name: Test ${{ matrix.browser }}
strategy:
matrix:
os: [ ubuntu-latest ]
browser: [ chrome-headless, firefox-headless ]
# TODO(davideast): Figure out why Safari tests timeout only on CI
# include:
# - os: macos-latest
# browser: safari
fail-fast: false
steps:
- name: Checkout
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
with:
persist-credentials: false
- name: Setup node
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
with:
node-version: 20
check-latest: false
- name: Setup java
uses: actions/setup-java@1bcf9fb12cf4aa7d266a90ae39939e61372fe520 # v5.4.0
with:
distribution: 'temurin'
java-version: '21'
- name: Install deps
run: npm ci
- name: Download Artifacts
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
name: angularfire-${{ github.run_id }}
path: dist
- name: Test browser
run: npm run test:${{ matrix.browser }}
contribute:
runs-on: ${{ matrix.os }}
name: Contribute Node ${{ matrix.node }} (${{ matrix.os }})
strategy:
matrix:
os: [ ubuntu-latest, macos-latest, windows-latest ]
node: ["20"]
fail-fast: false
steps:
- name: Checkout
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
with:
persist-credentials: false
- name: Setup node
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
with:
node-version: ${{ matrix.node }}
check-latest: true
- name: Install deps
run: npm ci
#- name: Lint
# run: npm run lint
- name: Build
run: npm run build
- name: Test Node
run: |
npm run build:jasmine
npm run test:node
- name: Setup java
uses: actions/setup-java@1bcf9fb12cf4aa7d266a90ae39939e61372fe520 # v5.4.0
with:
distribution: 'temurin'
java-version: '21'
- name: Test headless
run: npm run test:chrome-headless
# Tests are flaky on Windows
continue-on-error: ${{ matrix.os == 'windows-latest' }}
# Break the branch protection test into a seperate step, so we can manage the matrix more easily
test_and_contribute:
runs-on: ubuntu-latest
name: Branch protection
needs: ['test', 'contribute', 'browser']
steps:
- run: true
publish:
runs-on: ubuntu-latest
name: Publish (NPM)
needs: ['build', 'test', 'browser']
if: ${{ github.ref == 'refs/heads/main' || github.event_name == 'release' }}
# One canary publish at a time, so the check below reads the canary the previous one published.
concurrency:
group: ${{ github.event_name == 'release' && github.run_id || 'canary-publish' }}
cancel-in-progress: false
queue: max
steps:
- name: Setup node
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
with:
node-version: '20'
registry-url: 'https://wombat-dressing-room.appspot.com/'
check-latest: false
- name: 'Download Artifacts'
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
name: angularfire-${{ github.run_id }}
path: dist
- name: Skip a canary that is not newer than npm's
id: canary_check
run: |
VERSION=$(node -p "require('./dist/packages-dist/package.json').version")
if [[ $VERSION == *-canary.* ]]; then
# The dist-tags endpoint is not CDN-cached, unlike the package data `npm view` reads.
DIST_TAGS=$(curl -fsS --retry 3 --max-time 30 https://registry.npmjs.org/-/package/@angular/fire/dist-tags)
NPM_CANARY=$(node -p "JSON.parse(process.argv[1]).canary" "$DIST_TAGS")
# Order by position on main, not by version, which can be higher for an older commit.
git clone --quiet --bare --filter=tree:0 "$GITHUB_SERVER_URL/$GITHUB_REPOSITORY" history.git
HOW_TO_FIX="Every canary publish fails until the canary dist-tag points at a build of a commit on main. Publish rights are required to fix it with: npm dist-tag add @angular/fire@<version> canary"
if ! NPM_CANARY_COMMIT=$(git -C history.git rev-parse --verify --quiet "${NPM_CANARY##*[.-]}^{commit}"); then
echo "::error::Could not match the canary on npm, $NPM_CANARY, to a single commit in this repository. $HOW_TO_FIX"
exit 1
fi
# `npm publish` always moves a dist-tag, so a canary that is not newer must not publish at all.
if [[ $NPM_CANARY_COMMIT == "$GITHUB_SHA" ]]; then
if [[ $VERSION == "$NPM_CANARY" ]]; then
echo "::notice::Not publishing $VERSION, because it is already the canary on npm."
echo "skip=true" >> "$GITHUB_OUTPUT"
fi
elif git -C history.git merge-base --is-ancestor "$GITHUB_SHA" "$NPM_CANARY_COMMIT"; then
echo "::warning::Not publishing $VERSION, because the canary on npm, $NPM_CANARY, is from a later commit on main."
echo "skip=true" >> "$GITHUB_OUTPUT"
elif ! git -C history.git merge-base --is-ancestor "$NPM_CANARY_COMMIT" "$GITHUB_SHA"; then
echo "::error::Not publishing $VERSION, because its commit and the commit of the canary on npm, $NPM_CANARY, are not on the same line of history. One of them is not on main. $HOW_TO_FIX"
exit 1
fi
fi
- name: Publish
if: steps.canary_check.outputs.skip != 'true'
run: |
cd ./dist/packages-dist
chmod +x publish.sh
./publish.sh
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}