Skip to content

Commit 6db23ad

Browse files
committed
split up unit tests workflow
1 parent 3f30a43 commit 6db23ad

File tree

4 files changed

+413
-134
lines changed

4 files changed

+413
-134
lines changed

.github/workflows/unit-tests.yml

Lines changed: 9 additions & 134 deletions
Original file line numberDiff line numberDiff line change
@@ -8,137 +8,12 @@ on:
88
push:
99

1010
jobs:
11-
unitTests:
12-
name: "🧪 Unit Tests"
13-
runs-on: ubuntu-latest
14-
strategy:
15-
matrix:
16-
shardIndex: [1, 2, 3, 4, 5]
17-
shardTotal: [5]
18-
env:
19-
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
20-
SHARD_INDEX: ${{ matrix.shardIndex }}
21-
SHARD_TOTAL: ${{ matrix.shardTotal }}
22-
steps:
23-
- name: 🔧 Disable IPv6
24-
run: |
25-
sudo sysctl -w net.ipv6.conf.all.disable_ipv6=1
26-
sudo sysctl -w net.ipv6.conf.default.disable_ipv6=1
27-
sudo sysctl -w net.ipv6.conf.lo.disable_ipv6=1
28-
29-
- name: 🔧 Configure docker address pool
30-
run: |
31-
CONFIG='{
32-
"default-address-pools" : [
33-
{
34-
"base" : "172.17.0.0/12",
35-
"size" : 20
36-
},
37-
{
38-
"base" : "192.168.0.0/16",
39-
"size" : 24
40-
}
41-
]
42-
}'
43-
mkdir -p /etc/docker
44-
echo "$CONFIG" | sudo tee /etc/docker/daemon.json
45-
46-
- name: 🔧 Restart docker daemon
47-
run: sudo systemctl restart docker
48-
49-
- name: ⬇️ Checkout repo
50-
uses: actions/checkout@v4
51-
with:
52-
fetch-depth: 0
53-
54-
- name: ⎔ Setup pnpm
55-
uses: pnpm/action-setup@v4
56-
with:
57-
version: 8.15.5
58-
59-
- name: ⎔ Setup node
60-
uses: buildjet/setup-node@v4
61-
with:
62-
node-version: 20.11.1
63-
cache: "pnpm"
64-
65-
# ..to avoid rate limits when pulling images
66-
- name: 🐳 Login to DockerHub
67-
if: ${{ env.DOCKERHUB_USERNAME }}
68-
uses: docker/login-action@v3
69-
with:
70-
username: ${{ secrets.DOCKERHUB_USERNAME }}
71-
password: ${{ secrets.DOCKERHUB_TOKEN }}
72-
- name: 🐳 Skipping DockerHub login (no secrets available)
73-
if: ${{ !env.DOCKERHUB_USERNAME }}
74-
run: echo "DockerHub login skipped because secrets are not available."
75-
76-
- name: 📥 Download deps
77-
run: pnpm install --frozen-lockfile
78-
79-
- name: 📀 Generate Prisma Client
80-
run: pnpm run generate
81-
82-
- name: 🧪 Run Webapp Unit Tests
83-
run: pnpm run test:webapp --reporter=default --reporter=blob --shard=${{ matrix.shardIndex }}/${{ matrix.shardTotal }}
84-
env:
85-
DATABASE_URL: postgresql://postgres:postgres@localhost:5432/postgres
86-
DIRECT_URL: postgresql://postgres:postgres@localhost:5432/postgres
87-
SESSION_SECRET: "secret"
88-
MAGIC_LINK_SECRET: "secret"
89-
ENCRYPTION_KEY: "secret"
90-
91-
- name: 🧪 Run Package Unit Tests
92-
run: pnpm run test:packages --reporter=default --reporter=blob --shard=${{ matrix.shardIndex }}/${{ matrix.shardTotal }}
93-
94-
- name: 🧪 Run Internal Unit Tests
95-
run: pnpm run test:internal --reporter=default --reporter=blob --shard=${{ matrix.shardIndex }}/${{ matrix.shardTotal }}
96-
97-
- name: Gather all reports
98-
run: |
99-
mkdir -p .vitest-reports
100-
find . -type f -path '*/.vitest-reports/blob-*.json' \
101-
-exec bash -c 'src="$1"; basename=$(basename "$src"); pkg=$(dirname "$src" | sed "s|^\./||;s|/\.vitest-reports$||;s|/|_|g"); cp "$src" ".vitest-reports/${pkg}-${basename}"' _ {} \;
102-
103-
- name: Upload blob reports to GitHub Actions Artifacts
104-
if: ${{ !cancelled() }}
105-
uses: actions/upload-artifact@v4
106-
with:
107-
name: blob-report-${{ matrix.shardIndex }}
108-
path: .vitest-reports/*
109-
include-hidden-files: true
110-
retention-days: 1
111-
112-
merge-reports:
113-
if: ${{ !cancelled() }}
114-
needs: [unitTests]
115-
runs-on: ubuntu-latest
116-
steps:
117-
- name: ⬇️ Checkout repo
118-
uses: actions/checkout@v4
119-
with:
120-
fetch-depth: 0
121-
122-
- name: ⎔ Setup pnpm
123-
uses: pnpm/action-setup@v4
124-
with:
125-
version: 8.15.5
126-
127-
- name: ⎔ Setup node
128-
uses: buildjet/setup-node@v4
129-
with:
130-
node-version: 20.11.1
131-
cache: "pnpm"
132-
133-
- name: 📥 Download deps
134-
run: pnpm install --frozen-lockfile
135-
136-
- name: Download blob reports from GitHub Actions Artifacts
137-
uses: actions/download-artifact@v4
138-
with:
139-
path: .vitest-reports
140-
pattern: blob-report-*
141-
merge-multiple: true
142-
143-
- name: Merge reports
144-
run: npx vitest run --merge-reports
11+
webapp:
12+
uses: ./.github/workflows/unit-tests/webapp.yml
13+
secrets: inherit
14+
packages:
15+
uses: ./.github/workflows/unit-tests/packages.yml
16+
secrets: inherit
17+
internal:
18+
uses: ./.github/workflows/unit-tests/internal.yml
19+
secrets: inherit
Lines changed: 132 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
name: "🧪 Unit Tests: Internal"
2+
3+
permissions:
4+
contents: read
5+
6+
on:
7+
workflow_call:
8+
9+
jobs:
10+
unitTests:
11+
name: "🧪 Unit Tests: Internal"
12+
runs-on: ubuntu-latest
13+
strategy:
14+
matrix:
15+
shardIndex: [1, 2, 3, 4, 5]
16+
shardTotal: [5]
17+
env:
18+
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
19+
SHARD_INDEX: ${{ matrix.shardIndex }}
20+
SHARD_TOTAL: ${{ matrix.shardTotal }}
21+
steps:
22+
- name: 🔧 Disable IPv6
23+
run: |
24+
sudo sysctl -w net.ipv6.conf.all.disable_ipv6=1
25+
sudo sysctl -w net.ipv6.conf.default.disable_ipv6=1
26+
sudo sysctl -w net.ipv6.conf.lo.disable_ipv6=1
27+
28+
- name: 🔧 Configure docker address pool
29+
run: |
30+
CONFIG='{
31+
"default-address-pools" : [
32+
{
33+
"base" : "172.17.0.0/12",
34+
"size" : 20
35+
},
36+
{
37+
"base" : "192.168.0.0/16",
38+
"size" : 24
39+
}
40+
]
41+
}'
42+
mkdir -p /etc/docker
43+
echo "$CONFIG" | sudo tee /etc/docker/daemon.json
44+
45+
- name: 🔧 Restart docker daemon
46+
run: sudo systemctl restart docker
47+
48+
- name: ⬇️ Checkout repo
49+
uses: actions/checkout@v4
50+
with:
51+
fetch-depth: 0
52+
53+
- name: ⎔ Setup pnpm
54+
uses: pnpm/action-setup@v4
55+
with:
56+
version: 8.15.5
57+
58+
- name: ⎔ Setup node
59+
uses: buildjet/setup-node@v4
60+
with:
61+
node-version: 20.11.1
62+
cache: "pnpm"
63+
64+
# ..to avoid rate limits when pulling images
65+
- name: 🐳 Login to DockerHub
66+
if: ${{ env.DOCKERHUB_USERNAME }}
67+
uses: docker/login-action@v3
68+
with:
69+
username: ${{ secrets.DOCKERHUB_USERNAME }}
70+
password: ${{ secrets.DOCKERHUB_TOKEN }}
71+
- name: 🐳 Skipping DockerHub login (no secrets available)
72+
if: ${{ !env.DOCKERHUB_USERNAME }}
73+
run: echo "DockerHub login skipped because secrets are not available."
74+
75+
- name: 📥 Download deps
76+
run: pnpm install --frozen-lockfile
77+
78+
- name: 📀 Generate Prisma Client
79+
run: pnpm run generate
80+
81+
- name: 🧪 Run Internal Unit Tests
82+
run: pnpm run test:internal --reporter=default --reporter=blob --shard=${{ matrix.shardIndex }}/${{ matrix.shardTotal }}
83+
84+
- name: Gather all reports
85+
run: |
86+
mkdir -p .vitest-reports
87+
find . -type f -path '*/.vitest-reports/blob-*.json' \
88+
-exec bash -c 'src="$1"; basename=$(basename "$src"); pkg=$(dirname "$src" | sed "s|^\./||;s|/\.vitest-reports$||;s|/|_|g"); cp "$src" ".vitest-reports/${pkg}-${basename}"' _ {} \;
89+
90+
- name: Upload blob reports to GitHub Actions Artifacts
91+
if: ${{ !cancelled() }}
92+
uses: actions/upload-artifact@v4
93+
with:
94+
name: blob-report-${{ matrix.shardIndex }}
95+
path: .vitest-reports/*
96+
include-hidden-files: true
97+
retention-days: 1
98+
99+
merge-reports:
100+
name: "📊 Merge Reports"
101+
if: ${{ !cancelled() }}
102+
needs: [unitTests]
103+
runs-on: ubuntu-latest
104+
steps:
105+
- name: ⬇️ Checkout repo
106+
uses: actions/checkout@v4
107+
with:
108+
fetch-depth: 0
109+
110+
- name: ⎔ Setup pnpm
111+
uses: pnpm/action-setup@v4
112+
with:
113+
version: 8.15.5
114+
115+
- name: ⎔ Setup node
116+
uses: buildjet/setup-node@v4
117+
with:
118+
node-version: 20.11.1
119+
cache: "pnpm"
120+
121+
- name: 📥 Download deps
122+
run: pnpm install --frozen-lockfile
123+
124+
- name: Download blob reports from GitHub Actions Artifacts
125+
uses: actions/download-artifact@v4
126+
with:
127+
path: .vitest-reports
128+
pattern: blob-report-*
129+
merge-multiple: true
130+
131+
- name: Merge reports
132+
run: npx vitest run --merge-reports

0 commit comments

Comments
 (0)