|  | 
|  | 1 | +export runtest := ''' | 
|  | 2 | +  python3 -mvenv --system-site-packages /mnt/venv | 
|  | 3 | +  /mnt/venv/bin/pip install --upgrade wheel | 
|  | 4 | +  /mnt/venv/bin/pip install --upgrade pip | 
|  | 5 | +  /mnt/venv/bin/pip install "/mnt/app[test]" | 
|  | 6 | +  cd /mnt/app | 
|  | 7 | +  /mnt/venv/bin/python -munittest | 
|  | 8 | +''' | 
|  | 9 | + | 
|  | 10 | +yum-setup := ''' | 
|  | 11 | +  yum update -y | 
|  | 12 | +  yum install -y python3 sqlite3 python3-pip python3-venv | 
|  | 13 | +''' | 
|  | 14 | + | 
|  | 15 | +dnf-setup := ''' | 
|  | 16 | +  dnf update -y | 
|  | 17 | +  dnf install -y python3 sqlite python3-pip | 
|  | 18 | +''' | 
|  | 19 | + | 
|  | 20 | +apt-setup := ''' | 
|  | 21 | +  apt update | 
|  | 22 | +  apt upgrade -y | 
|  | 23 | +  apt install -y python3 sqlite3 python3-pip python3-venv | 
|  | 24 | +''' | 
|  | 25 | + | 
|  | 26 | +apk-setup := ''' | 
|  | 27 | +  apk update | 
|  | 28 | +  apk upgrade | 
|  | 29 | +  apk add python3 sqlite | 
|  | 30 | +''' | 
|  | 31 | + | 
|  | 32 | +_list: | 
|  | 33 | +  @just --list | 
|  | 34 | + | 
|  | 35 | +# Run all tests | 
|  | 36 | +test: python-tests debian-tests ubuntu-tests fedora-tests rhel-tests alpine-tests | 
|  | 37 | + | 
|  | 38 | +# Run a test with a given setup in the given container | 
|  | 39 | +_run-test $container $setup="": | 
|  | 40 | +  #!/bin/sh | 
|  | 41 | +  set -euxf | 
|  | 42 | +   | 
|  | 43 | +  podman container run \ | 
|  | 44 | +    --rm \ | 
|  | 45 | +    -e PYTHONPATH=/mnt/app/src \ | 
|  | 46 | +    --mount type=volume,destination=/mnt/venv \ | 
|  | 47 | +    --mount type=bind,source=.,destination=/mnt/app,ro=true \ | 
|  | 48 | +    --security-opt label=disable \ | 
|  | 49 | +    "docker.io/$container" \ | 
|  | 50 | +    /bin/sh -c " | 
|  | 51 | +      set -euxf | 
|  | 52 | +
 | 
|  | 53 | +      $setup | 
|  | 54 | +      $runtest | 
|  | 55 | +    " | 
|  | 56 | + | 
|  | 57 | +# Test a particular python version | 
|  | 58 | +test-python version="latest": (_run-test ("python:" + version)) | 
|  | 59 | + | 
|  | 60 | +# Test all supported python versions | 
|  | 61 | +python-tests: (test-python "3.6") (test-python "3.7") (test-python "3.8") (test-python "3.9") (test-python "3.10") (test-python "3.11") (test-python "3.12") | 
|  | 62 | + | 
|  | 63 | +# Test a particular alpine version | 
|  | 64 | +test-alpine version="latest": (_run-test ("alpine:" + version) apk-setup) | 
|  | 65 | + | 
|  | 66 | +# Test all supported alpine versions | 
|  | 67 | +alpine-tests: (test-alpine "3.17") (test-alpine "3.18") (test-alpine "3.19") (test-alpine "3.20") | 
|  | 68 | + | 
|  | 69 | +_test-apt image="debian:latest": (_run-test image apt-setup) | 
|  | 70 | + | 
|  | 71 | +# Test a particular debian version | 
|  | 72 | +test-debian version="latest": (_test-apt ("debian:" + version)) | 
|  | 73 | + | 
|  | 74 | +# Test a particular ubuntu version | 
|  | 75 | +test-ubuntu version="latest": (_test-apt ("ubuntu:" + version)) | 
|  | 76 | + | 
|  | 77 | +# Test all supported debian versions | 
|  | 78 | +debian-tests: (test-debian "buster") (test-debian "bullseye") (test-debian "bookworm") | 
|  | 79 | + | 
|  | 80 | +# Test all supported ubuntu versions | 
|  | 81 | +ubuntu-tests: (test-ubuntu "18.04") (test-ubuntu "20.04") (test-ubuntu "22.04") (test-ubuntu "24.04") | 
|  | 82 | + | 
|  | 83 | +_test-dnf image="fedora:latest": (_run-test image dnf-setup) | 
|  | 84 | + | 
|  | 85 | +# Test a particular fedora version | 
|  | 86 | +test-fedora version="latest": (_test-dnf ("fedora:" + version)) | 
|  | 87 | + | 
|  | 88 | +# Test all supported fedora versions | 
|  | 89 | +fedora-tests: (test-fedora "38") (test-fedora "39") (test-fedora "40") | 
|  | 90 | + | 
|  | 91 | +# Test a particular RHEL version | 
|  | 92 | +test-rhel version="ubi9": (_test-dnf ("redhat/" + version)) | 
|  | 93 | + | 
|  | 94 | +# Test all supported RHEL versions | 
|  | 95 | +rhel-tests: (test-rhel "ubi8") (test-rhel "ubi9") | 
0 commit comments