-
Notifications
You must be signed in to change notification settings - Fork 0
140 lines (133 loc) · 5.13 KB
/
Copy pathtests.yml
File metadata and controls
140 lines (133 loc) · 5.13 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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
name: Tests
on:
push:
pull_request:
permissions:
contents: read
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
validate:
name: Validate (${{ matrix.os }}, Python ${{ matrix.python-version }})
strategy:
fail-fast: false
matrix:
os:
- macos-latest
- ubuntu-latest
- windows-latest
python-version: ["3.10", "3.11", "3.12", "3.13", "3.14"]
runs-on: ${{ matrix.os }}
timeout-minutes: 10
defaults:
run:
shell: bash
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Validate repository baseline
run: ./tests/validate.sh
- name: Set up Python
uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0
with:
python-version: ${{ matrix.python-version }}
- name: Install test dependencies
run: python -m pip install ".[dev,typer]"
- name: Run Python tests
run: python -m pytest
- name: Type-check public contract sample
run: python -m mypy --strict examples/typed_consumer.py
- name: Type-check library
run: python -m mypy --strict lib/python/base_cli
quality:
name: Quality and security gates
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Set up Python
uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0
with:
python-version: "3.13"
- name: Install quality dependencies
run: python -m pip install ".[dev,typer,quality]"
- name: Run formatting and lint checks
run: |
ruff format --check lib/python/base_cli scripts examples tests
ruff check lib/python/base_cli scripts examples tests
- name: Run strict typing and documentation checks
run: |
python -m mypy --strict examples/typed_consumer.py
python -m mypy --strict lib/python/base_cli
python scripts/validate_docs.py
python scripts/benchmark_runtime.py --check
python -m compileall -q examples
- name: Run tests with coverage threshold
run: python -m pytest --cov=base_cli --cov-report=term-missing --cov-fail-under=80
- name: Run static security checks
run: |
bandit -q -r lib/python/base_cli scripts -lll -iii
# The project itself is installed from this checkout and may not be
# published to PyPI yet (for example, while validating a release PR).
# Audit every installed third-party package without asking pip-audit
# to resolve the unpublished project distribution.
python -m pip freeze \
| grep -Eiv '^base-cli([[:space:]]|$)' \
> "$RUNNER_TEMP/base-cli-audit-requirements.txt"
pip-audit --strict -r "$RUNNER_TEMP/base-cli-audit-requirements.txt"
linux-distributions:
name: Validate (${{ matrix.name }})
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include:
- name: Debian 12
image: debian:12-slim
family: debian
- name: Fedora latest
image: fedora:latest
family: fedora
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Run distribution validation in Docker
env:
DISTRO_IMAGE: ${{ matrix.image }}
DISTRO_FAMILY: ${{ matrix.family }}
run: |
docker run --rm \
--volume "$GITHUB_WORKSPACE:/workspace" \
--workdir /workspace \
--env DISTRO_FAMILY \
"$DISTRO_IMAGE" \
sh -lc '
set -eu
if [ "$DISTRO_FAMILY" = debian ]; then
apt-get update
DEBIAN_FRONTEND=noninteractive apt-get install -y bash python3 python3-pip python3-venv
else
dnf install -y python3 python3-pip
fi
./tests/validate.sh
python3 -m venv /tmp/base-cli-venv
/tmp/base-cli-venv/bin/python -m pip install ".[dev,typer]"
/tmp/base-cli-venv/bin/python -m pytest
/tmp/base-cli-venv/bin/python -c "import base_cli; print(base_cli.__version__)"
'
wsl:
name: Validate (WSL)
runs-on: windows-latest
timeout-minutes: 15
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Validate repository baseline inside WSL
shell: pwsh
run: |
$distros = (wsl --list --quiet 2>$null | Out-String)
if ($distros -notmatch "Ubuntu") {
wsl --install --distribution Ubuntu --no-launch
}
$drive = $env:GITHUB_WORKSPACE.Substring(0, 1).ToLowerInvariant()
$path = $env:GITHUB_WORKSPACE.Substring(2).Replace('\', '/')
$linuxWorkspace = "/mnt/$drive$path"
wsl --distribution Ubuntu --user root -- bash -lc "set -eu; cd '$linuxWorkspace'; sed -i 's/\r$//' tests/validate.sh; bash tests/validate.sh; python3 --version"