-
Notifications
You must be signed in to change notification settings - Fork 384
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: add tests for examples (#1271)
- Loading branch information
1 parent
b163402
commit 31d5a60
Showing
7 changed files
with
115 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |