1212
1313jobs :
1414
15- # Build bundle, doc and run tests (unit, functional and coverage)
16- tests :
17- name : Build and test validation
15+ # Build bundle, doc and check linter
16+ build :
17+ name : Build bundle, check Linter and generate documentation
1818 runs-on : ubuntu-latest
1919 steps :
2020
2424 uses : actions/setup-node@v3
2525 with :
2626 node-version : 16.x
27+ cache : ' npm'
2728
2829 # Install packages
29- # TODO: add cache npm to speed up installing
3030 - name : Install packages
3131 run : npm ci
3232
@@ -43,30 +43,14 @@ jobs:
4343 if : ${{ success() }}
4444 run : npm run build
4545
46- # Run unit tests
47- - name : Unit tests
48- run : npm run test-with-coverage_lcov
49-
50- # Run functional tests
51- # TODO: functional tests don't stop if one fails
52- - name : Functional tests
53- if : ${{ success() }}
54- run : npm run test-functional
55-
56- # Code coverage
57- - name : Coveralls
58- uses : coverallsapp/github-action@master
59- with :
60- github-token : ${{ secrets.GITHUB_TOKEN }}
61-
6246 # Build documentation
6347 - name : Build documentation
6448 if : ${{ success() && github.ref == 'refs/heads/master' }}
6549 run : npm run doc -- -d buildDocs
6650
6751 # Prepare archive for deploying
6852 - name : Archive production artifacts
69- if : ${{ success() && github.ref == 'refs/heads/master' }}
53+ if : ${{ success() }}
7054 uses : actions/upload-artifact@v3
7155 with :
7256 name : dist-itowns
@@ -92,11 +76,70 @@ jobs:
9276 accessToken : ${{ secrets.GITHUB_TOKEN }}
9377
9478
79+ # Unit and coverage tests
80+ unit-and-coverage-tests :
81+ name : Unit and coverage tests
82+ needs : build
83+ runs-on : ubuntu-latest
84+ steps :
85+
86+ # Use specific Node.js version
87+ - uses : actions/checkout@v3
88+ - name : Use Node.js 16.x
89+ uses : actions/setup-node@v3
90+ with :
91+ node-version : 16.x
92+ cache : ' npm'
93+
94+ # Install packages
95+ - name : Install packages
96+ run : npm ci
97+
98+ - name : Run unit tests
99+ run : npm run test-with-coverage_lcov
100+
101+ # Code coverage
102+ - name : Coveralls
103+ if : ${{ success() }}
104+ uses : coverallsapp/github-action@master
105+ with :
106+ github-token : ${{ secrets.GITHUB_TOKEN }}
107+
108+
109+ # Functional tests
110+ functional-tests :
111+ name : Functional tests
112+ needs : build
113+ runs-on : ubuntu-latest
114+ steps :
115+
116+ # Use specific Node.js version
117+ - uses : actions/checkout@v3
118+ - name : Use Node.js 16.x
119+ uses : actions/setup-node@v3
120+ with :
121+ node-version : 16.x
122+ cache : ' npm'
123+
124+ # Install packages
125+ - name : Install packages
126+ run : npm ci
127+
128+ # Download artifact from build
129+ - name : Download itowns bundle
130+ uses : actions/download-artifact@v3
131+ with :
132+ name : dist-itowns
133+
134+ - name : Run functional tests
135+ run : npm run test-functional
136+
137+
95138 # Publish NPM package
96139 publish :
97140 name : Publish NPM package
98141 if : ${{ github.ref == 'refs/heads/master' }}
99- needs : [tests, check-commit-message]
142+ needs : [unit-and-coverage-tests, functional- tests, check-commit-message]
100143 runs-on : ubuntu-latest
101144 steps :
102145
@@ -147,7 +190,7 @@ jobs:
147190 deploy :
148191 name : Deploy to itowns.github.io
149192 if : ${{ github.ref == 'refs/heads/master' }}
150- needs : [tests, check-commit-message]
193+ needs : [unit-and-coverage-tests, functional- tests, check-commit-message]
151194 runs-on : ubuntu-latest
152195 steps :
153196
@@ -208,7 +251,7 @@ jobs:
208251 release :
209252 name : Release GitHub
210253 if : ${{ github.ref == 'refs/heads/master' && startsWith( github.event.head_commit.message, 'release v' ) }}
211- needs : [tests, check-commit-message]
254+ needs : [unit-and-coverage-tests, functional- tests, check-commit-message]
212255 runs-on : ubuntu-latest
213256 steps :
214257
0 commit comments