ci: add postgresql src caching in CI pipeline #105
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 i | |
| npm i -D | |
| npm run compile | |
| - name: Run linter | |
| run: npm run lint | |
| 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: Setup environment | |
| run: | | |
| sudo apt-get install -y build-essential wget gdb lldb libpq5 | |
| echo 0 | sudo tee /proc/sys/kernel/yama/ptrace_scope | |
| - name: Restore PostgreSQL | |
| id: restore-postgresql | |
| uses: actions/cache/restore@v4 | |
| with: | |
| path: pgsrc/${{ matrix.pgversion }} | |
| key: pgsql-src-${{ runner.os }}-${{ runner.arch }}-${{ matrix.pgversion }}-${{ hashFiles('src/test/patches/**') }} | |
| - name: Build PostgreSQL | |
| if: steps.restore-postgresql.outputs.cache-hit != 'true' | |
| run: | | |
| ./src/test/setup.sh -j 4 --pg-version=${{ matrix.pgversion }} | |
| - name: Save PostgreSQL build cache | |
| uses: actions/cache/save@v4 | |
| if: steps.restore-postgresql.outputs.cache-hit != 'true' | |
| with: | |
| path: pgsrc/${{ matrix.pgversion }} | |
| key: ${{ steps.restore-postgresql.outputs.cache-primary-key }} | |
| - 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 |