-
Notifications
You must be signed in to change notification settings - Fork 3
92 lines (85 loc) · 3.91 KB
/
Copy pathpython-app.yml
File metadata and controls
92 lines (85 loc) · 3.91 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
# This workflow installs Python dependencies and runs the test suite across a broad range of
# Python versions.
#
# * job "build" — modern interpreters (3.8 .. 3.13) via actions/setup-python on ubuntu-latest.
# The legacy-Python compat layer (coshsh_pycompat.py) is INERT here and
# tests/test_pycompat.py is SKIPPED (skipif >= 3.8).
# * job "legacy" — Python 3.6 / 3.7. These cannot be provided by actions/setup-python on modern
# runners (GLIBC mismatch; both interpreters are EOL), so the job runs INSIDE the
# official python:<ver>-slim-bullseye container images. Bullseye ships GLIBC 2.31,
# new enough for actions/checkout@v4 (node20). This is where the compat layer
# actually activates and tests/test_pycompat.py executes instead of being skipped.
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python
name: Python application
on:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]
permissions:
contents: read
jobs:
build:
name: modern (${{ matrix.python-version }})
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13"]
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
git config --global user.email "lausser@yahoo.com"
git config --global user.name "Gerhard Lausser"
python -m pip install --upgrade pip
pip install pytest
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
- name: Test with pytest
run: |
pytest
legacy:
name: legacy (${{ matrix.python-version }})
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ["3.6", "3.7"]
container:
image: python:${{ matrix.python-version }}-slim-bullseye
steps:
- name: Install git
# The python:<ver>-slim-bullseye images ship without git. actions/checkout@v4 tolerates
# that (it falls back to the tarball download API), but the provision step below runs
# `git config`, which then fails with "git: not found" (exit 127). Install it first.
run: |
apt-get update
apt-get install -y --no-install-recommends git
- uses: actions/checkout@v4
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install pytest
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
- name: Provision environment (writable temp, non-root user, git identity)
# Mirrors specs/006-legacy-python-compat/quickstart.md: several tests require writable
# /tmp & /var/tmp and a NON-root run user (test_pid asserts non-writable-dir detection,
# which root bypasses). The job container runs as root by default, so create an
# unprivileged user and hand it the workspace.
run: |
mkdir -p /tmp /var/tmp && chmod 1777 /tmp /var/tmp
useradd -m tester
chown -R tester "$GITHUB_WORKSPACE"
git config --system --add safe.directory "$GITHUB_WORKSPACE"
runuser -u tester -- git config --global user.email "test@coshsh.test"
runuser -u tester -- git config --global user.name "coshsh test"
runuser -u tester -- git config --global --add safe.directory "$GITHUB_WORKSPACE"
- name: Test with pytest (non-root, compat layer active)
# `python -m pytest` prepends the workspace to sys.path so `import coshsh` resolves from the
# source tree; tests/conftest.py activates coshsh_pycompat before collection on <3.8.
run: |
runuser -u tester -- env TMPDIR=/tmp python -m pytest -p no:cacheprovider