Skip to content

Commit

Permalink
chore(ci): fix GitHub action workflows (#588)
Browse files Browse the repository at this point in the history
* chore(ci): create env file in set up action

* chore(ci): add set up db action

* chore(ci): use set up db action
  • Loading branch information
PJColombo authored Oct 5, 2024
1 parent fa9bdc1 commit 4949e7c
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 11 deletions.
29 changes: 18 additions & 11 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@ jobs:
postgres:
image: postgres:16
env:
POSTGRES_PASSWORD: postgres
POSTGRES_DB: blobscan_dev
POSTGRES_USER: blobscan
POSTGRES_PASSWORD: s3cr3t
ports:
- 5432:5432
options: >-
Expand All @@ -49,6 +51,9 @@ jobs:
- name: Setup
uses: ./tooling/github/setup

- name: Setup DB
uses: ./tooling/github/setup-db

- name: Typecheck
run: pnpm type-check

Expand All @@ -57,7 +62,9 @@ jobs:
postgres:
image: postgres:16
env:
POSTGRES_PASSWORD: postgres
POSTGRES_DB: blobscan_dev
POSTGRES_USER: blobscan
POSTGRES_PASSWORD: s3cr3t
ports:
- 5432:5432
options: >-
Expand All @@ -72,6 +79,9 @@ jobs:
- name: Setup
uses: ./tooling/github/setup

- name: Setup DB
uses: ./tooling/github/setup-db

- name: Build
run: pnpm build

Expand All @@ -80,7 +90,9 @@ jobs:
postgres:
image: postgres:16
env:
POSTGRES_PASSWORD: postgres
POSTGRES_DB: blobscan_dev
POSTGRES_USER: blobscan
POSTGRES_PASSWORD: s3cr3t
ports:
- 5432:5432
options: >-
Expand All @@ -107,6 +119,9 @@ jobs:
- name: Setup
uses: ./tooling/github/setup

- name: Setup DB
uses: ./tooling/github/setup-db

- name: Setup GCS emulator
uses: fsouza/[email protected]
with:
Expand All @@ -118,16 +133,8 @@ jobs:
- name: Generate Prisma Client
run: pnpm db:generate

- name: Test migrations
run: pnpm prisma migrate deploy --schema packages/db/prisma/schema.prisma
env:
DATABASE_URL: postgresql://postgres:postgres@localhost:5432/blobscan_ci?schema=public

- name: Test
run: pnpm coverage
env:
POSTGRES_STORAGE_ENABLED: true
DATABASE_URL: postgresql://postgres:postgres@localhost:5432/blobscan_ci

- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v4
Expand Down
17 changes: 17 additions & 0 deletions .github/workflows/nextjs-bundle-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,30 @@ env:

jobs:
analyze:
services:
postgres:
image: postgres:16
env:
POSTGRES_DB: blobscan_dev
POSTGRES_USER: blobscan
POSTGRES_PASSWORD: s3cr3t
ports:
- 5432:5432
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Setup
uses: ./tooling/github/setup

- name: Setup DB
uses: ./tooling/github/setup-db

- name: Build next.js app
run: pnpm build --filter=web

Expand Down
12 changes: 12 additions & 0 deletions tooling/github/setup-db/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
name: "Set up DB"
description: "Set up the database for the CI environment"
runs:
using: "composite"
steps:
- name: "Create .env file with db connection"
uses: "SpicyPizza/[email protected]"
with:
envkey_DATABASE_URL: "postgresql://blobscan:s3cr3t@localhost:5432/blobscan_dev?schema=public"
- name: "Apply Prisma migrations to db"
shell: bash
run: pnpm prisma migrate deploy --schema packages/db/prisma/schema.prisma

0 comments on commit 4949e7c

Please sign in to comment.