129 lines (126 loc) · 4.31 KB
/
test-app-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
name: Test Preview.js app end-to-end
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
on:
push:
branches:
- main
paths:
- "**"
- ".github/workflows/test-app-e2e.yaml"
- "!assets/**"
- "!integrations/**"
pull_request:
branches:
- "*"
paths:
- "**"
- ".github/workflows/test-app-e2e.yaml"
- "!assets/**"
- "!integrations/**"
jobs:
e2e-tests:
runs-on: ${{ matrix.os }}
strategy:
matrix:
node-version: [18.x]
os: [ubuntu-20.04, macos-11, windows-2022]
group: [0, 1, 2]
include:
# Important: Node 14 version must match minimum checked
# for CLI package.json, as well as IntelliJ and VS Code
# node --version checks.
- node-version: 14.18.0
os: ubuntu-latest
group: 0
- node-version: 14.18.0
os: ubuntu-latest
group: 1
- node-version: 14.18.0
os: ubuntu-latest
group: 2
- node-version: 16.9.0
os: ubuntu-latest
group: 0
- node-version: 16.9.0
os: ubuntu-latest
group: 1
- node-version: 16.9.0
os: ubuntu-latest
group: 2
steps:
- uses: actions/checkout@v3
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
- name: Cache pnpm modules
uses: actions/cache@v3
with:
path: ~/.pnpm-store
key: ${{ runner.os }}-${{ hashFiles('pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-
- uses: pnpm/action-setup@v2.2.4
with:
run_install: true
- run: pnpm turbo run build
env:
SKIP_PREFLIGHT_CHECK: "true"
- run: pnpm install # necessary to link e2e-test-runner
- run: pnpm turbo run e2e-test
env:
GROUP_INDEX: ${{ matrix.group }}
GROUP_COUNT: 3
- name: Archive success screenshots
if: ${{ always() }}
uses: actions/upload-artifact@v3
with:
name: success-screenshots-${{ runner.os }}-${{ matrix.node-version }}-${{ matrix.group }}
path: app/tests/__screenshots__
- name: Update screenshots on non-main branches
run: |
if [ -z "$(git status --porcelain)" ]; then
echo "No changes detected."
else
git status
export SCREENSHOTS_CHANGED=1
echo "::set-env name=SCREENSHOTS_CHANGED::$SCREENSHOTS_CHANGED"
git add app/tests/__screenshots__
git stash
git config --global user.name 'CI bot'
git config --global user.email 'fwouts@users.noreply.github.com'
git fetch
git checkout ${{ github.head_ref }}
git pull
git stash pop || echo "Conflict on git stash pop. Perhaps another Node version tried to update the same screenshot?"
git commit --allow-empty -am "bot: update screenshots"
if ! git push origin ${{ github.head_ref }}; then
# Try again as it may be a race condition.
git pull --rebase
git push origin ${{ github.head_ref }}
fi
fi
if: ${{ github.ref != 'refs/heads/main' && matrix.os == 'ubuntu-20.04' }}
shell: bash
env:
ACTIONS_ALLOW_UNSECURE_COMMANDS: "true"
- uses: actions/github-script@v6
if: ${{ env.SCREENSHOTS_CHANGED == '1' }}
env:
MATRIX_NODE_VERSION: ${{ matrix.node-version }}
MATRIX_OS: ${{ matrix.os }}
MATRIX_GROUP: ${{ matrix.group }}
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: `⚠️ Screenshots have changed: group ${process.env.MATRIX_GROUP}, ${process.env.MATRIX_OS} (Node ${process.env.MATRIX_NODE_VERSION})`
})
- name: Fail if screenshots have changed on main branch
run: git diff --exit-code
if: ${{ github.ref == 'refs/heads/main' && matrix.os == 'ubuntu-20.04' }}