-
Notifications
You must be signed in to change notification settings - Fork 1
164 lines (156 loc) · 6.8 KB
/
test-nx-project-e2e.yaml
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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
# This file is used for tests that use Nx app containers.
# For tests that don't require containers to be built first, see test-code.yaml
name: Test BCIERS Nx App containers
on:
workflow_call:
inputs:
docker_compose_file:
description: "Optional input to specify another docker-compose file. The default is docker-compose-nx-app.yaml"
required: false
type: string
image_url:
description: "Docker image URL minus the tag which will be the pull request sha"
required: true
type: string
is_nx_affected:
description: "Whether the project is affected by the PR"
required: true
type: boolean
nx_app_port:
description: "Port to run the Nx app on if using the docker-compose-nx-app.yaml file"
required: false
type: number
nx_project:
description: "Nx project to test"
required: true
type: string
env:
PGUSER: postgres
DJANGO_SECRET_KEY: ${{ secrets.DJANGO_SECRET_KEY }}
KEYCLOAK_CLIENT_ID: ${{ secrets.KEYCLOAK_CLIENT_ID }}
KEYCLOAK_CLIENT_SECRET: ${{ secrets.KEYCLOAK_CLIENT_SECRET }}
NEXTAUTH_SECRET: ${{ secrets.NEXTAUTH_SECRET }}
jobs:
e2e-tests:
if: ${{ inputs.is_nx_affected }}
name: 🧪 e2e tests chromium
runs-on: ubuntu-latest
timeout-minutes: 60
steps:
- uses: actions/checkout@v4
- name: 🎁 setup local app
uses: ./.github/actions/run-docker-compose
with:
django_secret_key: ${{ env.DJANGO_SECRET_KEY }}
docker_compose_file: ${{ inputs.docker_compose_file }}
image_url: ${{ inputs.image_url }}
keycloak_client_id: ${{ env.KEYCLOAK_CLIENT_ID }}
keycloak_client_secret: ${{ env.KEYCLOAK_CLIENT_SECRET }}
nextauth_secret: ${{ env.NEXTAUTH_SECRET }}
nx_app_port: ${{ inputs.nx_app_port }}
- name: yarn modern
shell: bash
run: |
corepack enable
- name: Install yarn dependencies
if: steps.yarn-cache.outputs.cache-hit != 'true'
run: yarn install --immutable
working-directory: ./bciers
shell: bash
- name: ⚡️ cache Playwright binaries
uses: actions/cache@v4
id: playwright-cache
with:
path: ~/.cache/ms-playwright
key: ${{ runner.os }}-chromium-ms-playwright-bciers
- name: 📥 install Playwright Chromium
if: steps.playwright-cache.outputs.cache-hit != 'true'
run: npx playwright install chromium
working-directory: ./bciers/apps/${{ inputs.nx_project }}-e2e
- name: 🎭 Run Playwright Tests
run: DEBUG=pw:api yarn nx run ${{ inputs.nx_project }}:e2e -- --project=chromium
env:
XDEBUG: pw:api,pw:browser*
API_URL: http://127.0.0.1:8000/api/
DB_USER: postgres
DB_PASSWORD: postgres
DB_NAME: registration
DB_PORT: 5432
DB_HOST: localhost
E2E_BASEURL: http://localhost:3000/
E2E_CAS_USER: ${{ secrets.E2E_CAS_USER }}
E2E_CAS_USER_GUID: ${{ secrets.E2E_CAS_USER_GUID }}
E2E_CAS_USER_PASSWORD: ${{ secrets.E2E_CAS_USER_PASSWORD}}
E2E_CAS_ADMIN_STORAGE_STATE: ${{ secrets.E2E_CAS_ADMIN_STORAGE_STATE}}
E2E_CAS_ANALYST_STORAGE_STATE: ${{ secrets.E2E_CAS_ANALYST_STORAGE_STATE}}
E2E_CAS_PENDING_STORAGE_STATE: ${{ secrets.E2E_CAS_PENDING_STORAGE_STATE}}
E2E_INDUSTRY_USER_ADMIN: bc-cas-dev
E2E_INDUSTRY_USER_ADMIN_GUID: ${{ secrets.E2E_INDUSTRY_USER_ADMIN_GUID }}
E2E_INDUSTRY_USER_ADMIN_PASSWORD: ${{ secrets.E2E_INDUSTRY_USER_ADMIN_PASSWORD }}
E2E_INDUSTRY_USER_ADMIN_STORAGE_STATE: ${{ secrets.E2E_INDUSTRY_USER_ADMIN_STORAGE_STATE}}
E2E_INDUSTRY_USER: bc-cas-dev-secondary
E2E_INDUSTRY_USER_GUID: ${{ secrets.E2E_INDUSTRY_USER_GUID }}
E2E_INDUSTRY_USER_PASSWORD: ${{ secrets.E2E_INDUSTRY_USER_PASSWORD }}
E2E_INDUSTRY_USER_STORAGE_STATE: ${{ secrets.E2E_INDUSTRY_USER_STORAGE_STATE}}
E2E_NEW_USER: bc-cas-dev-three
E2E_NEW_USER_GUID: ${{ secrets.E2E_NEW_USER_GUID }}
E2E_NEW_USER_PASSWORD: ${{ secrets.E2E_NEW_USER_PASSWORD }}
E2E_NEW_USER_STORAGE_STATE: ${{ secrets.E2E_NEW_USER_STORAGE_STATE}}
HAPPO_API_KEY: ${{ secrets.HAPPO_API_KEY }}
HAPPO_API_SECRET: ${{ secrets.HAPPO_API_SECRET }}
HAPPO_PROJECT: cas-${{ inputs.nx_project }}
SMTP_CONNECTION_STRING: smtp://@localhost:1025
working-directory: ./bciers
# Reports weren't being used regularly though leaving this in here for debugging purposes.
# Uncomment these if they are required to debug problematic e2e issues
# - name: 💾 save chromium report artifact
# # prefer to upload the report only in case of test failure
# if: failure()
# uses: actions/upload-artifact@v4
# with:
# # Store all of the reports separately by reconfiguring the report name
# name: blob-report-${{ inputs.nx_project }}-chromium
# path: bciers/blob-report
# retention-days: 1
#
# e2e-report:
# name: 📊 e2e report artifact
# runs-on: ubuntu-latest
# needs: [e2e-tests]
# if: ${{ always() && contains(needs.*.result, 'failure') && inputs.is_nx_affected }}
# steps:
# - name: Download blob reports from GitHub Actions Artifacts
# uses: actions/download-artifact@v4
# with:
# path: all-blob-reports
# # To minimize the report file size only download Chromium reports
# # If you want to debug other reports, add the * pattern back in temporarily
# pattern: blob-report-${{ inputs.nx_project }}-chromium #blob-report-*
# merge-multiple: true
#
# - name: Merge into HTML Report
# run: npx playwright merge-reports --reporter html ./all-blob-reports
# - name: Upload HTML report
# uses: actions/upload-artifact@v4
# with:
# name: playwright-report-${{ inputs.nx_project }}
# path: playwright-report
# retention-days: 14
# Call Happo api and skip the project if it wasn't affected
happo-skip-not-affected:
if: ${{ !inputs.is_nx_affected && github.ref_name != 'develop' && github.ref_name != 'main' && github.head_ref != 'develop' && github.head_ref != 'main' }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: dev env setup
uses: ./.github/actions/dev-env-setup
- name: run happo skip node script
shell: bash
env:
HAPPO_API_KEY: ${{ secrets.HAPPO_API_KEY }}
HAPPO_API_SECRET: ${{ secrets.HAPPO_API_SECRET }}
HAPPO_PROJECT: cas-${{ inputs.nx_project }}
COMMIT_SHA: ${{ github.event.pull_request.head.sha }}
run: |
cd bciers
node libs/e2e/src/utils/happo-skip.js