Skip to content

test(e2e): use cypress action #21

test(e2e): use cypress action

test(e2e): use cypress action #21

Workflow file for this run

name: End-to-End Testing (Cypress) πŸš€
on:
push:
branches:
- main
pull_request:
types: [opened, synchronize, reopened]
schedule:
- cron: '0 2 * * FRI'
jobs:
install:
runs-on: ubuntu-latest
steps:
- name: Checkout πŸ›Ž
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '18'
- name: Install dependencies
run: npm install
- name: Build Next.js app
run: npm run build
env:
NODE_ENV: ${{ matrix.env.name }}
NEXT_PUBLIC_REKOR_DEFAULT_DOMAIN: ${{ matrix.env.NEXT_PUBLIC_REKOR_DEFAULT_DOMAIN }}
- name: Start Next.js app
run: npm run start &
env:
NODE_ENV: ${{ matrix.env.name }}
NEXT_PUBLIC_REKOR_DEFAULT_DOMAIN: ${{ matrix.env.NEXT_PUBLIC_REKOR_DEFAULT_DOMAIN }}
- name: Wait for Next.js to start
run: npx wait-on http://localhost:3000
- name: Install browsers for Cypress
run: |
if [[ "${{ matrix.browser }}" == "chrome" ]]; then
sudo apt-get install -y google-chrome-stable;
elif [[ "${{ matrix.browser }}" == "firefox" ]]; then
sudo apt-get install -y firefox;
fi
- name: Cypress install
uses: cypress-io/github-action@v6
with:
# disable running of tests within install job
runTests: false
build: npm run build
- name: Save build folder
uses: actions/upload-artifact@v4
with:
name: build
if-no-files-found: error
path: build
cypress-run:
runs-on: ubuntu-latest
needs: install
timeout-minutes: 30
strategy:
matrix:
browser: [ chrome, electron ]
env:
- name: no-variable
NEXT_PUBLIC_REKOR_DEFAULT_DOMAIN: ""
- name: with-variable
NEXT_PUBLIC_REKOR_DEFAULT_DOMAIN: "https://rekor.sigstore.dev"
env:
CYPRESS_baseUrl: ${{ matrix.env.url }}
steps:
- name: Checkout πŸ›Ž
uses: actions/checkout@v4
- name: Download the build folder
uses: actions/download-artifact@v4
with:
name: build
path: .next
- name: Start Next.js app
run: npm run start &
env:
NODE_ENV: ${{ matrix.env.name }}
NEXT_PUBLIC_REKOR_DEFAULT_DOMAIN: ${{ matrix.env.NEXT_PUBLIC_REKOR_DEFAULT_DOMAIN }}
- name: Wait for Next.js to start
run: npx wait-on http://localhost:3000
- name: Run Cypress tests
uses: cypress-io/github-action@v6
with:
browser: ${{ matrix.browser }}
record: true
parallel: true
env:
NODE_ENV: ${{ matrix.env.name }}
NEXT_PUBLIC_REKOR_DEFAULT_DOMAIN: ${{ matrix.env.NEXT_PUBLIC_REKOR_DEFAULT_DOMAIN }}
CYPRESS_baseUrl: "http://localhost:3000"
- name: Upload Electron artifacts πŸ“Έ
uses: actions/upload-artifact@v4
with:
name: electron-artifacts
path: |
./artifacts/electron/videos
./artifacts/electron/screenshots
if-no-files-found: ignore
retention-days: 5