Skip to content

python bindings: add type information and minor fixups #3

python bindings: add type information and minor fixups

python bindings: add type information and minor fixups #3

Workflow file for this run

# libpathrs: safe path resolution on Linux
# Copyright (C) 2019-2024 Aleksa Sarai <[email protected]>
# Copyright (C) 2019-2024 SUSE LLC
#
# This program is free software: you can redistribute it and/or modify it under
# the terms of the GNU Lesser General Public License as published by the Free
# Software Foundation, either version 3 of the License, or (at your option) any
# later version.
#
# This program is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE. See the GNU General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License along
# with this program. If not, see <https://www.gnu.org/licenses/>.
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
release:
types: [ published ]
schedule:
- cron: '0 0 * * *'
name: bindings-ci
jobs:
smoke-test:
strategy:
fail-fast: false
matrix:
python-version: ["3.8", "3.10", "3.12"]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
# Build and install libpathrs.so.
- uses: dtolnay/rust-toolchain@stable
- name: build libpathrs
run: make release
- name: install libpathrs
run: sudo ./install.sh --libdir=/usr/lib
# Set up python venv.
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: install pypa/build
run: >-
python3 -m pip install --user build
# Check mypy.
- name: mypy check
run: >-
python3 -m pip install --user mypy types-toml types-cffi;
mypy --install-types contrib/bindings/python/pathrs
# Build and install our bindings.
- name: build python-libpathrs bindings
run: make -C contrib/bindings/python dist
- name: install python-libpathrs bindings
run: make -C contrib/bindings/python install
# Verify that the crate and python bindings have the same version.
# TODO: Move this to a "make check" we can run locally as well.
- name: check crate and python binding versions match
run: |
CRATE_VERSION="$(cargo metadata --no-deps --format-version=1 | jq -rM '.packages[] | "\(.name)-\(.version)"')"
PY_VERSION="$(python3 -c 'import importlib.metadata; print("pathrs-" + importlib.metadata.version("pathrs"))')"
echo "rust crate version: $CRATE_VERSION";
echo "python module version: $PY_VERSION";
[[ "$CRATE_VERSION" == "$PY_VERSION" ]] || exit 1
# Include the dist/ in our artefacts.
- name: upload python-libpathrs bindings dist/
uses: actions/upload-artifact@v4
with:
name: python-${{ matrix.python-version }}-libpathrs-dist
path: contrib/bindings/python/dist/
# Run smoke-tests.
- run: make -C examples/python smoke-test