Skip to content

Commit

Permalink
Run tests on GitHub Action (#3)
Browse files Browse the repository at this point in the history
  • Loading branch information
younglim authored Jul 23, 2024
1 parent c0e6a9c commit 5404878
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 7 deletions.
3 changes: 1 addition & 2 deletions .github/workflows/docker-tests.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
name: Run Docker Tests and Upload Results

on:
workflow_dispatch:
inputs:
Expand All @@ -17,7 +16,7 @@ jobs:
steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Set up Docker
uses: docker/setup-buildx-action@v1

Expand Down
14 changes: 11 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# purple-a11y-tests
#### [Cypress](https://www.cypress.io/) functional tests for [Purple A11y](https://github.com/govtechsg/purple-a11y) to verify the correctness of Purple A11y CLI and integration module.

[Cypress](https://www.cypress.io/) functional tests for [Purple A11y](https://github.com/govtechsg/purple-a11y) to verify the correctness of Purple A11y CLI and integration module.

## Run Locally
#### Step 1:
Expand Down Expand Up @@ -51,6 +52,13 @@ shell_scripts/stop_docker.sh
colima stop
```

## Limitations
- Docker can only run chromium in headless mode, using chrome and edge for Purple A11y will not be tested
## Run on GitHub Actions
Test changes to tests by triggering Actions to run the test on any branch of `tests` or `purple-a11y`.

- Go to [Actions](https://github.com/GovTechSG/purple-a11y-tests/actions/workflows/docker-tests.yml) tab.
- Select `Run workflow` and choose the branch under `Use workflow from` to change the tests branch.
- Optionally, the different git+URL of Purple A11y to change the branch of Purple A11y in `Checkout a specific purple a11y branch`.

## Limitations
- Docker can only run Chromium in headless mode or through Xvfb (`xvfb-run`).
- The tests will not run successfully on Chrome or Edge in Docker.
5 changes: 4 additions & 1 deletion shell_scripts/host_websites_and_run_cypress.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
cd ./www

# Run Python HTTP server in the www directory
python3 http_server_auth.py --bind 0.0.0.0 --port 8000 &
python3 http_server_auth.py --bind 0.0.0.0 --port 8000 > /dev/null 2>&1 &

# Save the PID of the background process
python_pid=$!
Expand Down Expand Up @@ -34,6 +34,9 @@ cd node_modules/@govtechsg/purple-hats && \
npm run build || true && \
cd ../../../

# npm run build tests repo
npm run build

echo "Starting Cypress tests..."

# Create exports directory
Expand Down
2 changes: 1 addition & 1 deletion shell_scripts/start_docker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ fi
docker build -t purple-a11y-tests .

# Add hostname mappings and run the container
docker run -dit --name purple-a11y-tests-instance --add-host=main.purplea11y.local:0.0.0.0 --add-host=diffHostname.purplea11y.local:0.0.0.0 purple-a11y-tests
docker run -dit --name purple-a11y-tests-instance --add-host=main.purplea11y.local:0.0.0.0 --add-host=diffHostname.purplea11y.local:0.0.0.0 --add-host=docs.google.com:0.0.0.0 purple-a11y-tests

# Copy the Cypress tests into the docker container
if [[ "$(uname)" == "Darwin" ]]; then
Expand Down

0 comments on commit 5404878

Please sign in to comment.