generated from oplik0/nodebb-plugin-quickstart
-
-
Notifications
You must be signed in to change notification settings - Fork 1
199 lines (193 loc) · 6.77 KB
/
test.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
on:
push:
pull_request:
workflow_dispatch:
permissions:
contents: read
name: Test
jobs:
test:
runs-on: ${{ matrix.os }}
name: "Test Plugin on NodeBB ${{ matrix.nodebb }} (Node.js ${{ matrix.node }}, ${{ matrix.database }}${{ matrix.lint && ', linting enabled' }})"
strategy:
matrix:
os: [ubuntu-latest]
node: [18, 20] # versions currently supported by NodeBB
database: [mongo] # you can add redis and postgres here if you're touching the database more directly
nodebb: [master, v3.x, v2.x] # branches or tags
include:
- os: ubuntu-latest
node: 18
database: mongo
nodebb: master
lint: true # we only want to lint once
exclude:
# pre-release means living on the edge... of LTS releases too I guess
- nodebb: master
node: 18
services:
postgres:
image: ${{ startsWith(matrix.database, 'postgres') && 'postgres:15-alpine' || '' }}
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
# Set health checks to wait until postgres has started
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
# Maps port 5432 on service container to the host
- 5432:5432
redis:
image: ${{ startsWith(matrix.database, 'redis') && 'redis:7.0.11' || '' }}
# Set health checks to wait until redis has started
options: >-
--health-cmd "redis-cli ping"
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
# Maps port 6379 on service container to the host
- 6379:6379
mongo:
image: ${{ startsWith(matrix.database, 'mongo') && 'mongo:3.7' || ''}}
ports:
# Maps port 27017 on service container to the host
- 27017:27017
meilisearch:
image: getmeili/meilisearch:latest
ports:
- 7700:7700
steps:
- uses: actions/checkout@v4
with:
repository: NodeBB/NodeBB
ref: ${{ matrix.nodebb }}
path: nodebb
- uses: actions/checkout@v4
with:
path: tested-plugin
- name: Prepare NodeBB package.json
run: cp install/package.json package.json
working-directory: nodebb
- uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node }}
- name: Install plugin dependencies
working-directory: tested-plugin
run: yarn
- name: Run ESLint
if: matrix.lint
working-directory: tested-plugin
run: yarn lint
- name: Get npm cache directory
id: npm-cache-dir
shell: bash
run: echo "dir=$(npm config get cache)" >> ${GITHUB_OUTPUT}
- uses: actions/cache@v4
id: npm-cache # use this to check for `cache-hit` ==> if: steps.npm-cache.outputs.cache-hit != 'true'
with:
path: ${{ steps.npm-cache-dir.outputs.dir }}
key: ${{ runner.os }}-node-${{ hashFiles('**/package.json') }}
restore-keys: |
${{ runner.os }}-node-
- name: Get plugin name
id: pluginName
run: echo "NAME=$(node -e "console.log(require('./tested-plugin/package.json').name)")" >> "$GITHUB_OUTPUT"
- name: Install dependencies
run: yarn
working-directory: nodebb
- name: Install tested plugin
run: yarn add $GITHUB_WORKSPACE/tested-plugin
working-directory: nodebb
- name: Setup on MongoDB
if: startsWith(matrix.database, 'mongo')
env:
SETUP: >-
{
"url": "http://127.0.0.1:4567",
"secret": "abcdef",
"admin:username": "admin",
"admin:email": "[email protected]",
"admin:password": "hAN3Eg8W",
"admin:password:confirm": "hAN3Eg8W",
"database": "mongo",
"mongo:host": "127.0.0.1",
"mongo:port": 27017,
"mongo:username": "",
"mongo:password": "",
"mongo:database": "nodebb"
}
CI: >-
{
"host": "127.0.0.1",
"port": 27017,
"database": "ci_test"
}
run: |
node app --setup="${SETUP}" --ci="${CI}"
working-directory: nodebb
- name: Setup on PostgreSQL
if: startsWith(matrix.database, 'postgres')
env:
SETUP: >-
{
"url": "http://127.0.0.1:4567",
"secret": "abcdef",
"admin:username": "admin",
"admin:email": "[email protected]",
"admin:password": "hAN3Eg8W",
"admin:password:confirm": "hAN3Eg8W",
"database": "postgres",
"postgres:host": "127.0.0.1",
"postgres:port": 5432,
"postgres:username": "postgres",
"postgres:password": "postgres",
"postgres:database": "nodebb"
}
CI: >-
{
"host": "127.0.0.1",
"database": "ci_test",
"port": 5432,
"username": "postgres",
"password": "postgres"
}
run: |
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())"
node app --setup="${SETUP}" --ci="${CI}"
working-directory: nodebb
- name: Setup on Redis
if: startsWith(matrix.database, 'redis')
env:
SETUP: >-
{
"url": "http://127.0.0.1:4567/forum",
"secret": "abcdef",
"admin:username": "admin",
"admin:email": "[email protected]",
"admin:password": "hAN3Eg8W",
"admin:password:confirm": "hAN3Eg8W",
"database": "redis",
"redis:host": "127.0.0.1",
"redis:port": 6379,
"redis:password": "",
"redis:database": 0
}
CI: >-
{
"host": "127.0.0.1",
"database": 1,
"port": 6379
}
run: |
node app --setup="${SETUP}" --ci="${CI}"
working-directory: nodebb
- name: Add tested plugin to config
run: jq '.test_plugins = ["${{ steps.pluginName.outputs.NAME }}"]' config.json > config.json.tmp && mv config.json.tmp config.json
working-directory: nodebb
- name: Run tests
run: npm test test/plugins-installed.js
working-directory: nodebb