Skip to content

Commit 8c383bd

Browse files
committed
Add a PR checks github workflow to run typecheck, unit tests, and e2e tests on PRs
1 parent 97e63d1 commit 8c383bd

File tree

4 files changed

+156
-0
lines changed

4 files changed

+156
-0
lines changed

.github/workflows/e2e.yml

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
name: "🧪 E2E Tests"
2+
on:
3+
workflow_call:
4+
jobs:
5+
e2e:
6+
name: "🧪 E2E Tests"
7+
runs-on: buildjet-4vcpu-ubuntu-2204
8+
steps:
9+
- name: 🐳 Login to Docker Hub
10+
uses: docker/login-action@v2
11+
with:
12+
username: ${{ secrets.DOCKERHUB_USERNAME }}
13+
password: ${{ secrets.DOCKERHUB_TOKEN }}
14+
15+
- name: ⬇️ Checkout repo
16+
uses: actions/checkout@v3
17+
with:
18+
fetch-depth: 0
19+
20+
- name: ⎔ Setup pnpm
21+
uses: pnpm/[email protected]
22+
with:
23+
version: 7.18
24+
25+
- name: ⎔ Setup node
26+
uses: buildjet/setup-node@v3
27+
with:
28+
node-version: 18
29+
cache: "pnpm"
30+
31+
- name: 📥 Download deps
32+
run: pnpm install --frozen-lockfile
33+
34+
- name: Install Playwright Browsers
35+
run: npx playwright install --with-deps
36+
37+
- name: Run Playwright tests
38+
run: |
39+
# Setup environment variables
40+
cp ./.env.example ./.env
41+
cp ./references/nextjs-test/.env.example ./references/nextjs-test/.env.local
42+
43+
# Build packages
44+
pnpm run build --filter @references/nextjs-test^...
45+
pnpm --filter @trigger.dev/database generate
46+
47+
# Move trigger-cli bin to correct place
48+
pnpm install --frozen-lockfile
49+
50+
# Execute tests
51+
pnpm run docker
52+
pnpm run db:migrate
53+
pnpm run db:seed
54+
pnpm run test:e2e
55+
56+
# Cleanup
57+
pnpm run docker:stop
58+
59+
- name: Upload Playwright report
60+
uses: actions/upload-artifact@v3
61+
if: always()
62+
with:
63+
name: playwright-report
64+
path: playwright-report/
65+
retention-days: 30

.github/workflows/pr_checks.yml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: 🤖 PR Checks
2+
3+
on:
4+
pull_request_target:
5+
branches:
6+
- main
7+
paths-ignore:
8+
- "**.md"
9+
- ".github/CODEOWNERS"
10+
11+
permissions:
12+
contents: read
13+
id-token: write
14+
15+
jobs:
16+
type-check:
17+
name: "ʦ TypeScript"
18+
uses: ./.github/workflows/typecheck.yml
19+
secrets: inherit
20+
21+
unitTests:
22+
name: "🧪 Unit Tests"
23+
uses: ./.github/workflows/unit-tests.yml
24+
secrets: inherit
25+
26+
e2e:
27+
name: "🧪 E2E Tests"
28+
uses: ./.github/workflows/e2e.yml
29+
secrets: inherit

.github/workflows/typecheck.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: "ʦ TypeScript"
2+
on:
3+
workflow_call:
4+
jobs:
5+
typecheck:
6+
runs-on: buildjet-4vcpu-ubuntu-2204
7+
8+
steps:
9+
- name: ⬇️ Checkout repo
10+
uses: actions/checkout@v3
11+
with:
12+
fetch-depth: 0
13+
14+
- name: ⎔ Setup pnpm
15+
uses: pnpm/[email protected]
16+
with:
17+
version: 7.18
18+
19+
- name: ⎔ Setup node
20+
uses: buildjet/setup-node@v3
21+
with:
22+
node-version: 18
23+
cache: "pnpm"
24+
25+
- name: 📥 Download deps
26+
run: pnpm install --frozen-lockfile
27+
28+
- name: 📀 Generate Prisma Client
29+
run: pnpm run generate
30+
31+
- name: 🔎 Type check
32+
run: pnpm run typecheck --filter webapp

.github/workflows/unit-tests.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: "🧪 Unit Tests"
2+
on:
3+
workflow_call:
4+
jobs:
5+
unitTests:
6+
name: "🧪 Unit Tests"
7+
runs-on: buildjet-4vcpu-ubuntu-2204
8+
steps:
9+
- name: ⬇️ Checkout repo
10+
uses: actions/checkout@v3
11+
with:
12+
fetch-depth: 0
13+
14+
- name: ⎔ Setup pnpm
15+
uses: pnpm/[email protected]
16+
with:
17+
version: 7.18
18+
19+
- name: ⎔ Setup node
20+
uses: buildjet/setup-node@v3
21+
with:
22+
node-version: 18
23+
cache: "pnpm"
24+
25+
- name: 📥 Download deps
26+
run: pnpm install --frozen-lockfile
27+
28+
- name: Run Unit Tests
29+
run: |
30+
pnpm run test

0 commit comments

Comments
 (0)