Stop container before removing it forcefully #630
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: CI | |
on: | |
push: | |
branches: | |
- "main" | |
pull_request: | |
jobs: | |
format: | |
name: Ensure code is properly formatted | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-python@v5 | |
with: | |
python-version: '3.x' | |
- uses: actions/cache@v4 | |
with: | |
path: ~/.cache/pypoetry/virtualenvs | |
key: poetry-${{ hashFiles('poetry.lock') }} | |
- run: | | |
pip install --upgrade poetry nox nox-poetry | |
nox -s format -- --check | |
generate_requirements: | |
name: Generate requirements.txt for Python 3.6 CI | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-python@v5 | |
with: | |
python-version: '3.x' | |
- uses: actions/cache@v4 | |
with: | |
path: ~/.cache/pypoetry/virtualenvs | |
key: poetry-${{ hashFiles('poetry.lock') }} | |
- run: | | |
pipx install poetry | |
poetry export --with=dev --without-hashes > requirements.txt | |
- uses: actions/upload-artifact@v4 | |
with: | |
name: requirements | |
path: requirements.txt | |
if-no-files-found: error | |
ci_36: | |
name: Run the integration tests for Python 3.6 | |
runs-on: ubuntu-20.04 | |
needs: generate_requirements | |
strategy: | |
fail-fast: false | |
matrix: | |
container_runtime: ["podman", "docker"] | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-python@v5 | |
with: | |
python-version: 3.6 | |
- uses: actions/download-artifact@v4 | |
with: | |
name: requirements | |
path: . | |
- run: pip install -r test-requirements.txt | |
- run: | | |
export CUR_USER="$(whoami)" | |
sudo loginctl enable-linger ${CUR_USER} | |
- run: | | |
mkdir ./tmp/ | |
chmod 1777 ./tmp | |
export TMPDIR="$(pwd)/tmp" | |
# duplication of noxfile.py because we can't use that one with python 3.6 :-/ | |
coverage run -m pytest -vv tests -p pytest_container -x -n auto --reruns 3 --pytest-container-log-level DEBUG | |
coverage run -m pytest -vv tests -p pytest_container -x --reruns 3 --pytest-container-log-level DEBUG | |
coverage combine | |
coverage report -m | |
coverage xml | |
- name: verify that no stray containers are left | |
run: | | |
[[ $(${{ matrix.container_runtime }} ps -aq|wc -l) = "0" ]] | |
- name: verify that no stray volumes are left | |
run: | | |
[[ $(${{ matrix.container_runtime }} volume ls -q|wc -l) = "0" ]] | |
- name: Upload coverage to Codecov | |
uses: codecov/codecov-action@v4 | |
with: | |
token: ${{ secrets.CODECOV_TOKEN }} | |
ci: | |
name: Run the integration tests | |
runs-on: "ubuntu-latest" | |
strategy: | |
fail-fast: false | |
matrix: | |
python_version: ["3.7", "3.8", "3.9", "3.10", "3.11", "3.12"] | |
container_runtime: ["podman", "docker"] | |
update_runtime: [ true, false ] | |
without_buildah: [ false ] | |
exclude: | |
- container_runtime: "docker" | |
python_version: "3.7" | |
update_runtime: true | |
without_buildah: false | |
- container_runtime: "docker" | |
python_version: "3.8" | |
update_runtime: true | |
without_buildah: false | |
- container_runtime: "docker" | |
python_version: "3.9" | |
update_runtime: true | |
without_buildah: false | |
- container_runtime: "docker" | |
python_version: "3.10" | |
update_runtime: true | |
without_buildah: false | |
- container_runtime: "docker" | |
python_version: "3.11" | |
update_runtime: true | |
without_buildah: false | |
- container_runtime: "docker" | |
python_version: "3.12" | |
update_runtime: true | |
without_buildah: false | |
include: | |
- python_version: "3.12" | |
container_runtime: "podman" | |
update_runtime: true | |
without_buildah: true | |
- python_version: "3.12" | |
container_runtime: "podman" | |
update_runtime: false | |
without_buildah: true | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-python@v5 | |
with: | |
python-version: ${{ matrix.python_version }} | |
- uses: actions/cache@v4 | |
with: | |
path: ~/.nox | |
key: nox-${{ matrix.python_version }}-${{ hashFiles('poetry.lock') }} | |
- run: pip install --upgrade nox poetry nox-poetry | |
- name: update the container runtime | |
if: ${{ matrix.update_runtime }} | |
run: | | |
sudo mkdir -p /etc/apt/keyrings | |
curl -fsSL https://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/unstable/xUbuntu_$(lsb_release -rs)/Release.key \ | |
| gpg --dearmor \ | |
| sudo tee /etc/apt/keyrings/devel_kubic_libcontainers_unstable.gpg > /dev/null | |
echo \ | |
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/devel_kubic_libcontainers_unstable.gpg]\ | |
https://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/unstable/xUbuntu_$(lsb_release -rs)/ /" \ | |
| sudo tee /etc/apt/sources.list.d/devel:kubic:libcontainers:unstable.list > /dev/null | |
sudo apt-get update -qq | |
sudo apt-get -qq -y install podman buildah | |
- name: remove buildah | |
if: ${{ matrix.without_buildah }} | |
run: | | |
sudo apt-get remove buildah | |
! command -v buildah | |
- run: | | |
export CUR_USER="$(whoami)" | |
sudo loginctl enable-linger ${CUR_USER} | |
- run: | | |
mkdir ./tmp/ | |
chmod 1777 ./tmp | |
export TMPDIR="$(pwd)/tmp" | |
export PULL_ALWAYS=0 | |
nox -s "test-${{ matrix.python_version }}(${{ matrix.container_runtime }})" -- -x -n auto --reruns 3 --pytest-container-log-level DEBUG | |
export PULL_ALWAYS=1 | |
nox -s "test-${{ matrix.python_version }}(${{ matrix.container_runtime }})" -- -x -n auto --reruns 3 --pytest-container-log-level DEBUG | |
nox -s "test-${{ matrix.python_version }}(${{ matrix.container_runtime }})" -- -x --reruns 3 --pytest-container-log-level DEBUG | |
nox -s coverage | |
- name: verify that no stray containers are left | |
run: | | |
[[ $(podman ps -aq|wc -l) = '0' ]] || (podman ps -aq|xargs podman inspect; exit 1) | |
- name: verify that no stray volumes are left | |
run: | | |
[[ $(${{ matrix.container_runtime }} volume ls -q|wc -l) = "0" ]] | |
- name: Upload coverage to Codecov | |
uses: codecov/codecov-action@v4 | |
with: | |
token: ${{ secrets.CODECOV_TOKEN }} | |
build: | |
name: Build the package | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-python@v5 | |
with: | |
python-version: "3.x" | |
- uses: actions/cache@v4 | |
with: | |
path: ~/.cache/pypoetry/virtualenvs | |
key: poetry-${{ hashFiles('poetry.lock') }} | |
- name: Run the build | |
run: | | |
pipx install poetry | |
poetry install | |
poetry build | |
- uses: actions/upload-artifact@v4 | |
with: | |
name: wheel | |
path: dist/pytest_container*whl | |
if-no-files-found: error | |
install: | |
name: Install the package | |
runs-on: ${{ matrix.os_version }} | |
needs: build | |
strategy: | |
fail-fast: false | |
matrix: | |
os_version: ["ubuntu-latest"] | |
python_version: ["3.7", "3.8", "3.9", "3.10", "3.11"] | |
include: | |
- os_version: "ubuntu-20.04" | |
python_version: "3.6" | |
steps: | |
- uses: actions/setup-python@v5 | |
with: | |
python-version: ${{ matrix.python_version }} | |
- uses: actions/download-artifact@v4 | |
with: | |
name: wheel | |
path: dist | |
- name: install the wheel | |
run: pip install --user dist/pytest_container*whl | |
- name: run a smoke test that the package has been installed | |
run: python -c "import pytest_container; print (pytest_container.__name__)" | |
documentation: | |
name: Build the documentation | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-python@v5 | |
with: | |
python-version: '3.x' | |
- uses: actions/cache@v4 | |
with: | |
path: ~/.nox | |
key: nox-${{ hashFiles('poetry.lock') }} | |
- run: pip install --upgrade nox poetry nox-poetry | |
- run: nox -s doc | |
- name: upload the build directory | |
uses: actions/upload-artifact@v4 | |
with: | |
name: build | |
path: ./build/html | |
deploy: | |
name: deploy to the gh-pages branch | |
runs-on: ubuntu-latest | |
needs: documentation | |
if: github.ref == 'refs/heads/main' | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/download-artifact@v4 | |
with: | |
name: build | |
path: ./build | |
- run: touch ./build/.nojekyll | |
- name: deploy to github pages | |
uses: JamesIves/github-pages-deploy-action@v4 | |
with: | |
branch: gh-pages | |
folder: build | |
lint: | |
name: Lint the source code | |
runs-on: ubuntu-latest | |
needs: build | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-python@v5 | |
with: | |
# FIXME: temporary fix to python 3.11 to avoid a: | |
# AttributeError: module 'pkgutil' has no attribute 'ImpImporter'. Did you mean: 'zipimporter'? | |
# when launching pylint with python 3.12 | |
python-version: '3.11' | |
- uses: actions/cache@v4 | |
with: | |
path: ~/.nox | |
key: nox-${{ hashFiles('poetry.lock') }} | |
- run: pip install --upgrade nox poetry nox-poetry | |
# grab the previously built wheel for checking with twine | |
- uses: actions/download-artifact@v4 | |
with: | |
name: wheel | |
path: dist | |
- run: nox -s lint |