@@ -26,108 +26,36 @@ jobs:
26
26
runs-on : ubuntu-latest
27
27
name : Build and Verify
28
28
steps :
29
- # Access a cache of set results from a previous run of the job
30
- # This is to prevent re-running steps that were already successful since it is not native to github actions
31
- # Can be used to verify flaky steps with reduced times
32
- - name : Restore the cached run
33
- uses : actions/cache@v2
34
- with :
35
- path : |
36
- job_successful
37
- linter_results
38
- unit_tests_results
39
- integration_tests_results
40
- key : ${{ github.run_id }}-${{ github.job }}-${{ github.sha }}
41
- restore-keys : |
42
- ${{ github.run_id }}-${{ github.job }}-${{ github.sha }}
43
-
44
- - name : Get if previous job was successful
45
- id : job_successful
46
- run : cat job_successful 2>/dev/null || echo 'false'
47
-
48
- - name : Get the previous linter results
49
- id : linter_results
50
- run : cat linter_results 2>/dev/null || echo 'default'
51
-
52
- - name : Get the previous unit tests results
53
- id : unit_tests_results
54
- run : cat unit_tests_results 2>/dev/null || echo 'default'
55
-
56
- - name : Get the previous integration tests results
57
- id : integration_tests_results
58
- run : cat integration_tests_results 2>/dev/null || echo 'default'
59
29
60
30
- name : Checkout code
61
- if : steps.job_successful.outputs.job_successful != 'true'
62
31
uses : actions/checkout@v2
63
32
64
33
- name : Setup Node
65
- if : steps.job_successful.outputs.job_successful != 'true'
66
34
uses : actions/setup-node@v2
67
35
with :
68
36
node-version-file : " .nvmrc"
69
37
registry-url : ' https://registry.npmjs.org'
70
38
71
39
- name : Setup Yarn
72
- if : steps.job_successful.outputs.job_successful != 'true'
73
40
run : |
74
41
npm uninstall -g yarn
75
42
76
43
77
44
- name : Run bootstrap
78
- if : steps.job_successful.outputs.job_successful != 'true'
79
45
run : yarn osd bootstrap
80
46
81
47
- name : Run linter
82
- if : steps.linter_results.outputs.linter_results != 'success'
83
48
id : linter
84
49
run : yarn lint
85
50
86
- # Runs unit tests while limiting workers because github actions will spawn more than it can handle and crash
87
- # Continues on error but will create a comment on the pull request if this step failed.
88
51
- name : Run unit tests
89
- if : steps.unit_tests_results.outputs.unit_tests_results != 'success'
90
52
id : unit-tests
91
- continue-on-error : true
92
- run : node scripts/jest --ci --colors --maxWorkers=10
93
- env :
94
- SKIP_BAD_APPLES : true
95
-
96
- - run : echo Unit tests completed unsuccessfully. However, unit tests are inconsistent on the CI so please verify locally with `yarn test:jest`.
97
- if : steps.unit_tests_results.outputs.unit_tests_results != 'success' && steps.unit-tests.outcome != 'success'
98
-
99
- # TODO: This gets rejected, we need approval to add this
100
- # - name: Add comment if unit tests did not succeed
101
- # if: steps.unit_tests_results.outputs.unit_tests_results != 'success' && steps.unit-tests.outcome != 'success'
102
- # uses: actions/github-script@v5
103
- # with:
104
- # github-token: ${{ secrets.GITHUB_TOKEN }}
105
- # script: |
106
- # github.rest.issues.createComment({
107
- # issue_number: context.issue.number,
108
- # owner: context.repo.owner,
109
- # repo: context.repo.repo,
110
- # body: 'Unit tests completed unsuccessfully. However, unit tests are inconsistent on the CI so please verify locally with `yarn test:jest`.'
111
- # })
53
+ run : yarn test:jest:ci
112
54
113
55
- name : Run integration tests
114
- if : steps.integration_tests_results.outputs.integration_tests_results != 'success'
115
56
id : integration-tests
116
- run : node scripts/jest_integration --ci --colors --max-old-space-size=5120
117
-
118
- # Set cache if linter, unit tests, and integration tests were successful then the job will be marked successful
119
- # Sets individual results to empower re-runs of the same build without re-running successful steps.
120
- - if : |
121
- (steps.linter.outcome == 'success' || steps.linter.outcome == 'skipped') &&
122
- (steps.unit-tests.outcome == 'success' || steps.unit-tests.outcome == 'skipped') &&
123
- (steps.integration-tests.outcome == 'success' || steps.integration-tests.outcome == 'skipped')
124
- run: echo "::set-output name=job_successful::true" > job_successful
125
- - if : steps.linter.outcome == 'success' || steps.linter.outcome == 'skipped'
126
- run : echo "::set-output name=linter_results::success" > linter_results
127
- - if : steps.unit-tests.outcome == 'success' || steps.unit-tests.outcome == 'skipped'
128
- run : echo "::set-output name=unit_tests_results::success" > unit_tests_results
129
- - if : steps.integration-tests.outcome == 'success' || steps.integration-tests.outcome == 'skipped'
130
- run : echo "::set-output name=integration_tests_results::success" > integration_tests_results
57
+ run : yarn test:jest_integration:ci
58
+
131
59
functional-tests :
132
60
needs : [ build-lint-test ]
133
61
runs-on : ubuntu-latest
@@ -138,76 +66,39 @@ jobs:
138
66
steps :
139
67
- run : echo Running functional tests for ciGroup${{ matrix.group }}
140
68
141
- # Access a cache of set results from a previous run of the job
142
- # This is to prevent re-running a CI group that was already successful since it is not native to github actions
143
- # Can be used to verify flaky steps with reduced times
144
- - name : Restore the cached run
145
- uses : actions/cache@v2
146
- with :
147
- path : |
148
- ftr_tests_results
149
- key : ${{ github.run_id }}-${{ github.job }}-${{ matrix.group }}-${{ github.sha }}
150
- restore-keys : |
151
- ${{ github.run_id }}-${{ github.job }}-${{ matrix.group }}-${{ github.sha }}
152
-
153
69
- name : Get the cached tests results
154
70
id : ftr_tests_results
155
71
run : cat ftr_tests_results 2>/dev/null || echo 'default'
156
72
157
73
- name : Checkout code
158
- if : steps.ftr_tests_results.outputs.ftr_tests_results != 'success'
159
74
uses : actions/checkout@v2
160
75
161
76
- name : Setup Node
162
- if : steps.ftr_tests_results.outputs.ftr_tests_results != 'success'
163
77
uses : actions/setup-node@v2
164
78
with :
165
79
node-version-file : " .nvmrc"
166
80
registry-url : ' https://registry.npmjs.org'
167
81
168
82
- name : Setup Yarn
169
- if : steps.ftr_tests_results.outputs.ftr_tests_results != 'success'
170
83
run : |
171
84
npm uninstall -g yarn
172
85
173
86
174
- - name : Get cache path
175
- if : steps.ftr_tests_results.outputs.ftr_tests_results != 'success'
176
- id : cache-path
177
- run : echo "::set-output name=CACHE_DIR::$(yarn cache dir)"
178
-
179
- - name : Setup cache
180
- if : steps.ftr_tests_results.outputs.ftr_tests_results != 'success'
181
- uses : actions/cache@v2
182
- with :
183
- path : ${{ steps.cache-path.outputs.CACHE_DIR }}
184
- key : ${{ runner.os }}-yarn-${{ env.CACHE_NAME }}-${{ hashFiles('**/yarn.lock') }}
185
- restore-keys : |
186
- ${{ runner.os }}-yarn-${{ env.CACHE_NAME }}-
187
- ${{ runner.os }}-yarn-
188
- ${{ runner.os }}-
189
-
190
87
# github virtual env is the latest chrome
191
88
- name : Setup chromedriver
192
- if : steps.ftr_tests_results.outputs.ftr_tests_results != 'success'
193
89
run :
yarn add --dev [email protected]
194
90
195
91
- name : Run bootstrap
196
- if : steps.ftr_tests_results.outputs.ftr_tests_results != 'success'
197
92
run : yarn osd bootstrap
198
93
199
94
- name : Build plugins
200
- if : steps.ftr_tests_results.outputs.ftr_tests_results != 'success'
201
95
run : node scripts/build_opensearch_dashboards_platform_plugins --no-examples --workers 10
202
96
203
- - if : steps.ftr_tests_results.outputs.ftr_tests_results != 'success'
97
+ - name : Run CI test group ${{ matrix.group }}
204
98
id : ftr-tests
205
99
run : node scripts/functional_tests.js --config test/functional/config.js --include ciGroup${{ matrix.group }}
206
100
env :
207
101
CI_GROUP : ciGroup${{ matrix.group }}
208
102
CI_PARALLEL_PROCESS_NUMBER : ciGroup${{ matrix.group }}
209
103
JOB : ci${{ matrix.group }}
210
104
CACHE_DIR : ciGroup${{ matrix.group }}
211
-
212
- - if : steps.ftr-tests.outcome == 'success' || steps.ftr-tests.outcome == 'skipped'
213
- run : echo "::set-output name=ftr_tests_results::success" > ftr_tests_results
0 commit comments