Skip to content

Test package managers #193

Test package managers

Test package managers #193

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