ci: try to parallelize CI steps using caches #1
This file contains 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: Build and Test PR with caches | ||
on: [pull_request, workflow_dispatch, push] | ||
jobs: | ||
build: | ||
steps: | ||
Check failure on line 5 in .github/workflows/build-and-test-on-pr-cache.yml GitHub Actions / Build and Test PR with cachesInvalid workflow file
|
||
- uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 0 | ||
- uses: pnpm/action-setup@v2 | ||
with: | ||
version: 8 | ||
- run: pnpm add -g pnpm | ||
- name: Use Node.js | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: 18 | ||
cache: 'pnpm' | ||
- run: pnpm install | ||
- run: pnpm build | ||
- name: 'Save build output' | ||
id: cache-build | ||
uses: actions/cache/save@v3 | ||
with: | ||
path: ${{ github.workspace }} | ||
key: ${{ runner.os }}-build-${{ github.sha }}-${{ github.run_id }} | ||
restore-keys: | ||
${{ runner.os }}-build-${{ github.sha }} | ||
test-integration: | ||
needs: build | ||
runs-on: ubuntu-latest | ||
services: | ||
postgres: | ||
image: postgres:15.1 | ||
env: | ||
POSTGRES_USER: postgres | ||
POSTGRES_PASSWORD: test123 | ||
ports: | ||
- 5432:5432 | ||
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5 | ||
steps: | ||
- uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 0 | ||
- uses: pnpm/action-setup@v2 | ||
with: | ||
version: 8 | ||
- run: pnpm add -g pnpm | ||
- name: Use Node.js | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: 18 | ||
cache: 'pnpm' | ||
- name: 'Restore build output' | ||
id: cache-build | ||
uses: actions/cache/restore@v3 | ||
with: | ||
path: ${{ github.workspace }} | ||
key: ${{ runner.os }}-build-${{ github.sha }}-${{ github.run_id }} | ||
restore-keys: ${{ runner.os }}-build-${{ github.sha }} | ||
fail-on-cache-miss: true | ||
- name: run integration tests | ||
env: | ||
INCLUDE_POSTGRES_TESTS: true | ||
POSTGRES_HOST: localhost | ||
POSTGRES_USER: postgres | ||
POSTGRES_PASSWORD: test123 | ||
POSTGRES_PORT: 5432 | ||
run: pnpm test:integration | ||
- uses: codecov/codecov-action@v3 | ||
with: | ||
token: ${{ secrets.CODECOV_TOKEN }} # not required for public repos but sometimes fails without :| | ||
test-browser: | ||
needs: build | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 0 | ||
- uses: pnpm/action-setup@v2 | ||
with: | ||
version: 8 | ||
- run: pnpm add -g pnpm | ||
- name: Use Node.js | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: 18 | ||
cache: 'pnpm' | ||
- name: 'Restore build output' | ||
id: cache-build | ||
uses: actions/cache/restore@v3 | ||
with: | ||
path: ${{ github.workspace }} | ||
key: ${{ runner.os }}-build-${{ github.sha }}-${{ github.run_id }} | ||
restore-keys: ${{ runner.os }}-build-${{ github.sha }} | ||
fail-on-cache-miss: true | ||
- name: run browser tests | ||
run: pnpm test:browser | ||
- run: pnpm run docs | ||
- run: pnpm lint | ||
- uses: codecov/codecov-action@v3 | ||
with: | ||
token: ${{ secrets.CODECOV_TOKEN }} # not required for public repos but sometimes fails without :| | ||
lint-and-docs: | ||
needs: build | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 0 | ||
- uses: pnpm/action-setup@v2 | ||
with: | ||
version: 8 | ||
- run: pnpm add -g pnpm | ||
- name: Use Node.js | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: 18 | ||
cache: 'pnpm' | ||
- name: 'Restore build output' | ||
id: cache-build | ||
uses: actions/cache/restore@v3 | ||
with: | ||
path: ${{ github.workspace }} | ||
key: ${{ runner.os }}-build-${{ github.sha }}-${{ github.run_id }} | ||
restore-keys: ${{ runner.os }}-build-${{ github.sha }} | ||
fail-on-cache-miss: true | ||
- run: pnpm run docs | ||
- run: pnpm lint |