Check out repo at depth 0 for Python tests, bump Python and PyPI actions (#1713)

The reason for this is that `setuptools-scm` installs a version relative
to the last release tag - if no tag is found, the default version is taken
to be v0.1.0. This was the case in GitHub Actions, where only the PR
branch is checked out.

Also unpins build system requirements in the `pyproject.toml`.

The sdist build system was changed to `build` from `python setup.py sdist`
for forward compatibility - `build` is superior in every way, and the
advertised solution by both cibuildwheel and PyPA itself.

Bump `actions/setup-python` to v5, `pypa/gh-action-pypi-publish` to v1.8.11,
and `docker/setup-qemu-action` to v3.
This commit is contained in:
Nicholas Junge 2023-12-19 15:13:08 +01:00 committed by GitHub
parent c2de526130
commit 9a0422eb23
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 24 additions and 24 deletions

View File

@ -16,16 +16,16 @@ jobs:
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Python - name: Set up Python
uses: actions/setup-python@v4 uses: actions/setup-python@v5
with: with:
python-version: 3.11 python-version: 3.11
cache: 'pip' cache: pip
cache-dependency-path: pyproject.toml cache-dependency-path: pyproject.toml
- name: Install dependencies - name: Install dependencies
run: | run: python -m pip install ".[dev]"
python -m pip install --upgrade pip
pip install ".[dev]"
- name: Cache pre-commit tools - name: Cache pre-commit tools
uses: actions/cache@v3 uses: actions/cache@v3
with: with:
@ -35,5 +35,4 @@ jobs:
${{ env.PRE_COMMIT_HOME }} ${{ env.PRE_COMMIT_HOME }}
key: ${{ runner.os }}-${{ hashFiles('.pre-commit-config.yaml') }}-linter-cache key: ${{ runner.os }}-${{ hashFiles('.pre-commit-config.yaml') }}-linter-cache
- name: Run pre-commit checks - name: Run pre-commit checks
run: | run: pre-commit run --all-files --verbose --show-diff-on-failure
pre-commit run --all-files --verbose --show-diff-on-failure

View File

@ -17,14 +17,14 @@ jobs:
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v4
- name: Set up Python with:
uses: actions/setup-python@v4 fetch-depth: 0
- name: Set up Python 3.11
uses: actions/setup-python@v5
with: with:
python-version: 3.11 python-version: 3.11
- name: Install GBM Python bindings on ${{ matrix.os }} - name: Install GBM Python bindings on ${{ matrix.os }}
run: | run: python -m pip install .
python -m pip install --upgrade pip setuptools wheel
python -m pip install .
- name: Run bindings example on ${{ matrix.os }} - name: Run bindings example on ${{ matrix.os }}
run: run:
python bindings/python/google_benchmark/example.py python bindings/python/google_benchmark/example.py

View File

@ -13,17 +13,16 @@ jobs:
steps: steps:
- name: Check out repo - name: Check out repo
uses: actions/checkout@v4 uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Install Python 3.11 - name: Install Python 3.11
uses: actions/setup-python@v4 uses: actions/setup-python@v5
with: with:
python-version: 3.11 python-version: 3.11
- run: python -m pip install build
- name: Build and check sdist - name: Build sdist
run: | run: python -m build --sdist
python setup.py sdist - uses: actions/upload-artifact@v3
- name: Upload sdist
uses: actions/upload-artifact@v3
with: with:
name: dist name: dist
path: dist/*.tar.gz path: dist/*.tar.gz
@ -38,10 +37,12 @@ jobs:
steps: steps:
- name: Check out Google Benchmark - name: Check out Google Benchmark
uses: actions/checkout@v4 uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up QEMU - name: Set up QEMU
if: runner.os == 'Linux' if: runner.os == 'Linux'
uses: docker/setup-qemu-action@v2 uses: docker/setup-qemu-action@v3
with: with:
platforms: all platforms: all
@ -61,7 +62,7 @@ jobs:
uses: actions/upload-artifact@v3 uses: actions/upload-artifact@v3
with: with:
name: dist name: dist
path: ./wheelhouse/*.whl path: wheelhouse/*.whl
pypi_upload: pypi_upload:
name: Publish google-benchmark wheels to PyPI name: Publish google-benchmark wheels to PyPI
@ -74,4 +75,4 @@ jobs:
with: with:
name: dist name: dist
path: dist path: dist
- uses: pypa/gh-action-pypi-publish@v1.8.10 - uses: pypa/gh-action-pypi-publish@v1.8.11

View File

@ -1,5 +1,5 @@
[build-system] [build-system]
requires = ["setuptools>=64", "setuptools-scm[toml]>=8"] requires = ["setuptools", "setuptools-scm[toml]", "wheel"]
build-backend = "setuptools.build_meta" build-backend = "setuptools.build_meta"
[project] [project]