Skip to content
Open
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
270 changes: 182 additions & 88 deletions .github/actions/setup-env/action.yml

Large diffs are not rendered by default.

41 changes: 32 additions & 9 deletions .github/workflows/benchmark.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,27 @@ on:
extras:
type: string
default: dev,benchmarks
description: Comma-separated extras to install with the wheel.
description: Comma-separated extras to install with the wheel (library mode).
python-version:
type: string
default: "3.13"
description: Python version of the benchmark env.
description: Python version of the benchmark env (library mode).
groups:
type: string
default: ''
description: Comma-separated dependency groups to install with the wheel. Only these groups are installed.
pixi-add:
type: string
default: ""
description: Space-separated conda-forge specs to add to the env.
default: ''
description: Space-separated conda specs added to a throwaway pixi env that becomes the install target, e.g. "glpk". Empty installs into a uv venv.
uv-locked:
type: string
default: auto
description: auto, true or false. true installs dependencies from uv.lock and fails on a stale lock, false resolves fresh. auto is true on pull_request events, falling back to false when uv.lock is missing.
cooldown:
type: string
default: 7d
description: Ignore conda and PyPI releases newer than this age, e.g. 7d. Empty disables. uv-locked installs ignore it.
description: Ignore PyPI releases newer than this age, e.g. 7d (library mode, applies when the install resolves fresh, i.e. uv-locked false, or auto off pull_request). Empty disables.
pytest-args:
type: string
default: ""
Expand Down Expand Up @@ -129,6 +137,8 @@ jobs:
python-version: ${{ inputs.python-version }}
pixi-add: ${{ inputs.pixi-add }}
extras: ${{ inputs.extras }}
groups: ${{ inputs.groups }}
uv-locked: ${{ inputs.uv-locked }}
cooldown: ${{ inputs.cooldown }}
wheel-dir: ${{ runner.temp }}/wheels
vars-json: ${{ toJSON(vars) }}
Expand Down Expand Up @@ -182,13 +192,21 @@ jobs:
- id: base
env:
WORKING_DIRECTORY: ${{ inputs.working-directory }}
UV_LOCKED: ${{ inputs.uv-locked }}
run: |
set -euo pipefail
if [ "$IS_PR" = true ] && [ -f "base/$WORKING_DIRECTORY/pyproject.toml" ]; then
dir="base/$WORKING_DIRECTORY"
env_dir="head/$WORKING_DIRECTORY"
if [ "$IS_PR" = true ] && [ -f "$dir/pyproject.toml" ]; then
echo "present=true" >> "$GITHUB_OUTPUT"
# A base without uv.lock (e.g. the PR adds it) cannot back a locked env: use head's.
if [ "$UV_LOCKED" = false ] || [ -f "$dir/uv.lock" ]; then
env_dir="$dir"
fi
else
echo "present=false" >> "$GITHUB_OUTPUT"
fi
echo "env-dir=$env_dir" >> "$GITHUB_OUTPUT"
- uses: hynek/build-and-inspect-python-package@67230f7b8410ae0052b39c1efc89d89fff43ff10 # v3.0.2
id: head-build
with:
Expand Down Expand Up @@ -223,17 +241,20 @@ jobs:
first="base"
fi
echo "first=$RUNNER_TEMP/wheels/$first" >> "$GITHUB_OUTPUT"
- uses: $/.github/actions/setup-env
- id: env
uses: $/.github/actions/setup-env
with:
mode: library
python-version: ${{ inputs.python-version }}
pixi-add: ${{ inputs.pixi-add }}
extras: ${{ inputs.extras }}
groups: ${{ inputs.groups }}
uv-locked: ${{ inputs.uv-locked }}
cooldown: ${{ inputs.cooldown }}
wheel-dir: ${{ steps.wheels.outputs.first }}
vars-json: ${{ toJSON(vars) }}
vars-env: ${{ inputs.vars-env }}
working-directory: ${{ steps.base.outputs.present == 'true' && 'base' || 'head' }}/${{ inputs.working-directory }}
working-directory: ${{ steps.base.outputs.env-dir }}
- if: steps.base.outputs.present == 'true'
working-directory: base/${{ inputs.working-directory }}
env:
Expand All @@ -253,7 +274,9 @@ jobs:
env:
PACKAGE: ${{ steps.head-build.outputs.package_name }}
WHEEL: ${{ steps.head-wheel.outputs.wheel }}
run: $RUN uv pip install --reinstall-package "$PACKAGE" "${WHEEL}[$EXTRAS]"
run: |
set -euo pipefail
uv pip install --reinstall-package "$PACKAGE" "${WHEEL}[${EXTRAS//[[:space:]]/}]"
- working-directory: head/${{ inputs.working-directory }}
env:
CDSAPI_KEY: ${{ secrets.CDSAPI_KEY }}
Expand Down
36 changes: 34 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,16 +56,46 @@ jobs:
test "$LEAN" = '[{"os":"ubuntu-latest","version":"3.12"},{"os":"ubuntu-latest","version":"3.14"}]'
test "$FULL" = '[{"os":"ubuntu-latest","version":"3.12"},{"os":"windows-latest","version":"3.12"}]'

test-library:
test-library-uv:
uses: ./.github/workflows/test.yml
permissions:
contents: read
id-token: write
with:
working-directory: tests/fixture-package
pixi-add: glpk
artifact-suffix: -uv
matrix: full
python-versions: '["3.12"]'
uv-locked: ${{ 'true' }} # zizmor: ignore[obfuscation] actionlint types a bare 'true' as bool
groups: dev
extras: ''
coverage: true

test-library-uv-unlocked:
uses: ./.github/workflows/test.yml
permissions:
contents: read
id-token: write
with:
working-directory: tests/fixture-package
uv-locked: ${{ 'false' }} # zizmor: ignore[obfuscation] actionlint types a bare 'false' as bool
groups: dev
extras: benchmarks
artifact-suffix: -uv-unlocked

test-library-pixi-add:
uses: ./.github/workflows/test.yml
permissions:
contents: read
id-token: write
with:
working-directory: tests/fixture-package
pixi-add: glpk
groups: dev
extras: ''
pytest-args: --require-binary glpsol
artifact-suffix: -pixi-add

test-project:
uses: ./.github/workflows/test.yml
permissions:
Expand All @@ -86,6 +116,8 @@ jobs:
with:
mode: compare
benchmark-path: benchmarks
groups: dev
extras: benchmarks
working-directory: tests/fixture-package

link-check:
Expand Down
8 changes: 6 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -180,9 +180,10 @@ jobs:
MOSEKLM_LICENSE_FILE: ${{ secrets.MOSEKLM_LICENSE_FILE }}
GUROBI_LIC: ${{ secrets.GUROBI_LIC }}
with:
extras: ${{ fromJSON(inputs.test-inputs).extras || 'dev' }}
extras: ${{ fromJSON(inputs.test-inputs).extras == null && 'dev' || fromJSON(inputs.test-inputs).extras }}
groups: ${{ fromJSON(inputs.test-inputs).groups || '' }}
pixi-add: ${{ fromJSON(inputs.test-inputs).pixi-add || '' }}
uv-locked: ${{ fromJSON(inputs.test-inputs).uv-locked == true }}
uv-locked: ${{ fromJSON(inputs.test-inputs)['uv-locked'] == null && 'auto' || format('{0}', fromJSON(inputs.test-inputs)['uv-locked']) || 'auto' }}
cooldown: ${{ fromJSON(inputs.test-inputs).cooldown == null && '7d' || fromJSON(inputs.test-inputs).cooldown }}
matrix: ${{ fromJSON(inputs.test-inputs).matrix || 'auto' }}
python-versions: ${{ fromJSON(inputs.test-inputs).python-versions || '' }}
Expand Down Expand Up @@ -301,6 +302,9 @@ jobs:
mode: library
python-version: ${{ needs.build.outputs.python-version }}
extras: ""
pixi-add: ${{ fromJSON(inputs.test-inputs).pixi-add || '' }}
uv-locked: 'false'
pixi-version: ${{ fromJSON(inputs.test-inputs).pixi-version || 'v0.81.0' }}
wheel-dir: ${{ runner.temp }}/wheels
working-directory: ${{ inputs.working-directory }}
- env:
Expand Down
34 changes: 21 additions & 13 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,26 +7,30 @@ on:
type: string
default: dev
description: Comma-separated extras installed with the wheel (library mode).
groups:
type: string
default: ''
description: Comma-separated dependency groups installed with the wheel (library mode). Only these groups are installed.
pixi-add:
type: string
default: ''
description: Space-separated conda specs added to the env (library mode).
description: Space-separated conda specs added to a throwaway pixi env that becomes the install target (library mode), e.g. "glpk gurobi::gurobi". Empty installs into a uv venv.
uv-locked:
type: boolean
default: false
description: Install dependencies from uv.lock before the wheel (library mode).
type: string
default: auto
description: auto, true or false (library mode). true installs dependencies from uv.lock and fails on a stale lock, false resolves fresh. auto is true on pull_request events, falling back to false when uv.lock is missing.
cooldown:
type: string
default: 7d
description: Ignore conda and PyPI releases newer than this age, e.g. 7d. Empty disables. uv-locked installs ignore it.
description: Ignore PyPI releases newer than this age, e.g. 7d (library mode, applies when the install resolves fresh, i.e. uv-locked false, or auto off pull_request). Empty disables.
matrix:
type: string
default: auto
description: auto, single, lean or full.
python-versions:
type: string
default: ''
description: JSON list of Python versions. Default from trove classifiers.
description: JSON list of Python versions (library mode). Default from trove classifiers.
os-full:
type: string
default: '["ubuntu-latest","macos-latest","windows-latest"]'
Expand All @@ -46,11 +50,11 @@ on:
pixi-environments:
type: string
default: '["default"]'
description: Project mode. JSON list of pixi environments or a regex matched against them.
description: pixi repos. JSON list of pixi environments or a regex matched against them.
manifest-path:
type: string
default: ''
description: Project mode manifest, relative to working-directory.
description: pixi manifest, relative to working-directory. Default pixi.toml, else pyproject.toml with a [tool.pixi] table.
pixi-version:
type: string
default: v0.81.0
Expand Down Expand Up @@ -131,21 +135,24 @@ jobs:
shell: bash
working-directory: ${{ inputs.working-directory }}
env:
PIXI_TASK: ${{ inputs.pixi-task }}
PROJECT: ${{ inputs.pixi-task != '' }}
PYTHON_VERSIONS: ${{ inputs.python-versions }}
CLASSIFIERS: ${{ steps.baipp.outputs.supported_python_classifiers_json_array }}
PIXI_ENVIRONMENTS: ${{ inputs.pixi-environments }}
MANIFEST_PATH: ${{ inputs.manifest-path }}
run: |
set -euo pipefail
if [ -z "$PIXI_TASK" ]; then
if [ "$PROJECT" != true ]; then
versions="${PYTHON_VERSIONS:-$CLASSIFIERS}"
elif [[ "$PIXI_ENVIRONMENTS" == \[* ]]; then
versions="$PIXI_ENVIRONMENTS"
else
manifest_args=()
[ -z "$MANIFEST_PATH" ] || manifest_args=(--manifest-path "$MANIFEST_PATH")
versions=$(pixi info --json ${manifest_args[@]+"${manifest_args[@]}"} | jq -c --arg re "$PIXI_ENVIRONMENTS" '[.environments_info[].name | select(test($re))]')
manifest="$MANIFEST_PATH"
if [ -z "$manifest" ]; then
if [ -f pixi.toml ]; then manifest=pixi.toml; else manifest=pyproject.toml; fi
fi
[ -f "$manifest" ] || { echo "::error::manifest $manifest not found" >&2; exit 1; }
versions=$(pixi info --json --manifest-path "$manifest" | jq -c --arg re "$PIXI_ENVIRONMENTS" '[.environments_info[].name | select(test($re))]')
fi
jq -e 'type == "array" and length > 0' <<<"${versions:-null}" >/dev/null || { echo "::error::no Python versions or pixi environments found: '${versions:-}'" >&2; exit 1; }
echo "versions=$versions" >>"$GITHUB_OUTPUT"
Expand Down Expand Up @@ -195,6 +202,7 @@ jobs:
pixi-environment: ${{ inputs.pixi-task != '' && matrix.version || 'default' }}
pixi-add: ${{ inputs.pixi-add }}
extras: ${{ inputs.extras }}
groups: ${{ inputs.groups }}
uv-locked: ${{ inputs.uv-locked }}
cooldown: ${{ inputs.cooldown }}
wheel-dir: ${{ runner.temp }}/packages
Expand Down
Loading
Loading