forked from compdemocracy/polis
-
Notifications
You must be signed in to change notification settings - Fork 0
115 lines (99 loc) · 3.78 KB
/
cypress-tests.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
# Changes to workflow name require changes to badge URL in README.md
name: E2E Tests
on:
push:
branches:
- dev
paths-ignore:
- "**.md"
pull_request:
paths-ignore:
- "**.md"
jobs:
cypress-run:
# Platform recommended in cypress-io/github-action docs.
runs-on: ubuntu-20.04
env:
# Use native docker command within docker-compose
COMPOSE_DOCKER_CLI_BUILD: 1
# Use buildkit to speed up docker command
DOCKER_BUILDKIT: 1
steps:
# This ensures only the most recently push commit will keep running.
- name: Cancel other active runs of this workflow
uses: rokroskar/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Checkout
uses: actions/[email protected]
# This step helps us know when to skip future steps, particularly if
# we're on a fork where upstream secrets won't be available.
- name: Ensure secrets available
env:
GOOGLE_CREDENTIALS_BASE64: ${{ secrets.GOOGLE_CREDENTIALS_BASE64 }}
run: |
if [ -n "$GOOGLE_CREDENTIALS_BASE64" ]; then
echo "DO_COMMENT_TRANSLATION=true" >> $GITHUB_ENV
fi
- name: Enable comment translation
if: env.DO_COMMENT_TRANSLATION
run: |
echo GOOGLE_CREDENTIALS_BASE64=${{ secrets.GOOGLE_CREDENTIALS_BASE64 }} >> server/docker-dev.env
echo SHOULD_USE_TRANSLATION_API=true >> server/docker-dev.env
- name: Set server configuration
run: |
# Test email transport failovers
# mailgun: unconfigured transport (will fail)
# aws-ses: unconfigured transport (will fail)
# nonexistent: nonexistent transport (will fail)
# maildev: catch-all dev email server running in container (will work)
echo EMAIL_TRANSPORT_TYPES=mailgun,aws-ses,nonexistent,maildev >> server/docker-dev.env
- name: Ensure embed test html is served
run: cp e2e/cypress/fixtures/html/embed.html client-admin/embed.html
- name: Serve app via docker-compose
run: docker-compose up --detach
- name: "Run Cypress tests: default"
uses: cypress-io/github-action@v2
env:
CYPRESS_BASE_URL: https://localhost
with:
working-directory: ./e2e
# Ignore all tests with pattern *.secrets.spec.js
spec: "**/polis/**/!(*.secrets).spec.js"
browser: chrome
- name: "Run Cypress tests: comment translation"
if: env.DO_COMMENT_TRANSLATION
uses: cypress-io/github-action@v2
env:
CYPRESS_BASE_URL: https://localhost
with:
install: false
working-directory: ./e2e
spec: "**/comment-translation.secrets.spec.js"
# Prevent cypress from discarding screenshots/videos from default test run.
config: "trashAssetsBeforeRuns=false"
browser: chrome
# NOTE: screenshots will be generated only if E2E test failed
# thus we store screenshots only on failures
- name: Save screenshot artefacts
uses: actions/[email protected]
if: failure()
with:
name: cypress-screenshots
path: e2e/cypress/screenshots
# Test run video was always captured, so this action uses "always()" condition
- name: Save video artefacts
uses: actions/[email protected]
if: always()
with:
name: cypress-videos
path: e2e/cypress/videos
- name: Check status of containers
if: failure()
run: docker-compose ps
- name: 'Check logs: server'
if: failure()
run: docker-compose logs server
- name: 'Check logs: nginx-proxy'
if: failure()
run: docker-compose logs nginx-proxy