From b6174a803c78b5a0c3ee61d615277e4143373ac8 Mon Sep 17 00:00:00 2001 From: Mike McCready <66998419+MikeMcC399@users.noreply.github.com> Date: Tue, 28 Jan 2025 15:34:46 +0100 Subject: [PATCH] test: run examples in Ubuntu arm64 on GitHub --- .github/workflows/example-tests.yml | 9 +++- examples/basic-mini/scripts/test.sh | 25 +++++++-- examples/basic/scripts/test.sh | 28 +++++++--- examples/chrome-for-testing/scripts/test.sh | 54 ++++++++++++------- examples/chromium/scripts/test.sh | 22 ++++++-- examples/firefox-esr/scripts/test.sh | 22 ++++++-- examples/included-as-non-root/scripts/test.sh | 18 ++++++- examples/test-all-examples.sh | 10 ++-- 8 files changed, 148 insertions(+), 40 deletions(-) diff --git a/.github/workflows/example-tests.yml b/.github/workflows/example-tests.yml index 864c7fbc44..eb22eae911 100644 --- a/.github/workflows/example-tests.yml +++ b/.github/workflows/example-tests.yml @@ -10,7 +10,6 @@ on: jobs: example: - runs-on: ubuntu-24.04 strategy: fail-fast: false matrix: @@ -22,6 +21,14 @@ jobs: firefox-esr, included-as-non-root ] + os: [ + ubuntu-24.04, # testing Linux/amd64 platform + ubuntu-24.04-arm # testing Linux/arm64 platform + ] + exclude: + - os: ubuntu-24.04-arm + directory: chrome-for-testing #browser not available for Linux/arm64 + runs-on: ${{ matrix.os }} steps: - uses: actions/checkout@v4 - name: Run test script diff --git a/examples/basic-mini/scripts/test.sh b/examples/basic-mini/scripts/test.sh index 2984f70713..1450f6a488 100755 --- a/examples/basic-mini/scripts/test.sh +++ b/examples/basic-mini/scripts/test.sh @@ -1,8 +1,25 @@ #!/bin/bash set -e # fail on error # -# Run in examples/basic-mini directory -# (amd64 only) +# Run ./scripts/test.sh in examples/basic-mini directory # -echo Test base-mini with cypress/included in Chrome -docker run --rm -v .:/app -w /app --entrypoint cypress cypress/included run -b chrome +ARCHITECTURE=$(uname -m) +echo Running on $ARCHITECTURE + +echo Test basic-mini example + +case $ARCHITECTURE in + x86_64) + echo Testing cypress/included in amd64 using Chrome + docker run --rm -v .:/app -w /app --entrypoint cypress cypress/included run -b chrome + ;; + aarch64) + echo Testing cypress/included in arm64 using Electron + echo No other browsers available + docker run --rm -v .:/app -w /app cypress/included + ;; + *) + echo Unsupported architecture + exit 1 + ;; +esac diff --git a/examples/basic/scripts/test.sh b/examples/basic/scripts/test.sh index f79bf2f9f5..712516d64c 100755 --- a/examples/basic/scripts/test.sh +++ b/examples/basic/scripts/test.sh @@ -1,14 +1,30 @@ #!/bin/bash set -e # fail on error # -# Run in examples/basic directory -# (amd64 only) +# Run ./scripts/test.sh in examples/basic directory # +ARCHITECTURE=$(uname -m) +echo Running on $ARCHITECTURE + echo Test basic example -npm ci # Install dependencies +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 + +case $ARCHITECTURE in + x86_64) + echo Testing browsers in amd64 + 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 + ;; + aarch64) + echo Skipping browser tests for arm64 + echo No browsers available + ;; + *) + echo Unsupported architecture + exit 1 + ;; +esac diff --git a/examples/chrome-for-testing/scripts/test.sh b/examples/chrome-for-testing/scripts/test.sh index 61160d0316..a9ac1e7564 100755 --- a/examples/chrome-for-testing/scripts/test.sh +++ b/examples/chrome-for-testing/scripts/test.sh @@ -3,24 +3,40 @@ set -e # fail on error # # Test building and running custom Cypress Docker image with different # versions of Chrome for Testing -# Run in directory examples/chrome-for-testing -# (amd64 only) # -npm ci # Install dependencies +# Run ./scripts/test.sh in directory examples/chrome-for-testing # -chromeVersion=( - 'stable' - 'beta' - 'dev' - 'canary' - '130' - '131.0.6778.204' - ) -# Build, show Cypress info and run Cypress test -for i in ${!chromeVersion[@]}; do -echo -echo CHROME_VERSION ${chromeVersion[$i]} -docker build --build-arg CHROME_VERSION=${chromeVersion[$i]} -t test-chrome-for-testing . -docker run --rm --entrypoint bash test-chrome-for-testing -c "npx cypress info" -docker run --rm --entrypoint bash test-chrome-for-testing -c "npx cypress run --browser chrome-for-testing" -done +ARCHITECTURE=$(uname -m) +echo Running on $ARCHITECTURE + +case $ARCHITECTURE in + x86_64) + echo Testing Chrome for Testing in amd64 + npm ci # Install dependencies + # + chromeVersion=( + 'stable' + 'beta' + 'dev' + 'canary' + '130' + '131.0.6778.204' + ) + # Build, show Cypress info and run Cypress test + for i in ${!chromeVersion[@]}; do + echo + echo CHROME_VERSION ${chromeVersion[$i]} + docker build --build-arg CHROME_VERSION=${chromeVersion[$i]} -t test-chrome-for-testing . + docker run --rm --entrypoint bash test-chrome-for-testing -c "npx cypress info" + docker run --rm --entrypoint bash test-chrome-for-testing -c "npx cypress run --browser chrome-for-testing" + done + ;; + aarch64) + echo Skipping Chrome for Testing for arm64 + echo This browser is not available for Linux/arm64 + ;; + *) + echo Unsupported architecture + exit 1 + ;; +esac diff --git a/examples/chromium/scripts/test.sh b/examples/chromium/scripts/test.sh index 1ae9d8fc6e..54f14d9c03 100755 --- a/examples/chromium/scripts/test.sh +++ b/examples/chromium/scripts/test.sh @@ -1,9 +1,25 @@ #!/bin/bash set -e # fail on error # -# Run in examples/chromium directory +# Run ./scripts/test.sh in examples/chromium directory # +ARCHITECTURE=$(uname -m) +echo Running on $ARCHITECTURE + +case $ARCHITECTURE in + x86_64) + echo Testing Chromium browser in amd64 + ;; + aarch64) + echo Testing Chromium browser in arm64 + ;; + *) + echo Unsupported architecture + exit 1 + ;; +esac + echo Test Chromium in cypress/base -npm ci # Install dependencies -docker build -t test-chromium . # Build a new image +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 diff --git a/examples/firefox-esr/scripts/test.sh b/examples/firefox-esr/scripts/test.sh index 92fccbcd21..bd257342a5 100755 --- a/examples/firefox-esr/scripts/test.sh +++ b/examples/firefox-esr/scripts/test.sh @@ -1,9 +1,25 @@ #!/bin/bash set -e # fail on error # -# Run in examples/firefox-esr directory +# Run ./scripts/test.sh in examples/firefox-esr directory # +ARCHITECTURE=$(uname -m) +echo Running on $ARCHITECTURE + +case $ARCHITECTURE in + x86_64) + echo Testing Firefox ESR browser in amd64 + ;; + aarch64) + echo Testing Firefox ESR browser in arm64 + ;; + *) + echo Unsupported architecture + exit 1 + ;; +esac + echo Test Firefox ESR in cypress/base -npm ci # Install dependencies -docker build -t test-firefox-esr . # Build a new image +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 diff --git a/examples/included-as-non-root/scripts/test.sh b/examples/included-as-non-root/scripts/test.sh index b99b9bde9f..64ec06b993 100755 --- a/examples/included-as-non-root/scripts/test.sh +++ b/examples/included-as-non-root/scripts/test.sh @@ -1,7 +1,23 @@ #!/bin/bash set -e # fail on error # -# Run in examples/included-as-non-root directory +# Run ./scripts/test.sh in examples/included-as-non-root directory # +ARCHITECTURE=$(uname -m) +echo Running on $ARCHITECTURE + +case $ARCHITECTURE in + x86_64) + echo Testing in amd64 + ;; + aarch64) + echo Testing in arm64 + ;; + *) + echo Unsupported architecture + exit 1 + ;; +esac + echo Test cypress/included running under node \(non-root\) user docker run --rm -v .:/test -w /test -u node cypress/included diff --git a/examples/test-all-examples.sh b/examples/test-all-examples.sh index 65cf32bf21..ad5d5b0849 100755 --- a/examples/test-all-examples.sh +++ b/examples/test-all-examples.sh @@ -2,7 +2,7 @@ set -e # fail on error # # Test all examples -# Run in examples directory +# Run ./test-all-examples.sh in examples directory # # These examples are compatible with amd64 architecture namedExamplesAmd64=( @@ -16,12 +16,16 @@ namedExamplesAmd64=( # These examples are compatible with arm64 architecture namedExamplesArm64=( + 'basic' + 'basic-mini' +# 'chrome-for-testing' # not available for arm64 'chromium' 'firefox-esr' + 'included-as-non-root' ) if [ "$(uname -m)" = "x86_64" ]; then - echo Testing all examples + echo Testing examples for amd64 for i in ${!namedExamplesAmd64[@]}; do echo echo testing examples/${namedExamplesAmd64[$i]} directory @@ -30,7 +34,7 @@ if [ "$(uname -m)" = "x86_64" ]; then cd .. done else - echo Testing examples for arm64 only + echo Testing examples for arm64 for i in ${!namedExamplesArm64[@]}; do echo echo testing examples/${namedExamplesArm64[$i]} directory