Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: add tests for examples #1271

Merged
merged 1 commit into from
Jan 2, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions .github/workflows/example-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Example Tests
# This workflow tests examples from the examples directory of this repo.

on:
push:
paths:
- examples/**
pull_request:
workflow_dispatch:

jobs:
example:
runs-on: ubuntu-24.04
strategy:
fail-fast: false
matrix:
directory: [
basic-mini,
basic,
chromium,
firefox-esr,
included-as-non-root
]
steps:
- uses: actions/checkout@v4
- name: Run test script
working-directory: examples/${{ matrix.directory }}
run: ./scripts/test.sh
8 changes: 8 additions & 0 deletions examples/basic-mini/scripts/test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/bash
set -e # fail on error
#
# Run in examples/basic-mini directory
# (amd64 only)
#
echo Test base-mini with cypress/included in Chrome
docker run --rm -v .:/app -w /app --entrypoint cypress cypress/included run -b chrome
14 changes: 14 additions & 0 deletions examples/basic/scripts/test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/bash
set -e # fail on error
#
# Run in examples/basic directory
# (amd64 only)
#
echo Test basic example
npm ci # Install dependencies
echo Build and test with cypress/base in Electron
docker build -f Dockerfile.base -t test-base . # Build a new image
docker run --rm --entrypoint bash test-base -c "npx cypress run" # Run Cypress test in container
echo Build and test with cypress/browsers in Chrome
docker build -f Dockerfile.browsers -t test-browsers . # Build a new image
docker run --rm --entrypoint bash test-browsers -c "npx cypress run -b chrome" # Run Cypress test in container using Chrome
9 changes: 9 additions & 0 deletions examples/chromium/scripts/test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/bash
set -e # fail on error
#
# Run in examples/chromium directory
#
echo Test Chromium in cypress/base
npm ci # Install dependencies
docker build -t test-chromium . # Build a new image
docker run --rm --entrypoint bash test-chromium -c "npx cypress run --browser chromium" # Run Cypress test using Chromium
9 changes: 9 additions & 0 deletions examples/firefox-esr/scripts/test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/bash
set -e # fail on error
#
# Run in examples/firefox-esr directory
#
echo Test Firefox ESR in cypress/base
npm ci # Install dependencies
docker build -t test-firefox-esr . # Build a new image
docker run --rm --entrypoint bash test-firefox-esr -c "npx cypress run --browser firefox" # Run Cypress test using Firefox ESR
7 changes: 7 additions & 0 deletions examples/included-as-non-root/scripts/test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash
set -e # fail on error
#
# Run in examples/included-as-non-root directory
#
echo Test cypress/included running under node \(non-root\) user
docker run --rm -v .:/test -w /test -u node cypress/included
40 changes: 40 additions & 0 deletions examples/test-all-examples.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#!/bin/bash
set -e # fail on error
#
# Test all examples
# Run in examples directory
#
# These examples are compatible with amd64 architecture
namedExamplesAmd64=(
'basic'
'basic-mini'
'chromium'
'firefox-esr'
'included-as-non-root'
)

# These examples are compatible with arm64 architecture
namedExamplesArm64=(
'chromium'
'firefox-esr'
)

if [ "$(uname -m)" = "x86_64" ]; then
echo Testing all examples
for i in ${!namedExamplesAmd64[@]}; do
echo
echo testing examples/${namedExamplesAmd64[$i]} directory
cd ${namedExamplesAmd64[$i]}
./scripts/test.sh
cd ..
done
else
echo Testing examples for arm64 only
for i in ${!namedExamplesArm64[@]}; do
echo
echo testing examples/${namedExamplesArm64[$i]} directory
cd ${namedExamplesArm64[$i]}
./scripts/test.sh
cd ..
done
fi
Loading