Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions .github/scripts/ci_check_wheel.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# A Powershell port of `ci_check_wheel.sh`. Refer to that script instead.

# Any change made here should be made in `ci_check_wheel.sh` too.

param (
[Parameter(Mandatory = $true)]
[string]$PYTHON_VERSION,

[Parameter(Mandatory = $true)]
[string]$KEY,

[string]$EXTRA
)

# Equivalent to `set -e`
$ErrorActionPreference = "Stop"

if (Test-Path ".venv") {
Remove-Item -Recurse -Force ".venv"
}

# When $EXTRA is empty powershell passes the argument as an empty argument to
# uv, so we need to explicitly check the argument and only pass it if it is not
# empty to avoid uv from erroring
if ($EXTRA) {
uv venv --no-project .venv -p $PYTHON_VERSION $EXTRA
} else {
uv venv --no-project .venv -p $PYTHON_VERSION
}

uv run --no-sync python --version

$WHEEL = $(Get-ChildItem -Path .\dist\ -Recurse -Filter "mapfile_parser-*-abi3-*")
if ([string]::IsNullOrEmpty($WHEEL)) {
Write-Host "Wheel not found"
exit 1
}
uv pip install --no-cache --no-config $WHEEL

uv run --no-sync python -c "import mapfile_parser; print(mapfile_parser.__version__)"
38 changes: 38 additions & 0 deletions .github/scripts/ci_check_wheel.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# This script checks a given Python wheel inside the `dist` is installable in a
# given Python version.
#
# It recieves the following arguments:
# - The python version to check, it must be compatible with uv.
# - A key value to allow searching for the wheel in the `dist` folder. Only a
# single wheel in the folder must contain this value in its name.
# Recommended values: abi3, cp314t, pypy39 and similar values.
# - (OPTIONAL) A single aditional flag to pass to `uv venv`.
# Usually `--managed-python`.

# Any change made here should be made in `ci_check_wheel.ps1` too.

PYTHON_VERSION=$1
KEY=$2
EXTRA=$3

# Exit with an error value if any command produces an error.
set -e

# We make a venv with the Python version we were told to.
rm -rf .venv
uv venv --no-project -p $PYTHON_VERSION $EXTRA
# Allows us to check we are actually using the requested Python version.
# --no-sync avoids building the wheel from source
uv run --no-sync python --version

# We install the wheel by looking it up in the dist folder.
# We need to do a `find` command here because we don't know the exact name of
# the wheel (it can be affected by package version, arch, python version, etc.).
WHEEL=$(find ./dist/ -name "mapfile_parser-*-$KEY*")
if [ -z "$WHEEL" ]; then
echo "Wheel not found"
exit 1
fi
uv pip install --no-cache --no-config "$WHEEL"
# Check something basic to make sure it was installed correctly.
uv run --no-sync python -c "import mapfile_parser; print(mapfile_parser.__version__)"
82 changes: 45 additions & 37 deletions .github/workflows/linting.yml
Original file line number Diff line number Diff line change
@@ -1,79 +1,87 @@
name: Linting
name: Python linting

# Build on every branch push, tag push, and pull request change:
on: [push, pull_request]

jobs:
mypy:
name: mypy
runs-on: ubuntu-latest
runs-on: ubuntu-22.04
strategy:
fail-fast: false
matrix:
py_version:
- '3.8'

steps:
- name: Checkout reposistory
uses: actions/checkout@main

- name: Set up Python 3.9
- name: Set up Python ${{ matrix.py_version }}
uses: actions/setup-python@main
with:
python-version: 3.9
python-version: ${{ matrix.py_version }}

- name: Install uv
uses: astral-sh/setup-uv@v7

# Setup venv and install dependencies without building the project from source.
- name: Install Dependencies
run: |
python3 -m pip install -r requirements.txt
python3 -m pip install -U maturin
python3 -m pip install -U mypy
uv venv --no-project --python ${{ matrix.py_version }}
uv sync --no-install-project
uv pip install -U mypy

- name: mypy
run: mypy --show-column-numbers --hide-error-context .
run: |
uv run --no-sync mypy --show-column-numbers --hide-error-context .

ruff:
runs-on: ubuntu-latest
name: ruff
runs-on: ubuntu-22.04
strategy:
fail-fast: false
matrix:
py_version:
- '3.8'

steps:
- name: Checkout repository
uses: actions/checkout@main

- name: Set up Python 3.9
- name: Set up Python ${{ matrix.py_version }}
uses: actions/setup-python@main
with:
python-version: '3.9'
python-version: ${{ matrix.py_version }}

- name: Setup venv
run: |
python3 -m venv .venv

- name: Install Dependencies
run: |
. .venv/bin/activate
python3 -m pip install -U -r requirements.txt
python3 -m pip install -U ruff
- name: Install uv
uses: astral-sh/setup-uv@v7

- name: mypy
- name: ruff
run: |
. .venv/bin/activate
ruff check
uvx ruff check src/

ruff_format:
name: ruff format
runs-on: ubuntu-latest
runs-on: ubuntu-22.04
strategy:
fail-fast: false
matrix:
py_version:
- '3.8'

steps:
- name: Checkout repository
uses: actions/checkout@main

- name: Set up Python 3.9
- name: Set up Python ${{ matrix.py_version }}
uses: actions/setup-python@main
with:
python-version: 3.9
python-version: ${{ matrix.py_version }}

- name: Setup venv
run: |
python3 -m venv .venv
- name: Install uv
uses: astral-sh/setup-uv@v7

- name: Install dependencies
run: |
. .venv/bin/activate
python3 -m pip install -U ruff

- name: mypy
- name: ruff
run: |
. .venv/bin/activate
ruff format src/ --check
uvx ruff format src/ --check
Loading
Loading