1- name : CI - Wiki.js Compatibility Testing
1+ name : Compatibility testing
2+ run-name : windows + browser + NodeJS + postgres
23
3- on : [push, pull_request]
4+ on :
5+ workflow_dispatch :
46
57jobs :
6- test :
8+ compatibility-tests :
79 runs-on : windows-latest
8-
9- services :
10- postgres :
11- image : postgres:15
12- env :
13- POSTGRES_USER : postgres
14- POSTGRES_PASSWORD : postgres
15- POSTGRES_DB : postgres
16- ports :
17- - 5432:5432
18- options : >-
19- --health-cmd="pg_isready -U postgres"
20- --health-interval=10s
21- --health-timeout=5s
22- --health-retries=5
10+ strategy :
11+ fail-fast : false
12+ matrix :
13+ node : [14, 18, 20]
14+ browser : [chrome, firefox, edge]
2315
2416 steps :
25- - name : Checkout repository
17+ - name : Checkout Repo
2618 uses : actions/checkout@v4
19+ with :
20+ path : mainrepo
2721
28- - name : Setup Node.js
22+ - name : Checkout Wiki.js source
23+ run : |
24+ Invoke-WebRequest https://github.com/Requarks/wiki/releases/latest/download/wiki-js.tar.gz -OutFile wiki-js.tar.gz
25+ mkdir wikijs
26+ tar -xzf wiki-js.tar.gz -C .\wikijs
27+ cd wikijs
28+ Copy-Item config.sample.yml config.yml
29+
30+ - name : Setup Node.js ${{ matrix.node }}
2931 uses : actions/setup-node@v4
3032 with :
31- node-version : 20
33+ node-version : ${{ matrix.node }}
3234
33- - name : Install dependencies
34- run : npm install
35+ # Cài PostgreSQL 15 bằng Chocolatey
36+ - name : Install PostgreSQL
37+ run : |
38+ choco install postgresql15 --params '/Password: wikijsrocks /Username:postgres' -y
39+ Start-Sleep -Seconds 20
3540
36- - name : Create Wiki.js database & user
41+ # Thêm PostgreSQL bin vào PATH để dùng createdb/psql
42+ - name : Add PostgreSQL to PATH
3743 run : |
38- psql -h localhost -U postgres -d postgres -c "CREATE USER wikijs WITH PASSWORD 'wikijsrocks' SUPERUSER;"
39- psql -h localhost -U postgres -d postgres -c "CREATE DATABASE wiki OWNER wikijs;"
40- env :
41- PGPASSWORD : postgres
44+ echo "C:\Program Files\PostgreSQL\15\bin" >> $env:GITHUB_PATH
4245
43- - name : Configure Wiki.js
46+ - name : Wait for Postgres
47+ run : |
48+ $env:PGPASSWORD="wikijsrocks"
49+ for ($i=0; $i -lt 10; $i++) {
50+ try {
51+ pg_isready -h localhost -U postgres
52+ if ($LASTEXITCODE -eq 0) { exit 0 }
53+ } catch {}
54+ Start-Sleep -Seconds 5
55+ }
56+ exit 1
57+
58+ - name : Create Wiki.js User + DB
59+ shell : pwsh
60+ run : |
61+ $env:PGPASSWORD="wikijsrocks"
62+ & "C:\Program Files\PostgreSQL\15\bin\psql.exe" -U postgres -d postgres -c "CREATE USER wikijs WITH PASSWORD 'wikijsrocks' SUPERUSER;"
63+ & "C:\Program Files\PostgreSQL\15\bin\psql.exe" -U postgres -d postgres -c "CREATE DATABASE wiki OWNER wikijs;"
64+
65+ - name : Test Postgres login
66+ run : |
67+ $env:PGPASSWORD="wikijsrocks"
68+ & "C:\Program Files\PostgreSQL\15\bin\psql.exe" -h localhost -U postgres -d postgres -c "SELECT version();"
69+
70+ - name : Set Database ENV
71+ run : |
72+ echo "DB_TYPE=postgres" >> $env:GITHUB_ENV
73+ echo "DB_HOST=localhost" >> $env:GITHUB_ENV
74+ echo "DB_PORT=5432" >> $env:GITHUB_ENV
75+ echo "DB_USER=wikijs" >> $env:GITHUB_ENV
76+ echo "DB_PASS=wikijsrocks" >> $env:GITHUB_ENV
77+ echo "DB_NAME=wiki" >> $env:GITHUB_ENV
78+
79+ - name : Install dependencies
80+ run : |
81+ cd wikijs
82+ npm install --no-audit --no-fund --legacy-peer-deps
83+
84+ - name : Build Wiki.js
85+ run : |
86+ cd wikijs
87+ echo "Running build on Node ${{ matrix.node }} and Browser ${{ matrix.browser }}"
88+ npm rebuild sqlite3
89+ - name : Configure Wiki.js DB
4490 run : |
45- mkdir -p wikijs
4691 Set-Content -Path wikijs/config.yml -Value @"
4792 port: 3000
4893 bindIP: 0.0.0.0
@@ -54,26 +99,14 @@ jobs:
5499 pass: wikijsrocks
55100 db: wiki
56101 ssl: false
102+ autoMigrate: true
57103 logLevel: info
58104 "@
59-
60- - name : Start Wiki.js
105+
106+ - name : Start Wiki.js server
61107 run : |
62108 cd wikijs
63- nohup node server > ../wikijs.log 2>&1 &
64-
65- - name : Wait for Wiki.js to be ready
66- run : |
67- echo "⏳ Waiting for Wiki.js to start..."
68- for /l %i in (1,1,30) do (
69- curl -s http://localhost:3000 >nul 2>&1 && echo "✅ Wiki.js is up!" && exit 0
70- timeout /t 2 >nul
71- )
72- echo "❌ Wiki.js failed to start in time"
73- exit 1
109+ Start-Process powershell -ArgumentList "node server > server.log 2>&1" -NoNewWindow
110+ Start-Sleep -Seconds 20
111+ Get-Content server.log
74112
75- - name : Run Playwright tests (Chromium + Edge)
76- run : |
77- npx playwright install --with-deps
78- npx playwright test --config=playwright.config.ts --project=chromium
79- npx playwright test --config=playwright.config.ts --project=msedge
0 commit comments