Some events ideas #882
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
name: Test building and running dojo | |
on: | |
push: | |
pull_request: | |
schedule: | |
- cron: '42 06 * * *' | |
jobs: | |
smoketest: | |
runs-on: ubuntu-22.04 | |
timeout-minutes: 15 | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: docker/setup-buildx-action@v3 | |
- uses: docker/build-push-action@v5 | |
with: | |
tags: dojo-test | |
load: true | |
no-cache: ${{ github.event_name == 'schedule' }} | |
# cache-from: type=gha | |
# cache-to: type=gha,mode=max | |
- uses: actions/setup-python@v4 | |
with: | |
python-version: '3.10' | |
cache: 'pip' | |
- name: Prepare Firefox | |
uses: browser-actions/setup-firefox@latest | |
- name: Install test dependencies | |
run: pip install pytest pytest-dependency requests selenium | |
- name: Run dojo | |
run: | | |
docker run \ | |
--privileged \ | |
-d \ | |
-v ./dojo-test-data:/opt/pwn.college/data:shared \ | |
-p 2222:22 -p 80:80 -p 443:443 \ | |
--name dojo-test \ | |
dojo-test | |
- name: Wait for services to build and start | |
run: | | |
docker exec dojo-test dojo wait | |
- name: Wait for services to be ready | |
timeout-minutes: 2 | |
run: | | |
docker exec dojo-test dojo compose logs -f & | |
log_pid=$! | |
until [[ "$(docker exec dojo-test docker inspect --format='{{.State.Health.Status}}' ctfd)" == "healthy" ]]; do | |
sleep 1 | |
done | |
kill $log_pid | |
exit 0 | |
- name: Run tests against dojo | |
run: | | |
export MOZ_HEADLESS=1 | |
pytest -vrpP ./test || (docker exec dojo-test docker compose logs && false) |