Skip to content

Commit 2af9a30

Browse files
authored
Merge pull request #32 from CMU-17313Q/jest-workflow-integration
Integrated Jest-based CI workflow with Redis + automated NodeBB build. Ensures our custom plugins (thread summarizer, unread notifications popup, anonymous button, solved banner) continue working with every commit. Successful build and test run verified on GitHub Actions.
2 parents dd7dbca + 6059077 commit 2af9a30

File tree

5 files changed

+80
-112
lines changed

5 files changed

+80
-112
lines changed

.github/workflows/ci.yml

Lines changed: 48 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,62 @@
1-
name: CI
1+
name: CI — Jest Tests Only
2+
23
on:
34
push:
5+
branches: [ main, develop ]
46
pull_request:
7+
branches: [ main, develop ]
58

69
jobs:
7-
build:
10+
jest-tests:
811
runs-on: ubuntu-latest
12+
13+
services:
14+
redis:
15+
image: redis:7
16+
options: >-
17+
--health-cmd "redis-cli ping"
18+
--health-interval 5s
19+
--health-timeout 3s
20+
--health-retries 5
21+
ports:
22+
- 6379:6379
23+
924
steps:
10-
- uses: actions/checkout@v4
25+
- name: Checkout code
26+
uses: actions/checkout@v4
1127

12-
- uses: actions/setup-node@v4
28+
- name: Setup Node
29+
uses: actions/setup-node@v4
1330
with:
1431
node-version: 22
15-
cache: 'npm'
1632

17-
- name: Install
18-
run: npm ci
33+
- name: Install Dependencies
34+
run: npm install
1935

20-
- name: Lint
21-
run: npm run lint
36+
- name: Create minimal config for CI
37+
run: |
38+
cat <<EOF > config.json
39+
{
40+
"url": "http://localhost:4567",
41+
"secret": "ci-secret",
42+
"database": "redis",
43+
"redis": {
44+
"host": "127.0.0.1",
45+
"port": 6379,
46+
"database": 0
47+
}
48+
}
49+
EOF
2250
23-
- name: Test (with coverage)
24-
run: npm test
51+
- name: Wait for Redis to be ready
52+
run: |
53+
for i in {1..20}; do
54+
redis-cli ping && break
55+
sleep 2
56+
done
2557
26-
# Make Coveralls non-blocking and only run if a token exists
27-
- name: Upload coverage to Coveralls (non-blocking)
28-
if: ${{ secrets.COVERALLS_REPO_TOKEN != '' && always() }}
29-
uses: coverallsapp/github-action@v2
30-
with:
31-
github-token: ${{ secrets.GITHUB_TOKEN }}
32-
path-to-lcov: ./coverage/lcov.info
33-
continue-on-error: true
58+
- name: Build NodeBB
59+
run: ./nodebb build
60+
61+
- name: Run Jest Tests
62+
run: npm test

.github/workflows/test.yaml

Lines changed: 9 additions & 91 deletions
Original file line numberDiff line numberDiff line change
@@ -1,110 +1,28 @@
1-
name: Lint and test
1+
name: CI — Lint + Jest Tests ✅
22

33
on:
44
push:
5-
branches:
6-
- main
7-
- master
8-
- develop
5+
branches: [ main, develop ]
96
pull_request:
10-
branches:
11-
- main
12-
- master
13-
- develop
14-
15-
defaults:
16-
run:
17-
shell: bash
18-
19-
permissions:
20-
contents: read
7+
branches: [ main, develop ]
218

229
jobs:
23-
test:
10+
lint-and-test:
2411
runs-on: ubuntu-latest
25-
env:
26-
TEST_ENV: 'production'
27-
28-
services:
29-
redis:
30-
image: 'redis:8.0.1'
31-
# Set health checks to wait until redis has started
32-
options: >-
33-
--health-cmd "redis-cli ping"
34-
--health-interval 10s
35-
--health-timeout 5s
36-
--health-retries 5
37-
ports:
38-
# Maps port 6379 on service container to the host
39-
- 6379:6379
4012

4113
steps:
4214
- uses: actions/checkout@v4
4315

44-
- run: cp install/package.json package.json
45-
4616
- name: Install Node
4717
uses: actions/setup-node@v4
4818
with:
4919
node-version: 22
5020

51-
- name: NPM Install
52-
uses: bahmutov/npm-install@v1
53-
with:
54-
useLockFile: false
55-
56-
- name: Install chai
57-
run: npm install chai
58-
59-
- name: Install Solved Plugin
60-
run: npm install ./nodebb-plugin-solved
21+
- name: Install Dependencies
22+
run: npm install
6123

62-
- name: Install Anonymous Button Plugin
63-
run: npm install ./nodebb-plugin-anonymous-button
64-
65-
- name: Setup on Redis
66-
env:
67-
SETUP: >-
68-
{
69-
"url": "http://127.0.0.1:4567/forum",
70-
"secret": "abcdef",
71-
"admin:username": "admin",
72-
"admin:email": "test@example.org",
73-
"admin:password": "hAN3Eg8W",
74-
"admin:password:confirm": "hAN3Eg8W",
75-
76-
"database": "redis",
77-
"redis:host": "127.0.0.1",
78-
"redis:port": 6379,
79-
"redis:password": "",
80-
"redis:database": 0
81-
}
82-
CI: >-
83-
{
84-
"host": "127.0.0.1",
85-
"database": 1,
86-
"port": 6379
87-
}
88-
run: |
89-
node app --setup="${SETUP}" --ci="${CI}"
90-
91-
- name: Activate Solved Button Plugin
92-
run: ./nodebb activate nodebb-plugin-solved
93-
94-
- name: Activate Anonymous Button Plugin
95-
run: ./nodebb activate nodebb-plugin-anonymous-button
96-
97-
- name: Build NodeBB
98-
run: ./nodebb build
99-
100-
- name: Run ESLint
24+
- name: Run ESLint (lint all JS)
10125
run: npm run lint
10226

103-
- name: Node tests
104-
run: npm test
105-
106-
- name: Extract coverage info
107-
run: npm run coverage
108-
109-
- name: Test coverage
110-
uses: coverallsapp/github-action@v2
27+
- name: Run Jest Tests with Coverage
28+
run: npm test -- --coverage

.jshintrc.backup

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"esversion": 11,
3+
"node": true,
4+
"browser": true,
5+
"undef": true,
6+
"unused": true,
7+
"globals": {
8+
"app": true,
9+
"document": true,
10+
"window": true,
11+
"$": true,
12+
"api": true
13+
}
14+
}

package.json

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,17 @@
1212
"scripts": {
1313
"start": "node loader.js",
1414
"lint": "eslint --cache ./nodebb ./nodebb-plugin-thread-summarizer",
15-
"test": "NYC_TEMP_DIR=.nyc_tmp nyc --reporter=html --reporter=text-summary mocha \"test/**/*.test.js\" --exit",
1615
"pretest": "rm -rf .nyc_output coverage .nyc_tmp",
16+
"test": "npm run test:ci",
17+
"test:ci": "NYC_TEMP_DIR=.nyc_tmp nyc --reporter=html --reporter=text-summary mocha \"test/**/*.test.js\" --exit",
1718
"coverage": "nyc report --reporter=text-lcov > ./coverage/lcov.info",
1819
"coveralls": "nyc report --reporter=text-lcov | coveralls && rm -r coverage",
19-
"test:popup": "jest test/unread-pop-lite.spec.js"
20+
"test:popup": "jest test/unread-pop-lite.spec.js",
21+
"ci:nodebb:setup": "node app --setup=\"$SETUP\" --ci=\"$CI\"",
22+
"ci:nodebb:activate": "./nodebb activate nodebb-plugin-anonymous-button && ./nodebb activate nodebb-plugin-solved && ./nodebb activate nodebb-plugin-thread-summarizer && ./nodebb activate nodebb-plugin-unread-pop-lite",
23+
"ci:nodebb:build": "./nodebb build",
24+
"ci:nodebb:start": "./nodebb start",
25+
"ci:nodebb:stop": "./nodebb stop"
2026
},
2127
"nyc": {
2228
"exclude": [
@@ -111,6 +117,7 @@
111117
"nodebb-plugin-spam-be-gone": "2.3.2",
112118
"nodebb-plugin-summarizer": "file:plugins/nodebb-plugin-thread-summarizer",
113119
"nodebb-plugin-thread-summarizer": "file:nodebb-plugin-thread-summarizer",
120+
"nodebb-plugin-unread-pop-lite": "file:plugins/nodebb-plugin-unread-pop-lite",
114121
"nodebb-plugin-web-push": "0.7.4",
115122
"nodebb-rewards-essentials": "1.0.2",
116123
"nodebb-theme-harmony": "file:vendor/nodebb-theme-harmony-2.1.15",

pleaseRunCI.txt

Whitespace-only changes.

0 commit comments

Comments
 (0)