Skip to content

feat(workflows): design workflow to run dataverse in a container #4

feat(workflows): design workflow to run dataverse in a container

feat(workflows): design workflow to run dataverse in a container #4

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
# ---------------------------
- name: Wait for Dataverse to be ready
run: |
set -euo pipefail
echo "Waiting for http://localhost:8080 ..."
for i in {1..60}; do
if curl -s http://localhost:8080 > /dev/null; then
echo "Dataverse is up."
exit 0
fi
sleep 5
done
echo "Dataverse failed to start in time."
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
# Chrome is preinstalled on ubuntu-latest
- name: Verify Chrome
run: |
google-chrome --version
# ---------------------------
# RUN SELENIUM TESTS
# ---------------------------
- name: Run Selenium test suite
run: |
set -euo pipefail
cd tests
python test_suite.py
# ---------------------------
# COLLECT LOGS IF FAILURE
# ---------------------------
- name: Dump container logs on failure
if: failure()
run: |
docker compose -f docker-compose-dev.yml logs
# ---------------------------
# SHUTDOWN
# ---------------------------
- name: Shutdown containers
if: always()
run: |
docker compose -f docker-compose-dev.yml down -v
- name: Final Docker cleanup
if: always()
run: |
docker system prune -af || true