@@ -2,10 +2,16 @@ name: Test Firestore
2
2
3
3
on : pull_request
4
4
5
+ env :
6
+ artifactRetentionDays : 14
7
+
5
8
jobs :
6
- test-chrome :
7
- name : Test Firestore on Chrome and Node If Changed
9
+ build :
10
+ name : Build Firestore
11
+
8
12
runs-on : ubuntu-latest
13
+ outputs :
14
+ changed : ${{ steps.set-output.outputs.CHANGED }}
9
15
10
16
steps :
11
17
- name : Checkout Repo
@@ -28,40 +34,166 @@ jobs:
28
34
cp config/ci.config.json config/project.json
29
35
yarn
30
36
- name : build
31
- run : yarn build:changed firestore
32
- - name : Run tests if firestore or its dependencies has changed
33
- run : yarn test:changed firestore
37
+ id : build
38
+ run : |
39
+ set -o pipefail
40
+ yarn build:changed firestore | tee ${{ runner.temp }}/yarn.log.txt
41
+ continue-on-error : false
42
+ - name : Check if Firestore is changed
43
+ id : check-changed
44
+ run : egrep "Skipping all" ${{ runner.temp }}/yarn.log.txt
45
+ # Continue when "Skipping all" is not found
46
+ continue-on-error : true
47
+ - name : set output
48
+ # This means "Skipping all" was not found
49
+ if : steps.check-changed.outcome != 'success'
50
+ id : set-output
51
+ run : echo "CHANGED=true" >> "$GITHUB_OUTPUT";
52
+ - name : Archive build
53
+ if : ${{ !cancelled() && steps.build.outcome == 'success' && steps.check-changed.outcome != 'success' }}
54
+ run : |
55
+ tar -cf build.tar --exclude=.git .
56
+ gzip build.tar
57
+ - name : Upload build archive
58
+ if : ${{ !cancelled() && steps.build.outcome == 'success' && steps.check-changed.outcome != 'success' }}
59
+ uses : actions/upload-artifact@v3
60
+ with :
61
+ name : build.tar.gz
62
+ path : build.tar.gz
63
+ retention-days : ${{ env.artifactRetentionDays }}
34
64
35
- test-firefox :
36
- name : Test Firestore on Firefox If Changed
65
+ compat-test-chrome :
66
+ name : Test Firestore Compatible
67
+ runs-on : ubuntu-latest
68
+ needs : build
69
+ if : ${{ needs.build.outputs.changed == 'true'}}
70
+ steps :
71
+ - name : Set up Node (14)
72
+ uses : actions/setup-node@v3
73
+ with :
74
+ node-version : 14.x
75
+ - name : install Chrome stable
76
+ run : |
77
+ sudo apt-get update
78
+ sudo apt-get install google-chrome-stable
79
+ - name : Download build archive
80
+ uses : actions/download-artifact@v3
81
+ with :
82
+ name : build.tar.gz
83
+ - name : Unzip build artifact
84
+ run : tar xf build.tar.gz
85
+ - name : Bump Node memory limit
86
+ run : echo "NODE_OPTIONS=--max_old_space_size=4096" >> $GITHUB_ENV
87
+ - name : Test setup and yarn install
88
+ run : cp config/ci.config.json config/project.json
89
+ - name : Run compat tests
90
+ run : cd packages/firestore-compat && yarn run test:ci
91
+
92
+ test-chrome :
93
+ name : Test Firestore
94
+ strategy :
95
+ matrix :
96
+ test-name : ["test:browser", "test:travis", "test:lite:browser", "test:browser:prod:nameddb", "test:lite:browser:nameddb"]
97
+ runs-on : ubuntu-latest
98
+ needs : build
99
+ if : ${{ needs.build.outputs.changed == 'true'}}
100
+ steps :
101
+ - name : Set up Node (14)
102
+ uses : actions/setup-node@v3
103
+ with :
104
+ node-version : 14.x
105
+ - name : install Chrome stable
106
+ run : |
107
+ sudo apt-get update
108
+ sudo apt-get install google-chrome-stable
109
+ - name : Download build archive
110
+ uses : actions/download-artifact@v3
111
+ with :
112
+ name : build.tar.gz
113
+ - name : Unzip build artifact
114
+ run : tar xf build.tar.gz
115
+ - name : Bump Node memory limit
116
+ run : echo "NODE_OPTIONS=--max_old_space_size=4096" >> $GITHUB_ENV
117
+ - name : Test setup and yarn install
118
+ run : cp config/ci.config.json config/project.json
119
+ - name : Run tests
120
+ run : cd packages/firestore && yarn run ${{ matrix.test-name }}
121
+
122
+ compat-test-firefox :
123
+ name : Test Firestore Compatible on Firefox
37
124
# Whatever version of Firefox comes with 22.04 is causing Firefox
38
125
# startup to hang when launched by karma. Need to look further into
39
126
# why.
40
127
runs-on : ubuntu-20.04
128
+ needs : build
129
+ if : ${{ needs.build.outputs.changed == 'true'}}
130
+ steps :
131
+ - name : install Firefox stable
132
+ run : |
133
+ sudo apt-get update
134
+ sudo apt-get install firefox
135
+ - name : Set up Node (14)
136
+ uses : actions/setup-node@v3
137
+ with :
138
+ node-version : 14.x
139
+ - name : Download build archive
140
+ uses : actions/download-artifact@v3
141
+ with :
142
+ name : build.tar.gz
143
+ - name : Unzip build artifact
144
+ run : tar xf build.tar.gz
145
+ - name : Bump Node memory limit
146
+ run : echo "NODE_OPTIONS=--max_old_space_size=4096" >> $GITHUB_ENV
147
+ - name : Test setup and yarn install
148
+ run : cp config/ci.config.json config/project.json
149
+ - name : Run compat tests
150
+ run : cd packages/firestore-compat && xvfb-run yarn run test:ci
151
+ env :
152
+ BROWSERS : ' Firefox'
41
153
154
+ test-firefox :
155
+ name : Test Firestore on Firefox
156
+ strategy :
157
+ matrix :
158
+ test-name : ["test:browser", "test:travis", "test:lite:browser", "test:browser:prod:nameddb", "test:lite:browser:nameddb"]
159
+ # Whatever version of Firefox comes with 22.04 is causing Firefox
160
+ # startup to hang when launched by karma. Need to look further into
161
+ # why.
162
+ runs-on : ubuntu-20.04
163
+ needs : build
164
+ if : ${{ needs.build.outputs.changed == 'true'}}
42
165
steps :
43
166
- name : install Firefox stable
44
167
run : |
45
168
sudo apt-get update
46
169
sudo apt-get install firefox
47
- - name : Checkout Repo
48
- uses : actions/checkout@master
170
+ - name : Download build archive
171
+ uses : actions/download-artifact@v3
49
172
with :
50
- # This makes Actions fetch all Git history so run-changed script can diff properly.
51
- fetch-depth : 0
173
+ name : build.tar.gz
174
+ - name : Unzip build artifact
175
+ run : tar xf build.tar.gz
52
176
- name : Set up Node (14)
53
177
uses : actions/setup-node@v3
54
178
with :
55
179
node-version : 14.x
56
180
- name : Bump Node memory limit
57
181
run : echo "NODE_OPTIONS=--max_old_space_size=4096" >> $GITHUB_ENV
58
182
- name : Test setup and yarn install
59
- run : |
60
- cp config/ci.config.json config/project.json
61
- yarn
62
- - name : build
63
- run : yarn build:changed firestore
64
- - name : Run tests if firestore or its dependencies has changed
65
- run : xvfb-run yarn test:changed firestore
183
+ run : cp config/ci.config.json config/project.json
184
+ - name : Run tests
185
+ run : cd packages/firestore && xvfb-run yarn run ${{ matrix.test-name }}
66
186
env :
67
187
BROWSERS : ' Firefox'
188
+
189
+ # A job that fails if any required job in the test matrix fails,
190
+ # to be used as a required check for merging.
191
+ check-required-tests :
192
+ runs-on : ubuntu-latest
193
+ if : always()
194
+ name : Check all required tests results
195
+ needs : [build, test-chrome, compat-test-chrome]
196
+ steps :
197
+ - name : Check test matrix
198
+ if : needs.build.result == 'failure' || needs.test-chrome.result == 'failure' || needs.compat-test-chrome.result == 'failure'
199
+ run : exit 1
0 commit comments