-
Notifications
You must be signed in to change notification settings - Fork 2
145 lines (128 loc) · 4.55 KB
/
tests-karma-editor.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
name: Editor Integration Tests
on:
push:
# Only run if editor-related files changed.
paths:
- 'assets/src/edit-story/**.js'
- 'babel.config.cjs'
- 'karma-edit-story.config.cjs'
- 'webpack.config.cjs'
- 'webpack.config.test.cjs'
- 'packages/**/*.js'
- '**/package.json'
- 'package-lock.json'
- '__static__/**'
branches:
- main
- release/*
pull_request:
# Only run if editor-related files changed.
paths:
- 'assets/src/edit-story/**.js'
- 'babel.config.cjs'
- 'karma-edit-story.config.cjs'
- 'webpack.config.cjs'
- 'webpack.config.test.cjs'
- 'packages/**/*.js'
- '**/package.json'
- 'package-lock.json'
- '__static__/**'
types:
- opened
- reopened
- synchronize
- ready_for_review
# Cancels all previous workflow runs for pull requests that have not completed.
concurrency:
# The concurrency group contains the workflow name and the branch name for pull requests
# or the commit hash for any other events.
group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.head_ref || github.sha }}
cancel-in-progress: true
jobs:
karma:
name: Karma
runs-on: ubuntu-latest
timeout-minutes: 60
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Read .nvmrc
run: echo "##[set-output name=NVMRC;]$(cat .nvmrc)"
id: nvm
- name: Setup Node
uses: actions/[email protected]
with:
node-version: ${{ steps.nvm.outputs.NVMRC }}
cache: npm
# TODO: Remove need for `npm install puppeteer`.
- name: Install dependencies
run: |
npm ci
npm install puppeteer
env:
CI: true
PUPPETEER_PRODUCT: chrome
# FIXME: https://github.com/google/web-stories-wp/issues/4364
- name: Increase max number of file watchers
run: echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p
- name: Run integration tests
run: npm run test:karma:edit-story -- --headless --snapshots --viewport=1600:1000 --coverage || npm run test:karma:edit-story:retry-failed -- --headless --snapshots --viewport=1600:1000
env:
DISABLE_ERROR_BOUNDARIES: true
- name: Add files for snapshotting
run: cp -r __static__ .test_artifacts/karma_snapshots/
- name: Upload code coverage report
uses: codecov/codecov-action@v1
with:
file: build/logs/karma-coverage/edit-story/lcov.info
flags: karmatests
- name: Upload Percy snapshots
uses: percy/[email protected]
with:
build-directory: '.test_artifacts/karma_snapshots'
flags: '--config=percy.config.yml'
env:
PERCY_TOKEN: ${{ secrets.PERCY_TOKEN }}
# The action cannot access the secret when run from a PR fork or authored by Dependabot.
if: >
github.event.pull_request.draft == false &&
github.event.pull_request.head.repo.fork == false &&
github.event.pull_request.user.login != 'dependabot[bot]'
- name: Upload CUJ coverage
uses: actions/upload-artifact@v4
with:
name: cuj-coverage-edit-story
path: build/cuj-coverage-edit-story.md
if: github.ref == 'refs/heads/main' && github.event_name == 'push'
deploy-cuj-coverage:
name: Deploy CUJ Coverage
needs: [karma]
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/main' && github.event_name == 'push'
steps:
- name: Checkout
uses: actions/checkout@v2
with:
ref: gh-pages
- name: Download coverage file
uses: actions/download-artifact@v4
with:
name: cuj-coverage-edit-story
- name: Move file
run: |
mkdir -p critical-user-journeys
rm -rf critical-user-journeys/editor.md
mv cuj-coverage-edit-story.md critical-user-journeys/editor.md
- name: Commit updates
run: |
git add .
git status
git diff --staged --quiet && echo 'No changes to commit; exiting!' && exit 0
git commit -m "Deploy CUJ coverage for ${{ github.sha }}"
git pull --no-edit --quiet
git push origin gh-pages
env:
GIT_AUTHOR_EMAIL: ${{ github.actor }}@users.noreply.github.com
GIT_AUTHOR_NAME: ${{ github.actor }}
GIT_COMMITTER_EMAIL: ${{ github.actor }}@users.noreply.github.com
GIT_COMMITTER_NAME: ${{ github.actor }}