-
Notifications
You must be signed in to change notification settings - Fork 0
260 lines (223 loc) · 9.04 KB
/
Copy pathci.yml
File metadata and controls
260 lines (223 loc) · 9.04 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
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
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)
git-254-parity:
name: C Git 2.54.0 parity
runs-on: ubuntu-latest
env:
GIT_254_URL: https://github.com/git/git/archive/refs/tags/v2.54.0.tar.gz
GIT_254_SHA256: 7b01a23c44c9ccfca2e3ad9daf8cbdd4d4caaaa6b5181e77e16e60c6ae5f772a
GIT_254_PREFIX: ${{ github.workspace }}/.cache/git-2.54.0
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Python 3.13
uses: actions/setup-python@v5
with:
python-version: "3.13"
cache: pip
- name: Cache C Git 2.54.0 build
id: cache-git-254
uses: actions/cache@v4
with:
path: .cache/git-2.54.0
key: git-2.54.0-ubuntu-${{ env.GIT_254_SHA256 }}
- name: Install C Git build dependencies
if: steps.cache-git-254.outputs.cache-hit != 'true'
run: |
sudo apt-get update
sudo apt-get install -y build-essential gettext libcurl4-gnutls-dev libexpat1-dev libssl-dev zlib1g-dev
- name: Build C Git 2.54.0 oracle
if: steps.cache-git-254.outputs.cache-hit != 'true'
shell: bash
run: |
curl -L "$GIT_254_URL" -o /tmp/git-2.54.0.tar.gz
echo "$GIT_254_SHA256 /tmp/git-2.54.0.tar.gz" | sha256sum -c -
rm -rf /tmp/git-2.54.0-src
mkdir -p /tmp/git-2.54.0-src "$GIT_254_PREFIX"
tar -xzf /tmp/git-2.54.0.tar.gz -C /tmp/git-2.54.0-src --strip-components=1
make -C /tmp/git-2.54.0-src -j"$(nproc)" prefix="$GIT_254_PREFIX" NO_TCLTK=YesPlease all install
- name: Verify oracle version
run: |
"$GIT_254_PREFIX/bin/git" --version | grep -q "git version 2.54.0"
- name: Install package + test deps
run: |
python -m pip install --upgrade pip
python -m pip install -e ".[test]"
- name: Configure oracle identity
run: |
"$GIT_254_PREFIX/bin/git" config --global user.name "ci"
"$GIT_254_PREFIX/bin/git" config --global user.email "ci@example.invalid"
"$GIT_254_PREFIX/bin/git" config --global init.defaultBranch main
- name: Run required parity tests
env:
PYGIT_PARITY_GIT: ${{ env.GIT_254_PREFIX }}/bin/git
run: python -m pytest -v --color=yes tests/git_parity --require-git-254-oracle
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')
"