-
Notifications
You must be signed in to change notification settings - Fork 4
115 lines (104 loc) · 3.76 KB
/
test-e2e.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
name: E2E tests
# Disabled automatic running because these are totally broken
on:
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
env:
SKIP_ENV_VALIDATION: "true"
REGISTRY: "ghcr.io"
jobs:
changed-packages:
name: Determine which apps changed
uses: ./.github/workflows/changed-packages.yml
test-cypress-ui:
name: Cypress tests ui
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
needs: [changed-packages]
if: needs.changed-packages.outputs.ui_changed == 'true'
env:
NEXT_PUBLIC_MOCK_REQUESTS: 'true'
DISABLE_AUTH: 'true'
NEXT_PUBLIC_TILAVARAUS_API_URL: http://localhost:4000
PORT: 4000
TZ: Europe/Helsinki
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: "Set up Docker Buildx"
uses: docker/setup-buildx-action@v3
- name: "Log in to the Container registry"
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- uses: pnpm/action-setup@v4
with:
version: 8
- uses: actions/setup-node@v4
with:
node-version: 20
# Repository name needs to be lowercase
# TODO remember to fix the image name after we can reuse the regular image (build-args)
- name: "Create repository name"
id: repo
run: >-
echo "repo=$(
echo ${{ env.REGISTRY }}/${{ github.repository }} | tr '[:upper:]' '[:lower:]'
)" >> $GITHUB_OUTPUT
- name: "Extract metadata (tags, labels) for Docker"
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ steps.repo.outputs.repo }}
tags: |
type=ref,event=branch
type=ref,event=tag
type=ref,event=pr
# TODO reuse the ui image (problem is the build-args)
- name: "Build ui e2e container"
uses: docker/build-push-action@v6
with:
context: .
file: Dockerfile
build-args: |
NEXT_PUBLIC_TILAVARAUS_API_URL=${{ env.NEXT_PUBLIC_TILAVARAUS_API_URL }}
NEXT_PUBLIC_MOCK_REQUESTS=${{ env.NEXT_PUBLIC_MOCK_REQUESTS }}
APP=ui
DISABLE_AUTH=true
push: ${{ github.event_name != 'pull_request' }}
load: true
tags: ${{ steps.meta.outputs.tags }}
# TODO can we add a tag here like e2e-latest or smth, that we can use for the next step just tilavaraus-ui:e2e-latest
# instead of referencing the whole path
labels: ${{ steps.meta.outputs.labels }}
# Use a shared cache to speed up builds
cache-from: type=registry,ref=${{ steps.repo.outputs.repo }}:cache
cache-to: type=registry,ref=${{ steps.repo.outputs.repo }}:cache,mode=max
- name: Run the test container
run: |
docker run -p 4000:4000 --rm -e PORT=4000 -d --ipc=host --name tilavaraus-ui-server ${{ steps.meta.outputs.tags }}
- name: Cypress e2e & a11y
uses: cypress-io/github-action@v6
with:
project: ./apps/ui
config-file: cypress.config.ts
install-command: pnpm install --frozen-lockfile
#install: false
command: pnpm test:browser:ci
#wait-on: 'http://127.0.0.1:4000'
wait-on: 'http://localhost:4000'
- name: Upload images on failure
uses: actions/upload-artifact@v4
if: failure()
with:
name: cypress-screenshots
path: apps/ui/cypress/screenshots
if-no-files-found: ignore
- name: Stop container
run: docker stop tilavaraus-ui-server