generated from KevinBatdorf/gutenberg-rust-starter
-
-
Notifications
You must be signed in to change notification settings - Fork 10
82 lines (81 loc) · 3.04 KB
/
cypress-push.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
name: Run Cypress on push
on:
push:
branches-ignore:
- main
workflow_dispatch:
jobs:
generate_file_list:
name: Generate file list
runs-on: ubuntu-latest
outputs:
spec: ${{ steps.list_files.outputs.spec }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: List Files
id: list_files
run: |
# List all the .cy.js files in the cypress/e2e directory
# and output their file names without the extension
ls cypress/e2e/*.cy.js | xargs -I{} basename {} .cy.js | jq -Rrs "split(\"\n\") | map(select(length > 0)) | tojson" | tee /tmp/spec.json
echo "spec=$(cat /tmp/spec.json)" >> "$GITHUB_OUTPUT"
npm_install:
name: Install Node modules
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Cache node modules
uses: actions/cache@v4
id: cache-node-modules
with:
path: node_modules
key: ${{ runner.os }}-node-modules-${{ hashFiles('**/package-lock.json') }}
- name: Install npm dependencies
if: steps.cache-node-modules.outputs.cache-hit != 'true'
run: npm ci
test:
name: WordPress (${{ matrix.spec }})
concurrency:
group: cypress - ${{ github.event.pull_request.number || github.ref }} - ${{ matrix.spec }}
cancel-in-progress: true
runs-on: ubuntu-latest
needs: [npm_install, generate_file_list]
strategy:
fail-fast: false
matrix:
spec: ${{ fromJson(needs.generate_file_list.outputs.spec) }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Restore node modules cache
uses: actions/cache@v4
with:
path: node_modules
key: ${{ runner.os }}-node-modules-${{ hashFiles('**/package-lock.json') }}
restore-keys: ${{ runner.os }}-node-modules-
- name: Build
run: |
npx eslint --max-warnings 0 .
npm run build
- name: Start server
run: |
npx wp-env start
echo "WordPress version: `npx wp-env run cli core version`"
- name: Cypress run
uses: cypress-io/github-action@v6
with:
spec: cypress/e2e/${{ matrix.spec }}.cy.js
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- uses: actions/upload-artifact@v4
if: failure()
with:
name: cypress-screenshots
path: cypress/screenshots
- uses: actions/upload-artifact@v4
if: failure()
with:
name: cypress-videos
path: cypress/videos