Skip to content

Commit

Permalink
ci: try to parallelize CI steps using caches
Browse files Browse the repository at this point in the history
  • Loading branch information
mirceanis committed May 17, 2023
1 parent b1ae5a5 commit 5baf36b
Show file tree
Hide file tree
Showing 2 changed files with 147 additions and 1 deletion.
143 changes: 143 additions & 0 deletions .github/workflows/build-and-test-on-pr-cache.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,143 @@
name: Build and Test PR with caches
on: [pull_request, workflow_dispatch, push]
jobs:
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: 20
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: 20
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: 20
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 install

- 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: 20
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
5 changes: 4 additions & 1 deletion packages/test-react-app/jest-integration.config.cjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
const { defaults } = require('jest-config')

/**
* @type {import('jest-environment-puppeteer').JestPuppeteerConfig}
*/
const config = {
// preset path is relative to the rootDir when that is set
preset: '../jest-preset-puppeteer-esm/jest-preset.cjs',
Expand All @@ -11,7 +14,7 @@ const config = {
},
transformIgnorePatterns: [],
testTimeout: 30000,
coverageProvider: 'v8',
collectCoverage: false,
moduleNameMapper: {
'^(\\.{1,2}/.*)\\.js$': '$1',
},
Expand Down

0 comments on commit 5baf36b

Please sign in to comment.