Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refresh test workflow and associated config, accept podmain test failure for now #485

Merged
merged 3 commits into from
May 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
132 changes: 132 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
# This is a GitHub workflow defining a set of jobs with a set of steps.
# ref: https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions
#
name: Tests

on:
pull_request:
paths-ignore:
- "docs/**"
- "**.md"
- ".github/workflows/*.yaml"
- "!.github/workflows/test.yaml"
push:
paths-ignore:
- "docs/**"
- "**.md"
- ".github/workflows/*.yaml"
- "!.github/workflows/test.yaml"
branches-ignore:
- "dependabot/**"
- "pre-commit-ci-update-config"
tags: ["**"]
workflow_dispatch:

jobs:
test:
runs-on: ubuntu-22.04
timeout-minutes: 10

strategy:
fail-fast: false
matrix:
include:
- python-version: "3.7"
pip-install-spec: "jupyterhub==1.0.0 sqlalchemy==1.*"
- python-version: "3.8"
pip-install-spec: "jupyterhub==2.* sqlalchemy==1.*"
- python-version: "3.9"
pip-install-spec: "jupyterhub==3.*"
- python-version: "3.11"
pip-install-spec: "jupyterhub==4.*"
- python-version: "3.11"
pip-install-spec: "jupyterhub==4.*"
test-variation: internal-ssl
- python-version: "3.11"
pip-install-spec: "jupyterhub==4.*"
test-variation: podman

steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- uses: actions/setup-node@v3
with:
node-version: "18"
minrk marked this conversation as resolved.
Show resolved Hide resolved

- name: setup docker swarm
run: docker swarm init

- name: Install Python dependencies
run: |
pip install ${{ matrix.pip-install-spec }}
pip install -e "." -r dev-requirements.txt
minrk marked this conversation as resolved.
Show resolved Hide resolved

- name: List Python dependencies
run: |
pip freeze
minrk marked this conversation as resolved.
Show resolved Hide resolved

- name: Install Node dependencies
run: |
npm install -g configurable-http-proxy

- name: Run tests
if: matrix.test-variation == ''
run: |
pytest tests --cov=dockerspawner

- name: Run examples/internal-ssl tests
if: matrix.test-variation == 'internal-ssl'
# FIXME: --cov=dockerspawner is omitted as the tested code lives inside
# the built dockerspawner image, so --cov=dockerspawner
# referencing the local source code doesn't get us test coverage.
#
run: |
pytest examples/internal-ssl --capture=no

- name: Run podman tests
continue-on-error: true
if: matrix.test-variation == 'podman'
# Podman's system service is started as a user managed process
# (user-mode / rootless), and the docker-api provided by podman is used
# by setting DOCKER_HOST to the podman provided docker-api.
#
# ref: https://docs.podman.io/en/latest/markdown/podman-system-service.1.html
# ref: https://docker-py.readthedocs.io/en/stable/client.html#envvar-DOCKER_HOST
#
run: |
# Default is unix://$XDG_RUNTIME_DIR/podman/podman.sock but XDG_RUNTIME_DIR may not be set
export DOCKER_HOST=unix://$HOME/podman.sock

podman system service --time=0 $DOCKER_HOST &

for n in $(seq 1 10); do
if ! docker version &>/dev/null; then
echo "podman system service - starting..."
sleep 1
else
echo "podman system service - started!"
echo ""
break
fi
done

# FIXME: we run into an error described in
# https://github.com/containers/podman/blob/main/troubleshooting.md#26-running-containers-with-resource-limits-fails-with-a-permissions-error
#
# This is a check for permissions of relevance, where we
# conclude we get "memory pids" on ubuntu-22.04. This confirms
# that we need additional permissions for the podman system
# service we have started as the current user, lacking such
# permissions.
#
# If this is resolved, also remove the continue-on-error
# section above.
#
cat "/sys/fs/cgroup/user.slice/user-$(id -u).slice/user@$(id -u).service/cgroup.controllers"

pytest tests/test_dockerspawner.py --cov=dockerspawner

# GitHub action reference: https://github.com/codecov/codecov-action
- uses: codecov/codecov-action@v3
minrk marked this conversation as resolved.
Show resolved Hide resolved
117 changes: 0 additions & 117 deletions .github/workflows/test.yml

This file was deleted.

2 changes: 0 additions & 2 deletions dev-requirements.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
codecov
netifaces
notebook<7
pyflakes
pytest>=3.6
pytest-asyncio
pytest-cov
15 changes: 11 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ profile = "black"
[tool.black]
skip-string-normalization = true
target_version = [
"py36",
"py37",
"py38",
"py39",
Expand All @@ -27,7 +26,15 @@ target_version = [
# ref: https://docs.pytest.org/en/stable/
#
[tool.pytest.ini_options]
addopts = "--verbose --color=yes --durations=10"
addopts = "--verbose --color=yes --durations=10 --maxfail=1"
asyncio_mode = "auto"
# Ignore thousands of tests in dependencies installed in a virtual environment
norecursedirs = "lib lib64"
testpaths = ["tests"]
# These markers are registered to avoid warnings triggered by importing from
# jupyterhub.tests.test_api.
markers = [
"role",
"user",
"slow",
"group",
"services",
]
3 changes: 2 additions & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,9 @@ def docker():
c.remove()
try:
services = d.services.list()
except APIError:
except (APIError, TypeError):
# e.g. services not available
# podman gives TypeError
return
else:
for s in services:
Expand Down