-
Notifications
You must be signed in to change notification settings - Fork 9
91 lines (80 loc) · 2.91 KB
/
test.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
name: Automatic Testing
on:
workflow_dispatch:
jobs:
set_vars:
name: Set Auxiliary Variables
runs-on: ubuntu-latest
timeout-minutes: 5
outputs:
should_run: ${{ steps.set_should_run.outputs.should_run }}
steps:
- name: Clone repository
uses: actions/checkout@v3
- name: Checking whether relevant files were changed
uses: dorny/[email protected]
id: changes
with:
filters: |
infra:
- '.github/workflows/test.yml'
- 'env.zip.gpg'
- 'Makefile'
- 'docker-compose.dev.yml'
- 'docker-compose.test.yml'
- 'Dockerfile-dev'
- 'bin/**'
app:
- 'frontend/**'
- 'middleware/**'
- 'reverse-proxy/**'
tests:
- 'frontend-e2e/**'
- name: Set `should_run`
id: set_should_run
uses: actions/github-script@v6
with:
script: |
const refName = context.ref.split('/').slice(2).join('/')
core.info(`Detected ref: ${refName}`)
const event = context.eventName
core.info(`Detected event: ${event}`)
if (event === 'pull_request') {
const relevantFilesChanged = ${{ steps.changes.outputs.infra == 'true' || steps.changes.outputs.app == 'true' || steps.changes.outputs.tests == 'true' }}
core.info(`Relevant files changed: ${relevantFilesChanged}`)
if (relevantFilesChanged) {
core.info('PR event with relevant changes ➡️ running E2E tests 🧪')
core.setOutput('should_run', true)
} else {
core.info('PR event with irrelevant changes ➡️ no need for E2E tests 😴')
core.setOutput('should_run', false)
}
} else {
core.info('Not a PR event ➡️ running E2E tests 🧪')
core.setOutput('should_run', true)
}
e2e:
if: ${{ needs.set_vars.outputs.should_run == 'true' }}
needs: set_vars
name: End-to-end Tests
runs-on: ubuntu-latest
timeout-minutes: 60
steps:
- name: Clone repository
uses: actions/checkout@v3
- name: Create `env_passphrase` file for decryption of environment variables
run: echo -n ${{ secrets.ENV_PASSPHRASE }} > env_passphrase
- name: Build `docker-compose.dev.yml` with empty environment variables
run: |
touch .env.dev stemweb/.env.dev && \
make build-dev
- name: Decrypt environment variables stored in `env.zip.gpg`
run: make decrypt-env
- name: Run the end-to-end tests
run: pwd && ls && make tests
- name: Upload test run videos
if: failure()
uses: actions/upload-artifact@v3
with:
name: cypress_videos
path: frontend-e2e/cypress/videos