From dbb7677ada00ac6620273ab3dd5499c40b0da110 Mon Sep 17 00:00:00 2001 From: Rostislav Simonik Date: Sun, 18 Dec 2022 19:13:33 +0100 Subject: [PATCH] ci: reflect local database for tests in trunk github actions workflow --- .github/workflows/trunk.yml | 83 +++++++++++++++++++++++++++++++++++-- 1 file changed, 79 insertions(+), 4 deletions(-) diff --git a/.github/workflows/trunk.yml b/.github/workflows/trunk.yml index 118fb7100..e8f0e3d9c 100644 --- a/.github/workflows/trunk.yml +++ b/.github/workflows/trunk.yml @@ -5,14 +5,15 @@ on: branches: [main] jobs: - test-latest-prisma: + test-latest-prisma-without-database: name: Test with latest Prisma timeout-minutes: 20 strategy: matrix: - os: ['ubuntu-latest', 'macos-latest', 'windows-latest'] + os: ['macos-latest', 'windows-latest'] node-version: [14, 16] + database: ['no-db'] runs-on: ${{ matrix.os }} steps: @@ -41,8 +42,64 @@ jobs: - name: Test run: yarn -s test:ci + env: + DATABASE: ${{ matrix.database }} + + test-latest-prisma-with-database: + name: Test with latest Prisma + timeout-minutes: 20 + + strategy: + matrix: + os: ['ubuntu-latest'] + node-version: [14, 16] + database: ['db'] + + runs-on: ${{ matrix.os }} + + services: + postgres: + image: postgres + env: + POSTGRES_PASSWORD: postgres + options: >- + --health-cmd pg_isready + --health-interval 10s + --health-timeout 5s + --health-retries 5 + ports: + - 5432:5432 + + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v3 + with: + node-version: ${{ matrix.node-version }} + cache: 'yarn' - test-past-prisma: + - name: Install dependencies + run: yarn --frozen-lockfile + + - name: Set E2E DB Schema for Windows + if: ${{ matrix.os == 'windows-latest' }} + run: yarn -s ts-node scripts/get-e2e-db-schema --os ${{ matrix.os }} --node-version ${{ matrix.node-version }} --github-env $env:GITHUB_ENV + + - name: Set E2E DB Schema for other operating systems + if: ${{ matrix.os != 'windows-latest' }} + run: yarn -s ts-node scripts/get-e2e-db-schema --os ${{ matrix.os }} --node-version ${{ matrix.node-version }} --github-env $GITHUB_ENV + + - name: Build + run: yarn -s build + + - name: Test + run: yarn -s test:ci + env: + DATABASE: ${{ matrix.database }} + + test-past-prisma-with-database: name: Test with past Prisma timeout-minutes: 20 @@ -50,9 +107,24 @@ jobs: matrix: os: ['ubuntu-latest'] node-version: [16] + database: ['db'] prisma-client-version: ['4.0'] runs-on: ${{ matrix.os }} + + services: + postgres: + image: postgres + env: + POSTGRES_PASSWORD: postgres + options: >- + --health-cmd pg_isready + --health-interval 10s + --health-timeout 5s + --health-retries 5 + ports: + - 5432:5432 + steps: - name: Checkout repository uses: actions/checkout@v3 @@ -76,9 +148,12 @@ jobs: - name: Test run: yarn -s test:ci + env: + DATABASE: ${{ matrix.database }} release-canary: - needs: [test-latest-prisma, test-past-prisma] + needs: + [test-latest-prisma-without-database, test-latest-prisma-with-database, test-past-prisma-with-database] name: Release canary timeout-minutes: 20