* ci: split e2e * chore: 3 parts * chore: use matrix * chore: use playwright container, bump playwright * chore: remove playwright container * ci: move all packages into matrix * ci: reusable action to restore build cache * chore: revert custom action * chore: cleanup logs
209 lines
5.1 KiB
YAML
209 lines
5.1 KiB
YAML
name: build
|
|
|
|
on:
|
|
pull_request:
|
|
types: [opened, reopened, synchronize]
|
|
push:
|
|
branches: ['main']
|
|
|
|
jobs:
|
|
core-build:
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
with:
|
|
fetch-depth: 25
|
|
|
|
- name: Use Node.js 18
|
|
uses: actions/setup-node@v3
|
|
with:
|
|
node-version: 18
|
|
|
|
- name: Install pnpm
|
|
uses: pnpm/action-setup@v2
|
|
with:
|
|
version: 8
|
|
run_install: false
|
|
|
|
- name: Get pnpm store directory
|
|
shell: bash
|
|
run: |
|
|
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
|
|
|
|
- uses: actions/cache@v3
|
|
name: Setup pnpm cache
|
|
with:
|
|
path: ${{ env.STORE_PATH }}
|
|
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
|
|
restore-keys: |
|
|
${{ runner.os }}-pnpm-store-
|
|
${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
|
|
|
|
- run: pnpm install
|
|
- run: pnpm run build
|
|
|
|
- name: Cache build
|
|
uses: actions/cache@v3
|
|
with:
|
|
path: ./*
|
|
key: ${{ github.sha }}-${{ github.run_number }}
|
|
|
|
tests:
|
|
runs-on: ubuntu-latest
|
|
needs: core-build
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
database: [mongoose, postgres]
|
|
env:
|
|
POSTGRES_USER: postgres
|
|
POSTGRES_PASSWORD: postgres
|
|
POSTGRES_DB: payloadtests
|
|
|
|
steps:
|
|
- name: Use Node.js 18
|
|
uses: actions/setup-node@v3
|
|
with:
|
|
node-version: 18
|
|
|
|
- name: Install pnpm
|
|
uses: pnpm/action-setup@v2
|
|
with:
|
|
version: 8
|
|
run_install: false
|
|
|
|
- name: Restore build
|
|
uses: actions/cache@v3
|
|
with:
|
|
path: ./*
|
|
key: ${{ github.sha }}-${{ github.run_number }}
|
|
|
|
- name: Start PostgreSQL
|
|
uses: CasperWA/postgresql-action@v1.2
|
|
with:
|
|
postgresql version: '14' # See https://hub.docker.com/_/postgres for available versions
|
|
postgresql db: ${{ env.POSTGRES_DB }}
|
|
postgresql user: ${{ env.POSTGRES_USER }}
|
|
postgresql password: ${{ env.POSTGRES_PASSWORD }}
|
|
if: matrix.database == 'postgres'
|
|
|
|
- run: sleep 30
|
|
- name: Configure PostgreSQL
|
|
run: |
|
|
psql "postgresql://$POSTGRES_USER:$POSTGRES_PASSWORD@localhost:5432/$POSTGRES_DB" -c "CREATE ROLE runner SUPERUSER LOGIN;"
|
|
psql "postgresql://$POSTGRES_USER:$POSTGRES_PASSWORD@localhost:5432/$POSTGRES_DB" -c "SELECT version();"
|
|
echo "POSTGRES_URL=postgresql://$POSTGRES_USER:$POSTGRES_PASSWORD@localhost:5432/$POSTGRES_DB" >> $GITHUB_ENV
|
|
if: matrix.database == 'postgres'
|
|
|
|
- name: Component Tests
|
|
run: pnpm test:components
|
|
|
|
- name: Integration Tests
|
|
run: pnpm test:int
|
|
env:
|
|
PAYLOAD_DATABASE: ${{ matrix.database }}
|
|
POSTGRES_URL: ${{ env.POSTGRES_URL }}
|
|
|
|
tests-e2e:
|
|
runs-on: ubuntu-latest
|
|
needs: core-build
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
part: [1/4, 2/4, 3/4, 4/4]
|
|
|
|
steps:
|
|
- name: Use Node.js 18
|
|
uses: actions/setup-node@v3
|
|
with:
|
|
node-version: 18
|
|
|
|
- name: Install pnpm
|
|
uses: pnpm/action-setup@v2
|
|
with:
|
|
version: 8
|
|
run_install: false
|
|
|
|
- name: Restore build
|
|
uses: actions/cache@v3
|
|
with:
|
|
path: ./*
|
|
key: ${{ github.sha }}-${{ github.run_number }}
|
|
|
|
- name: E2E Tests
|
|
run: pnpm test:e2e --part ${{ matrix.part }} --bail
|
|
|
|
- uses: actions/upload-artifact@v3
|
|
if: always()
|
|
with:
|
|
name: test-results
|
|
path: test-results/
|
|
retention-days: 1
|
|
|
|
tests-type-generation:
|
|
runs-on: ubuntu-latest
|
|
needs: core-build
|
|
|
|
steps:
|
|
- name: Use Node.js 18
|
|
uses: actions/setup-node@v3
|
|
with:
|
|
node-version: 18
|
|
|
|
- name: Install pnpm
|
|
uses: pnpm/action-setup@v2
|
|
with:
|
|
version: 8
|
|
run_install: false
|
|
|
|
- name: Restore build
|
|
uses: actions/cache@v3
|
|
with:
|
|
path: ./*
|
|
key: ${{ github.sha }}-${{ github.run_number }}
|
|
|
|
- name: Generate Payload Types
|
|
run: pnpm dev:generate-types fields
|
|
|
|
- name: Generate GraphQL schema file
|
|
run: pnpm dev:generate-graphql-schema graphql-schema-gen
|
|
|
|
build-packages:
|
|
name: Build Packages
|
|
runs-on: ubuntu-latest
|
|
needs: core-build
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
pkg:
|
|
- db-mongodb
|
|
- db-postgres
|
|
- bundler-webpack
|
|
- bundler-vite
|
|
- richtext-slate
|
|
- richtext-lexical
|
|
- live-preview
|
|
- live-preview-react
|
|
|
|
steps:
|
|
- name: Use Node.js 18
|
|
uses: actions/setup-node@v3
|
|
with:
|
|
node-version: 18
|
|
|
|
- name: Install pnpm
|
|
uses: pnpm/action-setup@v2
|
|
with:
|
|
version: 8
|
|
run_install: false
|
|
|
|
- name: Restore build
|
|
uses: actions/cache@v3
|
|
with:
|
|
path: ./*
|
|
key: ${{ github.sha }}-${{ github.run_number }}
|
|
|
|
- name: Build ${{ matrix.pkg }}
|
|
run: pnpm turbo run build --filter=${{ matrix.pkg }}
|