diff options
author | 2021-12-27 16:56:11 -0800 | |
---|---|---|
committer | 2021-12-27 16:56:11 -0800 | |
commit | b02102b59aad2396ae651792ab5029262f819337 (patch) | |
tree | 1f93cc17897b6965bd17bd69a18de451a9b43a64 | |
parent | CI: fix pre-commit logs step condition (diff) |
CI: clean up Docker stuff in self-hosted runner
Use docker-compose run instead of docker-compose up. This is more
appropriate since the container is only needed for one command. The
latter was actually starting the whole snekbox server. Furthermore,
the former has the --rm option to remove the container when the command
finishes.
As an extra precaution, use docker-compose down in the self-hosted
runner to also remove images, volumes, networks, and any other
containers that were somehow missed. Removing images will also prevent
the disk usage from building up. This is not necessary for the GH-hosted
runner since a new VM is used for each run.
-rw-r--r-- | .github/workflows/test.yaml | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 2476e55..350142d 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -30,11 +30,6 @@ jobs: # Needed for the Docker Compose file. - name: Checkout code uses: actions/checkout@v2 - - - name: Start container - run: | - export IMAGE_SUFFIX='-venv:${{ inputs.tag }}' - docker-compose up --no-build -d # endregion # Memory limit tests would fail if this isn't disabled. @@ -45,9 +40,12 @@ jobs: # Suffix the generated coverage datafile with the name of the runner's OS. - name: Run tests id: run_tests - run: >- - docker exec -e COVERAGE_DATAFILE=.coverage.${{ matrix.os }} snekbox_dev /bin/bash -c - 'coverage run -m unittest' + run: | + export IMAGE_SUFFIX='-venv:${{ inputs.tag }}' + docker-compose run \ + --rm -T -e COVERAGE_DATAFILE=.coverage.${{ matrix.os }} \ + snekbox \ + coverage run -m unittest # Upload it so the coverage from all matrix jobs can be combined later. - name: Upload coverage data @@ -57,6 +55,14 @@ jobs: path: .coverage.* retention-days: 1 + # Self-hosted runner needs containers, images, networks, volumes, etc. + # removed because they persist across runs and may interfere. + - name: Docker cleanup + if: matrix.os == 'self-hosted' && always() + run: | + export IMAGE_SUFFIX='-venv:${{ inputs.tag }}' + docker-compose down --rmi all --remove-orphans -v -t 0 + report: name: Combine and report coverage data runs-on: ubuntu-20.04 |