ci: add separate build/lint job with caching in CI #102
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: Run tests | |
| on: [push, pull_request] | |
| defaults: | |
| run: | |
| shell: bash | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Setup repository | |
| uses: actions/checkout@v4 | |
| - name: Setup NodeJS | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '20.x' | |
| cache: 'npm' | |
| - name: Build extension | |
| run: npm run compile | |
| - name: Run linter | |
| run: npm run lint | |
| - name: Save cache | |
| id: build-cache | |
| uses: actions/cache@v4 | |
| if: success() | |
| with: | |
| path: | | |
| node_modules | |
| out | |
| key: cache-${{ runner.os }}-${{ hashFiles('src/**/*.ts') }} | |
| test: | |
| runs-on: ubuntu-latest | |
| needs: build | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| pgversion: ['17', '16', '15', '14', '13', '12', '11', '10', '9.6'] | |
| steps: | |
| - name: Setup repository | |
| uses: actions/checkout@v4 | |
| - name: Restore cache | |
| uses: actions/cache/restore@v4 | |
| with: | |
| path: | | |
| node_modules | |
| out | |
| key: cache-${{ runner.os }}-${{ hashFiles('src/**/*.ts') }} | |
| fail-on-cache-miss: true | |
| - name: Setup NodeJS | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '20.x' | |
| cache: 'npm' | |
| - name: Build PostgreSQL | |
| run: | | |
| sudo apt-get install -y build-essential wget gdb lldb libpq5 | |
| echo 0 | sudo tee /proc/sys/kernel/yama/ptrace_scope | |
| ./src/test/setup.sh -j 4 --pg-version=${{ matrix.pgversion }} | |
| - name: Run tests | |
| run: ./src/test/test.sh --no-gui --tests="vars,format" --pg-versions=${{ matrix.pgversion }} | |
| - name: Upload artifacts | |
| uses: actions/upload-artifact@v4 | |
| if: failure() | |
| with: | |
| name: postgresql-logs-${{ matrix.pgversion }} | |
| retention-days: 3 | |
| path: | | |
| pgsrc/${{ matrix.pgversion }}/data/postgresql.log | |
| src/test/log |