Enforce Git 2.54 parity registry #27
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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') | |
| " |