1
1
# This workflow will do a clean install of node dependencies, build the source code,
2
- # run unit tests, and perform a SonarCloud scan.
2
+ # run unit tests, perform a Sonarqube scan, and publish NPM artifacts from master/main .
3
3
4
4
# For more information see:
5
5
# https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions
6
6
7
- # Common FOLIO configurable env :
7
+ # Common FOLIO configurable environment variables to set :
8
8
# - YARN_TEST_OPTIONS (options to pass to 'yarn test')
9
- # - SQ_ROOT_DIR (where to scan relative to top-level directory)
10
- # - FOLIO_NAME
9
+ # - SQ_ROOT_DIR (root SQ directory to scan relative to top-level directory)
11
10
# - PUBLISH_MOD_DESCRIPTOR (boolean 'true' or 'false')
12
11
# - COMPILE_TRANSLATION_FILES (boolean 'true' or 'false')
13
12
14
13
15
14
16
15
name : buildNPM Snapshot
17
16
on : [push, pull_request]
17
+
18
18
jobs :
19
- build-npm :
19
+ github-actions-ci :
20
20
env :
21
- YARN_TEST_OPTIONS : ' --ci --coverage --colors '
21
+ YARN_TEST_OPTIONS : ' '
22
22
SQ_ROOT_DIR : ' ./src'
23
- PUBLISH_MOD_DESCRIPTOR : ' false '
24
- COMPILE_TRANSLATION_FILES : ' false '
23
+ COMPILE_TRANSLATION_FILES : ' true '
24
+ PUBLISH_MOD_DESCRIPTOR : ' true '
25
25
FOLIO_NPM_REGISTRY : ' https://repository.folio.org/repository/npm-folioci/'
26
26
FOLIO_NPM_REGISTRY_AUTH : ' //repository.folio.org/repository/npm-folioci/'
27
27
FOLIO_MD_REGISTRY : ' https://folio-registry.dev.folio.org'
28
28
NODEJS_VERSION : ' 18'
29
29
JEST_JUNIT_OUTPUT_DIR : ' artifacts/jest-junit'
30
30
JEST_COVERAGE_REPORT_DIR : ' artifacts/coverage-jest/lcov-report/'
31
+ BIGTEST_JUNIT_OUTPUT_DIR : ' artifacts/runTest'
32
+ BIGTEST_COVERAGE_REPORT_DIR : ' artifacts/coverage/lcov-report/'
31
33
SQ_LCOV_REPORT : ' artifacts/coverage-jest/lcov.info'
32
34
SQ_EXCLUSIONS : ' **/platform/alias-service.js,**/docs/**,**/node_modules/**,**/examples/**,**/artifacts/**,**/ci/**,Jenkinsfile,**/LICENSE,**/*.css,**/*.md,**/*.json,**/tests/**,**/stories/*.js,**/test/**,**/.stories.js,**/resources/bigtest/interactors/**,**/resources/bigtest/network/**,**/*-test.js,**/*.test.js,**/*-spec.js,**/karma.conf.js,**/jest.config.js'
33
35
34
36
runs-on : ubuntu-latest
35
37
steps :
36
- - uses : actions /checkout@v2
38
+ - uses : folio-org /checkout@v2
37
39
with :
38
40
fetch-depth : 0
39
41
@@ -67,39 +69,30 @@ jobs:
67
69
run : yarn lint
68
70
continue-on-error : true
69
71
70
- - name : Get number of CPU cores
71
- id : cpu-cores
72
- uses : SimenB/github-actions-cpu-cores@v1
73
-
74
72
- name : Run yarn test
75
- run : xvfb-run --server-args="-screen 0 1024x768x24" yarn test $YARN_TEST_OPTIONS --max-workers ${{ steps.cpu-cores.outputs.count }}
73
+ run : xvfb-run --server-args="-screen 0 1024x768x24" yarn test $YARN_TEST_OPTIONS
76
74
77
75
- name : Run yarn formatjs-compile
78
- if : ${{ env.COMPILE_TRANSLATION_FILES == 'true' }}
76
+ if : ${{ env.COMPILE_TRANSLATION_FILES == 'true' }}
79
77
run : yarn formatjs-compile
80
78
81
- - name : Generate Module descriptor
79
+ - name : Generate FOLIO module descriptor
82
80
if : ${{ env.PUBLISH_MOD_DESCRIPTOR == 'true' }}
83
81
run : yarn build-mod-descriptor
84
82
85
- - name : debug mod descriptor
83
+ - name : Print FOLIO module descriptor
86
84
if : ${{ env.PUBLISH_MOD_DESCRIPTOR == 'true' }}
87
85
run : cat module-descriptor.json
88
86
89
- - name : Upload event file
90
- uses : actions/upload-artifact@v3
91
- with :
92
- name : Event File
93
- path : ${{ github.event_path }}
94
- retention-days : 30
95
-
96
- - name : Upload Jest results
87
+ - name : Publish Jest unit test results
88
+ uses : docker://ghcr.io/enricomi/publish-unit-test-result-action:v1
97
89
if : always()
98
- uses : actions/upload-artifact@v3
99
90
with :
100
- name : jest-test-results
101
- path : ${{ env.JEST_JUNIT_OUTPUT_DIR }}/*.xml
102
- retention-days : 30
91
+ github_token : ${{ github.token }}
92
+ files : " ${{ env.JEST_JUNIT_OUTPUT_DIR }}/*.xml"
93
+ check_name : Jest Unit Test Results
94
+ comment_mode : update last
95
+ comment_title : Jest Unit Test Statistics
103
96
104
97
- name : Publish Jest coverage report
105
98
uses : actions/upload-artifact@v2
@@ -109,6 +102,32 @@ jobs:
109
102
path : ${{ env.JEST_COVERAGE_REPORT_DIR }}
110
103
retention-days : 30
111
104
105
+ - name : Publish BigTest unit test results
106
+ uses : docker://ghcr.io/enricomi/publish-unit-test-result-action:v1
107
+ if : always()
108
+ with :
109
+ github_token : ${{ github.token }}
110
+ files : " ${{ env.BIGTEST_JUNIT_OUTPUT_DIR }}/*.xml"
111
+ check_name : BigTest Unit Test Results
112
+ comment_mode : update last
113
+ comment_title : BigTest Unit Test Statistics
114
+
115
+ - name : Publish BigTest coverage report
116
+ uses : actions/upload-artifact@v2
117
+ if : always()
118
+ with :
119
+ name : bigtest-coverage-report
120
+ path : ${{ env.BIGTEST_COVERAGE_REPORT_DIR }}
121
+ retention-days : 30
122
+
123
+ - name : Publish yarn.lock
124
+ uses : actions/upload-artifact@v2
125
+ if : failure()
126
+ with :
127
+ name : yarn.lock
128
+ path : yarn.lock
129
+ retention-days : 5
130
+
112
131
- name : Set default branch as env variable
113
132
run : echo "DEFAULT_BRANCH=${{ github.event.repository.default_branch }}" >> $GITHUB_ENV
114
133
@@ -139,13 +158,15 @@ jobs:
139
158
always-auth : true
140
159
141
160
- name : Set _auth in .npmrc
161
+ if : ${{ github.ref == 'refs/heads/master' || github.ref == 'refs/heads/main' }}
142
162
run : |
143
163
npm config set @folio:registry $FOLIO_NPM_REGISTRY
144
164
npm config set $FOLIO_NPM_REGISTRY_AUTH:_auth $NODE_AUTH_TOKEN
145
165
env :
146
166
NODE_AUTH_TOKEN : ${{ secrets.NPM_TOKEN }}
147
167
148
168
- name : Exclude some CI-generated artifacts in package
169
+ if : ${{ github.ref == 'refs/heads/master' || github.ref == 'refs/heads/main' }}
149
170
run : |
150
171
echo "artifacts" >> .npmignore
151
172
echo ".github" >> .npmignore
@@ -178,19 +199,3 @@ jobs:
178
199
username : ${{ secrets.FOLIO_REGISTRY_USERNAME }}
179
200
password : ${{ secrets.FOLIO_REGISTRY_PASSWORD }}
180
201
181
- # restoring "github-actions-ci" with some dummy steps
182
- # to maybe allow PR #14 to succeed, where it is stuck
183
- # in "Waiting for status to be reported" ATM.
184
- github-actions-ci :
185
- runs-on : ubuntu-latest
186
- steps :
187
- - uses : folio-org/checkout@v2
188
- with :
189
- fetch-depth : 0
190
-
191
- - name : Use Node.js
192
- uses : actions/setup-node@v2
193
- with :
194
- node-version : ${{ env.NODEJS_VERSION }}
195
- check-latest : true
196
- always-auth : true
0 commit comments