-
Notifications
You must be signed in to change notification settings - Fork 0
199 lines (171 loc) · 6.78 KB
/
ci.yml
File metadata and controls
199 lines (171 loc) · 6.78 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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
name: CI
on:
push:
branches: [main]
pull_request:
branches: [main]
workflow_dispatch:
permissions:
contents: read
concurrency:
group: ci-${{ github.ref }}
cancel-in-progress: true
jobs:
test:
name: pytest (${{ matrix.os }} / py${{ matrix.python-version }})
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
# Full matrix on Linux; latest Python only on macOS and Windows to
# keep run time reasonable while still catching platform regressions.
include:
- os: ubuntu-latest
python-version: "3.9"
- os: ubuntu-latest
python-version: "3.10"
- os: ubuntu-latest
python-version: "3.11"
- os: ubuntu-latest
python-version: "3.12"
- os: ubuntu-latest
python-version: "3.13"
- os: macos-latest
python-version: "3.13"
- os: windows-latest
python-version: "3.13"
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
cache: pip
- name: Show git version (used by interop tests)
shell: bash
run: git --version
- name: Install package + test deps
run: |
python -m pip install --upgrade pip
python -m pip install -e ".[test]"
- name: Configure global git identity (some tests shell out to real git)
shell: bash
run: |
git config --global user.name "ci"
git config --global user.email "ci@example.invalid"
git config --global init.defaultBranch main
- name: Run pytest
run: python -m pytest -v --color=yes
- name: Verify `pygit` entry point works
shell: bash
run: |
pygit --version
pygit help | head -5
- name: Verify `git` is NOT installed by default
shell: bash
run: |
scripts_dir=$(python -c "import sysconfig; print(sysconfig.get_path('scripts'))")
if [[ "${{ runner.os }}" == "Windows" ]]; then
[ ! -f "$scripts_dir/git.exe" ] || (echo "unexpected git.exe in $scripts_dir"; exit 1)
else
[ ! -f "$scripts_dir/git" ] || (echo "unexpected git in $scripts_dir"; exit 1)
fi
- name: Verify opt-in via `pygit install-git-shim`
shell: bash
run: |
pygit install-git-shim
scripts_dir=$(python -c "import sysconfig; print(sysconfig.get_path('scripts'))")
if [[ "${{ runner.os }}" == "Windows" ]]; then
shim="$scripts_dir/git.exe"
else
shim="$scripts_dir/git"
fi
"$shim" --version | grep -q "pygit version"
"$shim" help | grep -q "init"
pygit uninstall-git-shim
[ ! -f "$shim" ] || (echo "uninstall left $shim behind"; exit 1)
- name: Verify opt-in via `pip install "pure-python-git[git]"` extra
shell: bash
run: |
# Install the sibling shim package from this repo, then re-install
# pythongit with the [git] extra. The extra references
# pure-python-git-shim, which should now resolve locally.
python -m pip install ./pure-python-git-shim
scripts_dir=$(python -c "import sysconfig; print(sysconfig.get_path('scripts'))")
if [[ "${{ runner.os }}" == "Windows" ]]; then
shim="$scripts_dir/git.exe"
else
shim="$scripts_dir/git"
fi
[ -f "$shim" ] || (echo "git shim not installed by the shim wheel"; exit 1)
"$shim" --version | grep -q "pygit version"
# Clean up so the test step (which does not want this extra installed)
# ends back in the default state.
python -m pip uninstall -y pure-python-git-shim
[ ! -f "$shim" ] || (echo "pip uninstall left $shim behind"; exit 1)
build:
name: build wheel + sdist
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.13"
cache: pip
- name: Install build tools
run: python -m pip install --upgrade build twine
- name: Build pythongit (main package)
run: python -m build
- name: Build pure-python-git-shim (companion package)
run: python -m build pure-python-git-shim --outdir dist
- name: twine check both distributions
run: python -m twine check dist/*
- name: Smoke-install — default (no `git` shim)
run: |
python -m venv /tmp/install-venv
/tmp/install-venv/bin/pip install dist/pure_python_git-*.whl
/tmp/install-venv/bin/pygit --version
# `git` must NOT be installed by default.
[ ! -f /tmp/install-venv/bin/git ] || (echo "unexpected git in /tmp/install-venv/bin"; exit 1)
- name: Smoke-install — `pure-python-git[git]` extra
run: |
python -m venv /tmp/install-extra-venv
# Install both wheels so the extra resolves against local artifacts.
/tmp/install-extra-venv/bin/pip install dist/pure_python_git_shim-*.whl dist/pure_python_git-*.whl
/tmp/install-extra-venv/bin/pygit --version
/tmp/install-extra-venv/bin/git --version | grep -q "pygit version"
/tmp/install-extra-venv/bin/pip uninstall -y pure-python-git-shim
[ ! -f /tmp/install-extra-venv/bin/git ] || (echo "uninstall failed"; exit 1)
- name: Smoke-install — `pygit install-git-shim` post-install path
run: |
python -m venv /tmp/install-postvenv
/tmp/install-postvenv/bin/pip install dist/pure_python_git-*.whl
/tmp/install-postvenv/bin/pygit install-git-shim
/tmp/install-postvenv/bin/git --version | grep -q "pygit version"
/tmp/install-postvenv/bin/pygit uninstall-git-shim
[ ! -f /tmp/install-postvenv/bin/git ] || (echo "uninstall failed"; exit 1)
- name: Upload distribution artifacts
uses: actions/upload-artifact@v4
with:
name: dist
path: dist/
if-no-files-found: error
lint:
name: syntax + import sanity
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.13"
- name: Bytecode-compile every module
run: python -m compileall -q pythongit tests
- name: Import smoke test
run: |
python -c "
from pythongit import cli
from pythongit.cli import _COMMANDS
assert len(_COMMANDS) >= 150, f'expected >=150 commands, got {len(_COMMANDS)}'
print(f'OK: {len(_COMMANDS)} commands registered')
"