From 5632dc0208f917357d09241d587e49f4de7bac4b Mon Sep 17 00:00:00 2001 From: "Paul J. Dorn" Date: Fri, 23 Aug 2024 21:19:06 +0200 Subject: [PATCH] CI: test OpenBSD + FreeBSD + illumos in Linux VM --- .github/workflows/foreign.yml | 82 +++++++++++++++++++++++++++++++++++ tests/test_nginx.py | 18 ++++---- 2 files changed, 92 insertions(+), 8 deletions(-) create mode 100644 .github/workflows/foreign.yml diff --git a/.github/workflows/foreign.yml b/.github/workflows/foreign.yml new file mode 100644 index 000000000..db2173624 --- /dev/null +++ b/.github/workflows/foreign.yml @@ -0,0 +1,82 @@ +name: foreign +on: [push, pull_request] +permissions: + # BOLD WARNING: do not add permissions, this workflow executes remote code + contents: read +env: + FORCE_COLOR: 1 +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true +jobs: + freebsd: + name: freebsd + timeout-minutes: 20 + runs-on: ubuntu-latest + strategy: + fail-fast: true + steps: + - uses: actions/checkout@v4 + - uses: vmactions/freebsd-vm@v1 + with: + prepare: pkg install -y nginx python311 py311-pip py311-tox py311-sqlite3 + usesh: true + copyback: false + # not a typo: "openssl --version" != "openssl version" + run: | + uname -a \ + && python3.11 --version \ + && python3.11 -m tox --version \ + && openssl version \ + && pkg info nginx \ + && python3.11 -m tox -e run-module \ + && python3.11 -m tox -e run-entrypoint \ + && python3.11 -m tox -e py + + openbsd: + name: openbsd + timeout-minutes: 20 + runs-on: ubuntu-latest + strategy: + fail-fast: true + steps: + - uses: actions/checkout@v4 + - uses: vmactions/openbsd-vm@v1 + with: + prepare: pkg_add python py3-pip py3-tox py3-sqlite3 nginx + usesh: true + copyback: false + run: | + uname -a \ + && python3 --version \ + && python3 -m tox --version \ + && openssl version \ + && pkg_info nginx \ + && python3 -m tox -e run-module \ + && python3 -m tox -e run-entrypoint \ + && python3 -m tox -e py + + illumos: + name: illumos + timeout-minutes: 20 + runs-on: ubuntu-latest + strategy: + fail-fast: true + steps: + - uses: actions/checkout@v4 + - uses: vmactions/omnios-vm@v1 + with: + prepare: pkg install pip-311 python-311 sqlite-3 nginx + usesh: true + copyback: false + run: | + cat /etc/release \ + && uname -a \ + && python3 --version \ + && openssl version \ + && pkg_info nginx \ + && python3 -m pip install tox \ + && python3 -m tox --version \ + && python3 -m tox -e run-module \ + && python3 -m tox -e run-entrypoint \ + && python3 -m tox -e py diff --git a/tests/test_nginx.py b/tests/test_nginx.py index 69742edb7..70330ca65 100644 --- a/tests/test_nginx.py +++ b/tests/test_nginx.py @@ -12,12 +12,12 @@ import secrets import signal import subprocess +import shutil import sys import time from pathlib import Path from tempfile import TemporaryDirectory from typing import TYPE_CHECKING -from filelock import FileLock import pytest @@ -25,12 +25,14 @@ import http.client from typing import Any, NamedTuple, Self -CMD_OPENSSL = Path("/usr/bin/openssl") -CMD_NGINX = Path("/usr/sbin/nginx") +# test runner may not be system administrator. not needed here, to run nginx +PATH = "/usr/sbin:/usr/local/sbin:"+os.environ.get("PATH", "/usr/local/bin:/usr/bin") +CMD_OPENSSL = shutil.which("openssl", path=PATH) +CMD_NGINX = shutil.which("nginx", path=PATH) pytestmark = pytest.mark.skipif( - not CMD_OPENSSL.is_file() or not CMD_NGINX.is_file(), - reason="need %s and %s" % (CMD_OPENSSL, CMD_NGINX), + CMD_OPENSSL is None or CMD_NGINX is None, + reason="need nginx and openssl binaries", ) STDOUT = 0 @@ -300,9 +302,9 @@ def dummy_ssl_cert(tmp_path_factory): key = base_tmp_dir / "dummy.key" print(crt, key) # generate once, reuse for all tests - with FileLock("%s.lock" % crt): - if not crt.is_file(): - generate_dummy_ssl_cert(crt, key) + # with FileLock("%s.lock" % crt): + if not crt.is_file(): + generate_dummy_ssl_cert(crt, key) return crt, key