Skip to content

Commit 4e76ad0

Browse files
committed
require tests to pass for releases
1 parent 37f2f00 commit 4e76ad0

File tree

3 files changed

+79
-62
lines changed

3 files changed

+79
-62
lines changed

.github/workflows/production.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ on:
77
jobs:
88
build-and-push:
99
runs-on: ubuntu-latest
10+
needs: test
1011

1112
steps:
1213
- uses: actions/checkout@v4

.github/workflows/staging.yaml

Lines changed: 1 addition & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -8,71 +8,10 @@ on:
88
jobs:
99
build-test-and-push:
1010
runs-on: ubuntu-latest
11+
needs: test
1112

1213
steps:
1314
- uses: actions/checkout@v4
14-
- uses: actions/setup-node@v4
15-
with:
16-
node-version: '20'
17-
cache: 'npm'
18-
- uses: docker/setup-buildx-action@v3
19-
20-
- name: Build image
21-
uses: docker/build-push-action@v5
22-
with:
23-
context: .
24-
file: ./Containerfile
25-
build-args: |
26-
CI=true
27-
STAGING=true
28-
# BASE_PATH=/
29-
push: false
30-
load: true
31-
tags: gptwrapper:ci
32-
cache-from: type=gha
33-
cache-to: type=gha,mode=max
34-
35-
- name: Start the application
36-
run: docker compose -f compose.ci.yaml up -d
37-
38-
# Copy dependencies from the container
39-
- name: Copy dependencies from the container
40-
run: docker cp gptwrapper:/opt/app-root/src/node_modules ./node_modules
41-
42-
- run: npm run tsc
43-
- run: npm run lint
44-
- run: npm run translations -- --lang fi,en
45-
46-
# https://playwrightsolutions.com/playwright-github-action-to-cache-the-browser-binaries/
47-
- name: Get installed Playwright version
48-
id: playwright-version
49-
run: echo "PLAYWRIGHT_VERSION=$(node -e "console.log(require('./package-lock.json').packages[''].devDependencies['@playwright/test'])")" >> $GITHUB_ENV
50-
51-
- name: Cache playwright binaries
52-
uses: actions/cache@v4
53-
id: playwright-cache
54-
with:
55-
path: |
56-
~/.cache/ms-playwright
57-
key: ${{ runner.os }}-playwright-${{ env.PLAYWRIGHT_VERSION }}
58-
59-
- run: npx playwright install --with-deps chromium
60-
if: steps.playwright-cache.outputs.cache-hit != 'true'
61-
- run: npx playwright install-deps
62-
if: steps.playwright-cache.outputs.cache-hit != 'true'
63-
64-
- name: Run tests
65-
env:
66-
CI: true
67-
run: npm run test:e2e
68-
69-
- name: Upload Playwright Report
70-
uses: actions/upload-artifact@v4
71-
if: failure()
72-
with:
73-
name: playwright-report
74-
path: playwright-report/
75-
retention-days: 7
7615

7716
- name: Build staging image
7817
id: build-staging-image

.github/workflows/test.yaml

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
name: E2E Tests
2+
3+
on: [workflow_call]
4+
5+
jobs:
6+
lint-test:
7+
runs-on: ubuntu-latest
8+
9+
steps:
10+
- uses: actions/checkout@v4
11+
- uses: actions/setup-node@v4
12+
with:
13+
node-version: '20'
14+
cache: 'npm'
15+
- uses: docker/setup-buildx-action@v3
16+
17+
- name: Build image
18+
uses: docker/build-push-action@v5
19+
with:
20+
context: .
21+
file: ./Containerfile
22+
build-args: |
23+
CI=true
24+
STAGING=true
25+
# BASE_PATH=/
26+
push: false
27+
load: true
28+
tags: gptwrapper:ci
29+
cache-from: type=gha
30+
cache-to: type=gha,mode=max
31+
32+
- name: Start the application
33+
run: docker compose -f compose.ci.yaml up -d
34+
35+
# Copy dependencies from the container
36+
- name: Copy dependencies from the container
37+
run: docker cp gptwrapper:/opt/app-root/src/node_modules ./node_modules
38+
39+
- run: npm run translations -- --lang fi,en
40+
- run: npm run lint
41+
- run: npm run tsc
42+
43+
# https://playwrightsolutions.com/playwright-github-action-to-cache-the-browser-binaries/
44+
- name: Get installed Playwright version
45+
id: playwright-version
46+
run: echo "PLAYWRIGHT_VERSION=$(node -e "console.log(require('./package-lock.json').packages[''].devDependencies['@playwright/test'])")" >> $GITHUB_ENV
47+
48+
- name: Cache playwright binaries
49+
uses: actions/cache@v4
50+
id: playwright-cache
51+
with:
52+
path: |
53+
~/.cache/ms-playwright
54+
key: ${{ runner.os }}-playwright-${{ env.PLAYWRIGHT_VERSION }}
55+
56+
- run: npx playwright install --with-deps chromium
57+
if: steps.playwright-cache.outputs.cache-hit != 'true'
58+
- run: npx playwright install-deps
59+
if: steps.playwright-cache.outputs.cache-hit != 'true'
60+
61+
- name: Run tests
62+
env:
63+
CI: true
64+
run: npm run test:e2e
65+
66+
- name: Upload Playwright Report
67+
uses: actions/upload-artifact@v4
68+
if: failure()
69+
with:
70+
name: playwright-report
71+
path: playwright-report/
72+
retention-days: 7
73+
74+
- name: Print logs on failure
75+
shell: bash
76+
if: failure()
77+
run: docker compose -f compose.ci.yaml logs

0 commit comments

Comments
 (0)