@@ -3,10 +3,12 @@ name: Lint and test
33on :
44 push :
55 branches :
6+ - main
67 - master
78 - develop
89 pull_request :
910 branches :
11+ - main
1012 - master
1113 - develop
1214
@@ -19,49 +21,11 @@ permissions:
1921
2022jobs :
2123 test :
22- permissions :
23- checks : write # for coverallsapp/github-action to create new checks
24- contents : read # for actions/checkout to fetch code
25- name : Lint and test
26- strategy :
27- fail-fast : false
28- matrix :
29- os : [ubuntu-latest]
30- node : [20, 22]
31- database : [mongo-dev, mongo, redis, postgres]
32- include :
33- # only run coverage once
34- - os : ubuntu-latest
35- node : 22
36- coverage : true
37- # test under development once
38- - database : mongo-dev
39- test_env : development
40- # only run eslint once
41- - os : ubuntu-latest
42- node : 22
43- database : mongo-dev
44- lint : true
45- runs-on : ${{ matrix.os }}
24+ runs-on : ubuntu-latest
4625 env :
47- TEST_ENV : ${{ matrix.test_env || 'production' }}
26+ TEST_ENV : ' production'
4827
4928 services :
50- postgres :
51- image : ' postgres:17-alpine'
52- env :
53- POSTGRES_USER : postgres
54- POSTGRES_PASSWORD : postgres
55- # Set health checks to wait until postgres has started
56- options : >-
57- --health-cmd pg_isready
58- --health-interval 10s
59- --health-timeout 5s
60- --health-retries 5
61- ports :
62- # Maps port 5432 on service container to the host
63- - 5432:5432
64-
6529 redis :
6630 image : ' redis:8.0.1'
6731 # Set health checks to wait until redis has started
7438 # Maps port 6379 on service container to the host
7539 - 6379:6379
7640
77- mongo :
78- image : ' mongo:8.0'
79- ports :
80- # Maps port 27017 on service container to the host
81- - 27017:27017
82-
8341 steps :
8442 - uses : actions/checkout@v4
8543
@@ -88,74 +46,14 @@ jobs:
8846 - name : Install Node
8947 uses : actions/setup-node@v4
9048 with :
91- node-version : ${{ matrix.node }}
49+ node-version : 22
9250
9351 - name : NPM Install
9452 uses : bahmutov/npm-install@v1
9553 with :
9654 useLockFile : false
9755
98- - name : Setup on MongoDB
99- if : startsWith(matrix.database, 'mongo')
100- env :
101- SETUP : >-
102- {
103- "url": "http://127.0.0.1:4567",
104- "secret": "abcdef",
105- "admin:username": "admin",
106- "admin:email": "test@example.org",
107- "admin:password": "hAN3Eg8W",
108- "admin:password:confirm": "hAN3Eg8W",
109-
110- "database": "mongo",
111- "mongo:host": "127.0.0.1",
112- "mongo:port": 27017,
113- "mongo:username": "",
114- "mongo:password": "",
115- "mongo:database": "nodebb"
116- }
117- CI : >-
118- {
119- "host": "127.0.0.1",
120- "port": 27017,
121- "database": "ci_test"
122- }
123- run : |
124- node app --setup="${SETUP}" --ci="${CI}"
125-
126- - name : Setup on PostgreSQL
127- if : startsWith(matrix.database, 'postgres')
128- env :
129- SETUP : >-
130- {
131- "url": "http://127.0.0.1:4567",
132- "secret": "abcdef",
133- "admin:username": "admin",
134- "admin:email": "test@example.org",
135- "admin:password": "hAN3Eg8W",
136- "admin:password:confirm": "hAN3Eg8W",
137-
138- "database": "postgres",
139- "postgres:host": "127.0.0.1",
140- "postgres:port": 5432,
141- "postgres:username": "postgres",
142- "postgres:password": "postgres",
143- "postgres:database": "nodebb"
144- }
145- CI : >-
146- {
147- "host": "127.0.0.1",
148- "database": "ci_test",
149- "port": 5432,
150- "username": "postgres",
151- "password": "postgres"
152- }
153- run : |
154- node -e "const { Client } = require('pg'); const c = new Client({ host: '127.0.0.1', port: 5432, user: 'postgres', password: 'postgres' }); c.connect().then(() => c.query('CREATE DATABASE nodebb')).then(() => c.query('CREATE DATABASE ci_test')).then(() => c.end())"
155- node app --setup="${SETUP}" --ci="${CI}"
156-
15756 - name : Setup on Redis
158- if : startsWith(matrix.database, 'redis')
15957 env :
16058 SETUP : >-
16159 {
18280 node app --setup="${SETUP}" --ci="${CI}"
18381
18482 - name : Run ESLint
185- if : matrix.lint
18683 run : npm run lint
18784
18885 - name : Node tests
@@ -192,21 +89,4 @@ jobs:
19289 run : npm run coverage
19390
19491 - name : Test coverage
195- uses : coverallsapp/github-action@648a8eb78e6d50909eff900e4ec85cab4524a45b # v2.3.6
196- if : matrix.coverage
197- with :
198- github-token : ${{ secrets.GITHUB_TOKEN }}
199- flag-name : ${{ matrix.os }}-node-${{ matrix.node }}-db-${{ matrix.database }}
200- parallel : true
201-
202- finish :
203- permissions :
204- checks : write # for coverallsapp/github-action to create new checks
205- needs : test
206- runs-on : ubuntu-latest
207- steps :
208- - name : Coveralls Finished
209- uses : coverallsapp/github-action@648a8eb78e6d50909eff900e4ec85cab4524a45b # v2.3.6
210- with :
211- github-token : ${{ secrets.GITHUB_TOKEN }}
212- parallel-finished : true
92+ uses : coverallsapp/github-action@v2
0 commit comments