Skip to content

Commit b7f508d

Browse files
committed
chore: set up authenticated tests
1 parent 4110172 commit b7f508d

File tree

3 files changed

+98
-28
lines changed

3 files changed

+98
-28
lines changed
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: 'Setup Repository'
2+
description: 'Set up the repository with pnpm and Node.js'
3+
inputs:
4+
pnpm-version:
5+
description: 'Version of pnpm to use'
6+
default: 10.27.0
7+
node-version:
8+
description: 'Version of Node.js to use'
9+
default: 24.12.0
10+
runs:
11+
using: 'composite'
12+
steps:
13+
- name: Setup pnpm
14+
uses: pnpm/action-setup@v3
15+
with:
16+
version: ${{ env.PNPM_VERSION }}
17+
18+
- name: Set up Node.js
19+
uses: actions/setup-node@v4
20+
with:
21+
node-version: ${{ env.NODE_VERSION }}
22+
cache: 'pnpm'
23+
24+
- name: Install dependencies
25+
shell: bash
26+
run: pnpm install --frozen-lockfile
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: 'Wait for Healthcheck'
2+
description: 'Wait for a service to be healthy by checking its healthcheck endpoint'
3+
inputs:
4+
host:
5+
description: 'The host of the backend'
6+
required: true
7+
endpoint:
8+
description: 'The healthcheck endpoint'
9+
required: true
10+
default: 'health'
11+
expected_code:
12+
description: 'The expected HTTP status code'
13+
default: '200'
14+
timeout:
15+
description: 'The timeout in seconds'
16+
default: '30'
17+
runs:
18+
using: 'composite'
19+
steps:
20+
- name: Wait for service to be healthy
21+
shell: bash
22+
run: |
23+
counter=0
24+
while [ "$(curl -s -o /dev/null -w '%{http_code}' http://${{ inputs.host }}/${{ inputs.endpoint }})" -ne ${{ inputs.expected_code }} ]; do
25+
counter=$((counter+1))
26+
if [ $counter -ge ${{ inputs.timeout }} ]; then
27+
echo "Service failed to start within 5 seconds."
28+
exit 1
29+
fi
30+
echo "Waiting for service to start..."
31+
sleep 1
32+
done
33+
echo "Service is healthy"

.github/workflows/main.yml

Lines changed: 39 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -14,31 +14,18 @@ permissions:
1414
env:
1515
IMAGE_REGISTRY: ghcr.io
1616
IMAGE_NAME: ${{ github.repository }}
17-
PNPM_VERSION: 10.27.0
18-
NODE_VERSION: 24.12.0
1917
HUSKY: 0
2018

2119
jobs:
2220
test:
23-
name: Build apps and run tests
21+
name: Run unit, lint and e2e tests
2422
runs-on: ubuntu-latest
2523
steps:
2624
- name: Checkout repository
2725
uses: actions/checkout@v4
2826

29-
- name: Setup pnpm
30-
uses: pnpm/action-setup@v3
31-
with:
32-
version: ${{ env.PNPM_VERSION }}
33-
34-
- name: Set up Node.js
35-
uses: actions/setup-node@v4
36-
with:
37-
node-version: ${{ env.NODE_VERSION }}
38-
cache: 'pnpm'
39-
40-
- name: Install dependencies
41-
run: pnpm install --frozen-lockfile
27+
- name: Setup repository
28+
uses: ./.github/workflows/actions/setup-repository
4229

4330
- name: Setup ESLint cache
4431
uses: actions/cache@v4
@@ -61,15 +48,44 @@ jobs:
6148
- name: Start genesis and ocular
6249
run: |
6350
docker pull ghcr.io/simonwep/genesis:latest
64-
pnpm dev:backend &
65-
pnpm preview &
51+
docker run -p 8080:8080 -v "./.data:/app/.data" --env-file .env.genesis ghcr.io/simonwep/genesis:latest start &
52+
pnpm vite preview &
53+
54+
- name: Wait for genesis to be healthy
55+
uses: ./.github/workflows/actions/wait-for-health-check
56+
with:
57+
host: localhost:8080
58+
59+
- name: Wait for ocular to be healthy
60+
uses: ./.github/workflows/actions/wait-for-health-check
61+
with:
62+
host: localhost:3000
63+
endpoint: /dashboard
6664

6765
- name: Install playwright browsers
6866
run: pnpm exec playwright install --with-deps firefox
6967

7068
- name: Run e2e tests
7169
run: pnpm test:e2e
7270

71+
- name: Upload test results
72+
uses: actions/upload-artifact@v4
73+
if: ${{ failure() }}
74+
with:
75+
name: test-results
76+
path: test-results/
77+
retention-days: 7
78+
79+
build:
80+
name: Run demo and docs build
81+
runs-on: ubuntu-latest
82+
steps:
83+
- name: Checkout repository
84+
uses: actions/checkout@v4
85+
86+
- name: Setup repository
87+
uses: ./.github/workflows/actions/setup-repository
88+
7389
- name: Set outputs
7490
id: vars
7591
run: echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
@@ -84,6 +100,9 @@ jobs:
84100
OCULAR_BUILD_SHA: ${{ steps.vars.outputs.sha_short }}
85101
OCULAR_BASE_URL: /ocular/demo/
86102

103+
- name: Build docs
104+
run: pnpm docs:build
105+
87106
- name: Upload app build
88107
uses: actions/upload-artifact@v4
89108
if: github.ref == 'refs/heads/main'
@@ -100,18 +119,10 @@ jobs:
100119
path: docs/.vitepress/dist
101120
retention-days: 1
102121

103-
- name: Upload test results
104-
uses: actions/upload-artifact@v4
105-
if: ${{ failure() }}
106-
with:
107-
name: test-results
108-
path: test-results/
109-
retention-days: 7
110-
111122
publish_docs:
112123
if: github.ref == 'refs/heads/main'
113124
name: Publish docs
114-
needs: test
125+
needs: [build, test]
115126
runs-on: ubuntu-latest
116127
permissions:
117128
pages: write
@@ -151,7 +162,7 @@ jobs:
151162
publish_docker:
152163
if: startsWith(github.event.ref, 'refs/tags/v')
153164
name: Build and publish docker image
154-
needs: test
165+
needs: [build, test]
155166
runs-on: ubuntu-latest
156167
permissions:
157168
contents: read

0 commit comments

Comments
 (0)