blob: 52d260498c6a265203cb9897ac42680280949526 [file]
# SPDX-License-Identifier: MPL-2.0
#
# libpathrs: safe path resolution on Linux
# Copyright (C) 2019-2025 SUSE LLC
# Copyright (C) 2026 Aleksa Sarai <cyphar@cyphar.com>
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at https://mozilla.org/MPL/2.0/.
on:
push:
branches: [ main ]
tags:
- 'v*'
pull_request:
branches: [ main ]
release:
types: [ published ]
schedule:
- cron: '0 0 * * *'
workflow_dispatch:
env:
CARGO_TERM_COLOR: always
PYTHON_DIST: ${{ github.workspace }}/.tmp/python3-pathrs-${{ github.run_id }}-${{ github.run_attempt }}
name: bindings-python
permissions:
contents: read
jobs:
ruff:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- name: install ruff
uses: $/.github/actions/python-deps
with:
name: ruff
- run: ruff check --output-format=github
- run: ruff format --check --diff
mypy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- name: install mypy
uses: $/.github/actions/python-deps
with:
name: mypy
- name: run mypy
working-directory: contrib/bindings/python/pathrs
run: |-
echo "::add-matcher::$GITHUB_WORKSPACE/.github/problem-matchers/mypy.json"
mypy --show-absolute-path .
build-pyproject:
strategy:
fail-fast: false
matrix:
python-version: ["3.10", "3.11", "3.12", "3.13", "3.x"]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
# Build and install libpathrs.so.
- name: install rust toolchain
run: |-
rustup toolchain install --profile minimal --no-self-update stable
rustup default stable
- name: build libpathrs
run: make release
- name: install libpathrs
run: sudo ./install.sh --libdir=/usr/lib
# Set up python venv.
- name: install pypa/build
uses: $/.github/actions/python-deps
with:
python-version: ${{ matrix.python-version }}
name: build
# Build and install our bindings.
- name: build python-pathrs bindings
run: make -C contrib/bindings/python dist
- run: twine check contrib/bindings/python/dist/*
- name: install python-pathrs 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[] | select(.name == "pathrs") | "\(.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-pathrs bindings dist/
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
name: python-${{ matrix.python-version }}-pathrs-dist
path: contrib/bindings/python/dist/
smoke-test:
strategy:
fail-fast: false
matrix:
python-version: ["3.10", "3.11", "3.12", "3.13", "3.x"]
needs:
- build-pyproject
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
# Build and install libpathrs.so.
- name: install rust toolchain
run: |-
rustup toolchain install --profile minimal --no-self-update stable
rustup default 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@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0
with:
python-version: ${{ matrix.python-version }}
# Download the pre-built python dist.
- name: download built python-pathrs
uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
with:
name: python-${{ matrix.python-version }}-pathrs-dist
path: ${{ env.PYTHON_DIST }}
- name: install python-pathrs
run: |-
python3 -m pip install "$PYTHON_DIST"/*.whl
# Run smoke-tests.
- run: make -C examples/python smoke-test
python-complete:
needs:
- ruff
- mypy
- build-pyproject
- smoke-test
runs-on: ubuntu-latest
steps:
- run: echo "Python CI jobs completed successfully."