windows + browser + NodeJS + postgres #73
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Compatibility testing | |
| run-name: windows + browser + NodeJS + postgres | |
| on: | |
| workflow_dispatch: | |
| jobs: | |
| compatibility-tests: | |
| runs-on: windows-latest | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| node: [14, 18, 20] | |
| browser: [chrome, firefox, edge] | |
| steps: | |
| - name: Checkout Repo | |
| uses: actions/checkout@v4 | |
| with: | |
| path: mainrepo | |
| - name: Checkout Wiki.js source | |
| run: | | |
| Invoke-WebRequest https://github.com/Requarks/wiki/releases/latest/download/wiki-js.tar.gz -OutFile wiki-js.tar.gz | |
| mkdir wikijs | |
| tar -xzf wiki-js.tar.gz -C .\wikijs | |
| cd wikijs | |
| Copy-Item config.sample.yml config.yml | |
| - name: Setup Node.js ${{ matrix.node }} | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: ${{ matrix.node }} | |
| # Cài PostgreSQL 15 bằng Chocolatey | |
| - name: Install PostgreSQL | |
| run: | | |
| choco install postgresql15 --params '/Password: wikijsrocks /Username:postgres' -y | |
| Start-Sleep -Seconds 20 | |
| # Thêm PostgreSQL bin vào PATH để dùng createdb/psql | |
| - name: Add PostgreSQL to PATH | |
| run: | | |
| echo "C:\Program Files\PostgreSQL\15\bin" >> $env:GITHUB_PATH | |
| - name: Wait for Postgres | |
| run: | | |
| $env:PGPASSWORD="wikijsrocks" | |
| for ($i=0; $i -lt 10; $i++) { | |
| try { | |
| pg_isready -h localhost -U postgres | |
| if ($LASTEXITCODE -eq 0) { exit 0 } | |
| } catch {} | |
| Start-Sleep -Seconds 5 | |
| } | |
| exit 1 | |
| - name: Create Wiki.js User + DB | |
| shell: pwsh | |
| run: | | |
| $env:PGPASSWORD="wikijsrocks" | |
| & "C:\Program Files\PostgreSQL\15\bin\psql.exe" -U postgres -d postgres -c "CREATE USER wikijs WITH PASSWORD 'wikijsrocks' SUPERUSER;" | |
| & "C:\Program Files\PostgreSQL\15\bin\psql.exe" -U postgres -d postgres -c "CREATE DATABASE wiki OWNER wikijs;" | |
| - name: Test Postgres login | |
| run: | | |
| $env:PGPASSWORD="wikijsrocks" | |
| & "C:\Program Files\PostgreSQL\15\bin\psql.exe" -h localhost -U postgres -d postgres -c "SELECT version();" | |
| - name: Set Database ENV | |
| run: | | |
| echo "DB_TYPE=postgres" >> $env:GITHUB_ENV | |
| echo "DB_HOST=localhost" >> $env:GITHUB_ENV | |
| echo "DB_PORT=5432" >> $env:GITHUB_ENV | |
| echo "DB_USER=wikijs" >> $env:GITHUB_ENV | |
| echo "DB_PASS=wikijsrocks" >> $env:GITHUB_ENV | |
| echo "DB_NAME=wiki" >> $env:GITHUB_ENV | |
| - name: Install dependencies | |
| run: | | |
| cd wikijs | |
| npm install --no-audit --no-fund --legacy-peer-deps | |
| - name: Build Wiki.js | |
| run: | | |
| cd wikijs | |
| echo "Running build on Node ${{ matrix.node }} and Browser ${{ matrix.browser }}" | |
| npm rebuild sqlite3 | |
| - name: Configure Wiki.js DB | |
| run: | | |
| Set-Content -Path wikijs/config.yml -Value @" | |
| port: 3000 | |
| bindIP: 0.0.0.0 | |
| db: | |
| type: postgres | |
| host: localhost | |
| port: 5432 | |
| user: wikijs | |
| pass: wikijsrocks | |
| db: wiki | |
| ssl: false | |
| autoMigrate: true | |
| logLevel: info | |
| "@ | |
| - name: Start Wiki.js server | |
| run: | | |
| cd wikijs | |
| Start-Process powershell -ArgumentList "node server > server.log 2>&1" -NoNewWindow | |
| Start-Sleep -Seconds 20 | |
| Get-Content server.log | |