If build fails, don't want to test the pwncollege/dojo image, so use … #12
Workflow file for this run
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 runnint dojo | |
on: push | |
jobs: | |
smoketest: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Install test dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install pytest | |
- name: Set up Docker Buildx | |
id: buildx | |
# Use the action from the master, as we've seen some inconsistencies with @v1 | |
# Issue: https://github.com/docker/build-push-action/issues/286 | |
uses: docker/setup-buildx-action@master | |
# It only worked for us with this option on 🤷♂️ | |
with: | |
install: true | |
- name: Cache Docker layers | |
uses: actions/cache@v2 | |
with: | |
path: /tmp/.buildx-cache | |
# Key is named differently to avoid collision | |
key: ${{ runner.os }}-multi-buildx-${{ github.sha }} | |
restore-keys: | | |
${{ runner.os }}-multi-buildx | |
- name: Build container | |
uses: docker/build-push-action@v2 | |
with: | |
context: . | |
builder: ${{ steps.buildx.outputs.name }} | |
file: Dockerfile | |
# Set the desired build target here | |
push: false | |
load: true # we want this tag to be loaded to docker images | |
tags: dojo-test | |
cache-from: type=local,src=/tmp/.buildx-cache | |
# Note the mode=max here | |
# More: https://github.com/moby/buildkit#--export-cache-options | |
# And: https://github.com/docker/buildx#--cache-tonametypetypekeyvalue | |
cache-to: type=local,mode=max,dest=/tmp/.buildx-cache-new | |
- name: Run Container | |
run: "docker run --privileged -d -v $PWD:/opt/pwn.college:shared -p 2222:22 -p 80:80 -p 443:443 --name dojo dojo-test" | |
- name: Wait for container to be ready | |
run: | | |
until docker exec dojo dojo is-setup-finished | |
do | |
sleep 5 | |
docker exec dojo journalctl -u pwn.college | tail -n 5 | |
done | |
- name: Run tests against container | |
run: | | |
pytest ./test || docker exec dojo journalctl -u pwn.college | |