This repository has been archived by the owner on Jan 28, 2025. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 461
208 lines (182 loc) · 7.38 KB
/
e2e-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
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
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
name: End-to-end Tests
on:
workflow_dispatch:
inputs:
pull_request_id:
description: "Pull Request ID"
required: false
default: ""
sha:
description: "GitHub SHA"
required: false
default: ""
jobs:
initialize:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: true
matrix:
os: [ubuntu-latest]
outputs:
pr_git_sha: ${{ steps.set_pr_git_sha.outputs.pr_git_sha }}
steps:
# For non-fork PRs
- uses: actions/checkout@v2
if: ${{ github.event.inputs.pull_request_id == '' }}
with:
ref: ${{ github.event.inputs.sha || github.ref }}
# For manually run PRs
- name: Initialize empty git repository
if: ${{ github.event.inputs.pull_request_id != '' }}
run: git init --initial-branch serverless-next-js-placeholder
- name: Checkout pull request
if: ${{ github.event.inputs.pull_request_id != '' }}
uses: dawidd6/action-checkout-pr@v1
with:
pr: ${{ github.event.inputs.pull_request_id }}
- name: Set pull request's git SHA
id: set_pr_git_sha
if: ${{ github.event.inputs.pull_request_id != '' }}
run: |
echo "PR_GIT_SHA=$(git rev-parse HEAD)" >> $GITHUB_ENV
echo "::set-output name=pr_git_sha::$(git rev-parse HEAD)"
- name: Mark end-to-end tests as pending with run URL
# For manual runs (e.g for fork PRs) don't update commit status as there won't be permissions to do so
if: ${{ github.event.inputs.pull_request_id == '' }}
uses: Sibz/github-status-action@v1
with:
authToken: ${{ secrets.GITHUB_TOKEN }}
context: "End-to-end Tests"
description: "Waiting for end-to-end tests to pass"
state: "pending"
sha: ${{ steps.set_pr_git_sha.outputs.pr_git_sha || github.event.inputs.sha || github.sha }}
target_url: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}
- name: Wait for existing workflow to complete before e2e tests
uses: softprops/turnstyle@v1
with:
poll-interval-seconds: 30
same-branch-only: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run-e2e-tests:
needs: [initialize]
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
node-version: [14.x]
os: [ubuntu-latest]
app:
# Current minor version of Next.js
- next-app
- next-app-experimental
- next-app-using-serverless-trace
- next-app-with-trailing-slash
- next-app-with-base-path
- next-app-dynamic-routes
- next-app-with-locales
- next-app-with-locales-using-serverless-trace
# Previous minor version of Next.js
- prev-next-app
- prev-next-app-with-trailing-slash
- prev-next-app-with-base-path
- prev-next-app-dynamic-routes
# Add additional single app for windows e2e testing
include:
- node-version: 14.x
os: windows-latest
app: next-app-windows
steps:
# For non-fork PRs
- uses: actions/checkout@v2
if: ${{ github.event.inputs.pull_request_id == '' }}
with:
ref: ${{ github.event.inputs.sha || github.ref }}
# For manually run PRs
- name: Initialize empty git repository
if: ${{ github.event.inputs.pull_request_id != '' }}
run: git init --initial-branch serverless-next-js-placeholder
- name: Checkout pull request
if: ${{ github.event.inputs.pull_request_id != '' }}
uses: dawidd6/action-checkout-pr@v1
with:
pr: ${{ github.event.inputs.pull_request_id }}
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node-version }}
- name: Cache Yarn
uses: actions/cache@v2
with:
path: ${{ github.workspace }}/.yarn
key: e2e-tests-v1-${{ matrix.os }}-${{ matrix.node-version }}-${{ matrix.app }}-${{ hashFiles('yarn.lock', 'packages/serverless-patched/yarn.lock', 'packages/e2e-tests/test-utils/yarn.lock') }}
restore-keys: |
e2e-tests-v1-${{ matrix.os }}-${{ matrix.node-version }}-${{ matrix.app }}-
# - name: "Download build"
# uses: actions/download-artifact@v2
# with:
# name: build-${{ matrix.os }}.tar.gz
#
# - name: "Uncompress build"
# run: tar -xf build-${{ matrix.os }}.tar.gz
- name: Setup yarn
run: yarn install --immutable --inline-builds
- name: Run yarn build
env:
NODE_OPTIONS: "--max-old-space-size=4096"
run: yarn build
- name: Build serverless-patched
working-directory: packages/serverless-patched
env:
NODE_OPTIONS: "--max-old-space-size=4096"
run: yarn install --immutable && yarn build
- name: Choose latest next.js version
if: ${{ !startsWith(matrix.app, 'prev') }}
working-directory: packages/e2e-tests/${{ matrix.app }}
run: yarn add next@latest
- name: Wait for existing workflow to complete before e2e tests
uses: softprops/turnstyle@v1
with:
poll-interval-seconds: 30
same-branch-only: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Run e2e tests
working-directory: packages/e2e-tests/${{ matrix.app }}
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_AT }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_ST }}
AWS_DEFAULT_REGION: us-east-1
WAIT_TIMEOUT: 900
CYPRESS_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed for testing external rewrites to GitHub API without getting throttled
NODE_OPTIONS: "--max-old-space-size=4096"
run: |
yarn install --immutable
yarn e2e:ci
timeout-minutes: 30 # In case something goes wrong
- name: Mark end-to-end tests as failed
# For manual runs (e.g for fork PRs) don't update commit status as there won't be permissions to do so
if: ${{ failure() && github.event.inputs.pull_request_id == '' }}
uses: Sibz/github-status-action@v1
with:
authToken: ${{ secrets.GITHUB_TOKEN }}
context: "End-to-end Tests"
description: "End-to-end tests have failed"
state: "failure"
sha: ${{ needs.initialize.outputs.pr_git_sha || github.event.inputs.sha || github.sha }}
target_url: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}
finalize:
needs: [initialize, run-e2e-tests]
runs-on: [ubuntu-latest]
steps:
- name: Mark end-to-end tests as succeeded
# For manual runs (e.g for fork PRs) don't update commit status as there won't be permissions to do so
if: ${{ github.event.inputs.pull_request_id == '' }}
uses: Sibz/github-status-action@v1
with:
authToken: ${{ secrets.GITHUB_TOKEN }}
context: "End-to-end Tests"
description: "End-to-end tests have passed"
state: "success"
sha: ${{ needs.initialize.outputs.pr_git_sha || github.event.inputs.sha || github.sha }}
target_url: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}