-
Notifications
You must be signed in to change notification settings - Fork 2k
149 lines (142 loc) · 5.64 KB
/
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
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
name: End-to-end tests
on:
push:
branches: [main]
paths-ignore:
- '**.md'
- '**.d.ts'
- 'examples/**'
- 'private/**'
- 'website/**'
- '.github/**'
- '!.github/workflows/e2e.yml'
pull_request_target:
types: [opened, synchronize, reopened, labeled]
paths-ignore:
- '**.md'
- '**.d.ts'
- 'examples/**'
- 'private/**'
- 'website/**'
- '.github/**'
pull_request:
types: [opened, synchronize, reopened]
paths:
- .github/workflows/e2e.yml
concurrency: ${{ github.workflow }}--${{ github.ref }}
env:
YARN_ENABLE_GLOBAL_CACHE: false
jobs:
e2e:
if:
${{ !github.event.pull_request ||
(contains(github.event.pull_request.labels.*.name, 'safe to test') &&
github.event.pull_request.state == 'open') ||
(github.event.pull_request.head.repo.full_name == github.repository &&
github.event.event_name != 'labeled') }}
name: Browser tests
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v3
with:
ref: ${{ github.event.pull_request.head.sha || github.sha }}
- name: Get yarn cache directory path
id: yarn-cache-dir-path
run:
echo "dir=$(corepack yarn config get cacheFolder)" >> $GITHUB_OUTPUT
- uses: actions/cache@v3
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- name: Create cache folder for Cypress
id: cypress-cache-dir-path
run: echo "dir=$(mktemp -d)" >> $GITHUB_OUTPUT
- uses: actions/cache@v3
with:
path: ${{ steps.cypress-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-cypress
- name: Install Node.js
uses: actions/setup-node@v3
with:
node-version: lts/*
- name: Start Redis
uses: supercharge/redis-github-action@1.4.0
with:
redis-version: 7
- name: Install dependencies
run: corepack yarn install --immutable
env:
# https://docs.cypress.io/guides/references/advanced-installation#Binary-cache
CYPRESS_CACHE_FOLDER: ${{ steps.cypress-cache-dir-path.outputs.dir }}
- name: Build Uppy packages
run: corepack yarn build
- name: Run end-to-end browser tests
run: corepack yarn run e2e:ci
env:
COMPANION_DATADIR: ./output
COMPANION_DOMAIN: localhost:3020
COMPANION_PROTOCOL: http
COMPANION_REDIS_URL: redis://localhost:6379
COMPANION_UNSPLASH_KEY: ${{secrets.COMPANION_UNSPLASH_KEY}}
COMPANION_UNSPLASH_SECRET: ${{secrets.COMPANION_UNSPLASH_SECRET}}
COMPANION_AWS_KEY: ${{secrets.COMPANION_AWS_KEY}}
COMPANION_AWS_SECRET: ${{secrets.COMPANION_AWS_SECRET}}
COMPANION_AWS_BUCKET: ${{secrets.COMPANION_AWS_BUCKET}}
COMPANION_AWS_REGION: ${{secrets.COMPANION_AWS_REGION}}
VITE_COMPANION_URL: http://localhost:3020
VITE_TRANSLOADIT_KEY: ${{secrets.TRANSLOADIT_KEY}}
VITE_TRANSLOADIT_SECRET: ${{secrets.TRANSLOADIT_SECRET}}
VITE_TRANSLOADIT_TEMPLATE: ${{secrets.TRANSLOADIT_TEMPLATE}}
VITE_TRANSLOADIT_SERVICE_URL: ${{secrets.TRANSLOADIT_SERVICE_URL}}
# https://docs.cypress.io/guides/references/advanced-installation#Binary-cache
CYPRESS_CACHE_FOLDER: ${{ steps.cypress-cache-dir-path.outputs.dir }}
- name: Upload videos in case of failure
uses: actions/upload-artifact@v3
if: failure()
with:
name: videos-and-screenshots
path: |
e2e/cypress/videos/
e2e/cypress/screenshots/
- name: Remove 'pending end-to-end tests' label
# Remove the 'pending end-to-end tests' label if tests ran successfully
if:
github.event.pull_request &&
contains(github.event.pull_request.labels.*.name, 'pending end-to-end
tests')
run: gh pr edit "$NUMBER" --remove-label 'pending end-to-end tests'
env:
NUMBER: ${{ github.event.pull_request.number }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Remove 'safe to test' label
# Remove the 'safe to test' label to ensure next commit needs approval before re-running this.
if:
always() && github.event.pull_request &&
contains(github.event.pull_request.labels.*.name, 'safe to test')
run: gh pr edit "$NUMBER" --remove-label 'safe to test'
env:
NUMBER: ${{ github.event.pull_request.number }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
add-pending-e2e-label:
# Add the 'pending end-to-end tests' label for PRs that come from forks.
# For those PRs, we want to review the code before running e2e tests.
# See https://securitylab.github.com/research/github-actions-preventing-pwn-requests/.
if:
github.event.pull_request.state == 'open' &&
github.event.pull_request.head.repo.full_name != github.repository &&
!contains(github.event.pull_request.labels.*.name, 'safe to test') &&
!contains(github.event.pull_request.labels.*.name, 'pending end-to-end
tests')
runs-on: ubuntu-latest
steps:
- name: Add label
env:
NUMBER: ${{ github.event.pull_request.number }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run:
gh pr edit "$NUMBER" --repo ${{ github.repository }} --add-label
'pending end-to-end tests'