forked from Klaveness-Digital/cypress-cucumber-preprocessor
-
-
Notifications
You must be signed in to change notification settings - Fork 149
118 lines (113 loc) · 3.16 KB
/
examples-branch.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
name: Examples (branch)
on:
push:
branches-ignore:
- master
defaults:
run:
shell: bash
jobs:
find-examples:
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- name: Checkout
uses: actions/checkout@v4
- id: set-matrix
name: Prepare
run: echo "matrix=$(node -p "JSON.stringify(fs.readdirSync('examples').filter(f => f !== 'readme.md'))")" >> $GITHUB_OUTPUT
build-package:
runs-on: ubuntu-latest
container:
image: cypress/base:latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Cache NPM modules
uses: actions/cache@v4
with:
path: ~/.npm
key: npm-linux@latest
- name: Cache Cypress binaries
uses: actions/cache@v4
with:
path: ~/.cache/Cypress
key: cypress-linux@latest
- name: Change owner
run: "chown root: ."
- name: Dependencies
env:
CYPRESS_INSTALL_BINARY: "0"
run: |
npm install
- name: Build
run: npm run build
- name: Pack
run: npm pack
- name: Store dirty build
uses: actions/upload-artifact@v4
with:
name: build
path: badeball-*
example:
needs:
- find-examples
- build-package
runs-on: ubuntu-latest
container:
image: cypress/base:latest
strategy:
fail-fast: false
matrix:
example: ${{fromJson(needs.find-examples.outputs.matrix)}}
env:
NPM_CONFIG_PACKAGE_LOCK: "false"
steps:
- uses: actions/setup-node@v4
with:
node-version: 18
- name: Checkout
uses: actions/checkout@v4
- name: Cache NPM modules
uses: actions/cache@v4
with:
path: ~/.npm
key: npm@${{ matrix.example }}
- name: Cache Cypress binaries
uses: actions/cache@v4
with:
path: ~/.cache/Cypress
key: cypress-examples
# In lack of native support, https://github.com/actions/checkout/issues/172.
- name: Make checkout sparse
run: |
shopt -s extglob
rm -rf examples/!(${{ matrix.example }})
rm -rf !(examples)
- name: Retrieve dirty build
uses: actions/download-artifact@v4
with:
name: build
path: examples/${{ matrix.example }}
- name: Install NPM modules
working-directory: examples/${{ matrix.example }}
run: npm install --engine-strict badeball-*
# For reasons unknown to me, `npm install <path>` will not trigger postinstall scripts.
# See https://github.com/npm/cli/issues/4804.
- name: Patch packages
working-directory: examples/${{ matrix.example }}
run: npx patch-package
- name: Run Cypress
working-directory: examples/${{ matrix.example }}
run: |
if [[ "${{ matrix.example }}" == ct-* ]]; then
npx cypress run --component
else
npx cypress run --e2e
fi
- name: Versions
run: |
npx cypress --version
node --version
npm --version