-
Notifications
You must be signed in to change notification settings - Fork 4
feat(workflows): add docker container testing workflow #88
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,142 @@ | ||||||||||||||||||||||||||||||||
| name: container-testing-run | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| on: | ||||||||||||||||||||||||||||||||
| push: | ||||||||||||||||||||||||||||||||
| branches: | ||||||||||||||||||||||||||||||||
| - develop | ||||||||||||||||||||||||||||||||
| paths-ignore: | ||||||||||||||||||||||||||||||||
| - 'doc/**' | ||||||||||||||||||||||||||||||||
| - '**/*.md' | ||||||||||||||||||||||||||||||||
| - '**/*.txt' | ||||||||||||||||||||||||||||||||
| - '.github/ISSUE_TEMPLATE/**' | ||||||||||||||||||||||||||||||||
| - '.github/*.md' | ||||||||||||||||||||||||||||||||
| pull_request: | ||||||||||||||||||||||||||||||||
| branches: | ||||||||||||||||||||||||||||||||
| - develop | ||||||||||||||||||||||||||||||||
| paths-ignore: | ||||||||||||||||||||||||||||||||
| - 'doc/**' | ||||||||||||||||||||||||||||||||
| - '**/*.md' | ||||||||||||||||||||||||||||||||
| - '**/*.txt' | ||||||||||||||||||||||||||||||||
| - '.github/ISSUE_TEMPLATE/**' | ||||||||||||||||||||||||||||||||
| - '.github/*.md' | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| concurrency: | ||||||||||||||||||||||||||||||||
| group: container-testing-${{ github.ref }} | ||||||||||||||||||||||||||||||||
| cancel-in-progress: true | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| jobs: | ||||||||||||||||||||||||||||||||
| container-test: | ||||||||||||||||||||||||||||||||
| runs-on: ubuntu-latest | ||||||||||||||||||||||||||||||||
| timeout-minutes: 45 | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| defaults: | ||||||||||||||||||||||||||||||||
| run: | ||||||||||||||||||||||||||||||||
| shell: bash | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| steps: | ||||||||||||||||||||||||||||||||
| # --------------------------- | ||||||||||||||||||||||||||||||||
| # CHECKOUT | ||||||||||||||||||||||||||||||||
| # --------------------------- | ||||||||||||||||||||||||||||||||
| - name: Checkout repository | ||||||||||||||||||||||||||||||||
| uses: actions/checkout@v4 | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| # --------------------------- | ||||||||||||||||||||||||||||||||
| # SCRUB RUNNER | ||||||||||||||||||||||||||||||||
| # --------------------------- | ||||||||||||||||||||||||||||||||
| - name: Scrub Docker state | ||||||||||||||||||||||||||||||||
| run: | | ||||||||||||||||||||||||||||||||
| set -euo pipefail | ||||||||||||||||||||||||||||||||
| sudo systemctl stop docker || true | ||||||||||||||||||||||||||||||||
| sudo rm -rf /var/lib/docker | ||||||||||||||||||||||||||||||||
| sudo rm -rf /var/lib/containerd | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| # Ubuntu runner already has Docker installed. | ||||||||||||||||||||||||||||||||
| - name: Verify Docker | ||||||||||||||||||||||||||||||||
| run: | | ||||||||||||||||||||||||||||||||
| set -euo pipefail | ||||||||||||||||||||||||||||||||
| docker version | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| # --------------------------- | ||||||||||||||||||||||||||||||||
| # BUILD + START CONTAINERS | ||||||||||||||||||||||||||||||||
| # --------------------------- | ||||||||||||||||||||||||||||||||
| - name: Build containers | ||||||||||||||||||||||||||||||||
| run: | | ||||||||||||||||||||||||||||||||
| set -euo pipefail | ||||||||||||||||||||||||||||||||
| docker compose -f docker-compose-dev.yml build | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| - name: Start containers | ||||||||||||||||||||||||||||||||
| run: | | ||||||||||||||||||||||||||||||||
| set -euo pipefail | ||||||||||||||||||||||||||||||||
| docker compose -f docker-compose-dev.yml up -d | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| # --------------------------- | ||||||||||||||||||||||||||||||||
| # WAIT FOR DATAVERSE (STRICT API CHECK) | ||||||||||||||||||||||||||||||||
| # --------------------------- | ||||||||||||||||||||||||||||||||
| - name: Wait for Dataverse API readiness | ||||||||||||||||||||||||||||||||
| run: | | ||||||||||||||||||||||||||||||||
| set -euo pipefail | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| URL="http://localhost:8080/api/info/version" | ||||||||||||||||||||||||||||||||
| MAX_ATTEMPTS=6 | ||||||||||||||||||||||||||||||||
| SLEEP_TIME=10 | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| echo "Checking Dataverse API readiness at $URL" | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| for attempt in $(seq 1 $MAX_ATTEMPTS); do | ||||||||||||||||||||||||||||||||
| echo "Attempt $attempt..." | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| RESPONSE=$(curl -s --max-time 10 "$URL" || true) | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| if echo "$RESPONSE" | grep -q '"status":"OK"'; then | ||||||||||||||||||||||||||||||||
| echo "Dataverse API is ready." | ||||||||||||||||||||||||||||||||
| echo "Response: $RESPONSE" | ||||||||||||||||||||||||||||||||
| exit 0 | ||||||||||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| echo "Not ready yet. Sleeping ${SLEEP_TIME}s..." | ||||||||||||||||||||||||||||||||
| sleep $SLEEP_TIME | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| # Exponential backoff (10 → 20 → 40 → 60 → 60 → 60) | ||||||||||||||||||||||||||||||||
| if [ $SLEEP_TIME -lt 60 ]; then | ||||||||||||||||||||||||||||||||
| SLEEP_TIME=$((SLEEP_TIME * 2)) | ||||||||||||||||||||||||||||||||
| if [ $SLEEP_TIME -gt 60 ]; then | ||||||||||||||||||||||||||||||||
| SLEEP_TIME=60 | ||||||||||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||||||||||
| done | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| echo "Dataverse failed to report status OK within timeout." | ||||||||||||||||||||||||||||||||
| docker compose -f docker-compose-dev.yml logs | ||||||||||||||||||||||||||||||||
| exit 1 | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| # --------------------------- | ||||||||||||||||||||||||||||||||
| # SETUP PYTHON + SELENIUM | ||||||||||||||||||||||||||||||||
| # --------------------------- | ||||||||||||||||||||||||||||||||
| - name: Setup Python | ||||||||||||||||||||||||||||||||
| uses: actions/setup-python@v5 | ||||||||||||||||||||||||||||||||
| with: | ||||||||||||||||||||||||||||||||
| python-version: '3.11' | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| - name: Install test dependencies | ||||||||||||||||||||||||||||||||
| run: | | ||||||||||||||||||||||||||||||||
| set -euo pipefail | ||||||||||||||||||||||||||||||||
| python -m pip install --upgrade pip | ||||||||||||||||||||||||||||||||
| pip install -r tests/requirements.txt | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
|
Comment on lines
+124
to
+125
|
||||||||||||||||||||||||||||||||
| pip install -r tests/requirements.txt | |
| if [ -f tests/requirements.txt ]; then | |
| echo "Installing test dependencies from tests/requirements.txt" | |
| pip install -r tests/requirements.txt | |
| elif [ -f requirements.txt ]; then | |
| echo "tests/requirements.txt not found; installing from root requirements.txt" | |
| pip install -r requirements.txt | |
| elif [ -f pyproject.toml ]; then | |
| echo "No requirements file found; installing project from pyproject.toml" | |
| pip install . | |
| else | |
| echo "Error: No dependency definition found (tests/requirements.txt, requirements.txt, or pyproject.toml)." >&2 | |
| exit 1 | |
| fi |
Copilot
AI
Mar 3, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The job is named container-test and sets up Python/Selenium, but it never actually runs any tests after bringing the compose stack up (it only verifies Chrome and then tears everything down). Add an explicit test execution step (e.g., run the existing Python unittest suite, or whichever container/API checks this workflow is meant to validate) so the workflow provides real signal.
| - name: Run Selenium tests | |
| run: | | |
| set -euo pipefail | |
| python -m unittest discover -s tests -p "test_*.py" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The workflow stops the Docker daemon and deletes
/var/lib/docker//var/lib/containerd, but it never starts Docker again. As a result,docker version(and laterdocker compose ...) will fail with "Cannot connect to the Docker daemon" on most runners. Start the Docker service again (and optionally wait until it’s active) before running any Docker commands, or remove the stop/wipe step if it’s not required.