Skip to content

Commit

Permalink
Merge pull request #8 from openscm/copier-update-test-pdm
Browse files Browse the repository at this point in the history
Update copier and try pdm again
  • Loading branch information
znicholls authored Dec 27, 2024
2 parents 172b6e5 + bd00bd8 commit 1925633
Show file tree
Hide file tree
Showing 17 changed files with 3,410 additions and 151 deletions.
6 changes: 3 additions & 3 deletions .copier-answers.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# Changes here will be overwritten by Copier; NEVER EDIT MANUALLY
_commit: v0.4.1-63-gd4970ec
_src_path: ../copier-core-python-repository
_commit: v0.7.0
_src_path: gl:znicholls/copier-core-python-repository
conda_release: false
email: [email protected]
include_cli: false
name: Zebedee Nicholls
notebook_based_docs: true
package_manager: uv
package_manager: pdm
pandas_doctests: false
plot_dependencies: true
project_description_short: Representation of continuous timeseries.
Expand Down
40 changes: 28 additions & 12 deletions .github/actions/setup/action.yml
Original file line number Diff line number Diff line change
@@ -1,29 +1,45 @@
name: "Setup Python and uv"
description: "setup Python and uv"
name: "Setup Python and pdm"
description: "setup Python and pdm with caches"

inputs:
python-version:
description: "Python version to use"
required: true
uv-dependency-install-flags:
description: "Flags to pass to uv when running `uv install`"
pdm-dependency-install-flags:
description: "Flags to pass to pdm when running `pdm install`"
required: true
run-uv-install:
description: "Should we run the uv install steps"
run-pdm-install:
description: "Should we run the pdm install steps"
required: false
default: true

runs:
using: "composite"
steps:
- name: Setup uv
id: setup-uv
uses: astral-sh/setup-uv@v4
- name: Write file with install flags
shell: bash
run: |
echo "${{ inputs.pdm-dependency-install-flags }}" > pdm-install-flags.txt
- name: Setup PDM
id: setup-pdm
uses: pdm-project/[email protected]
with:
version: "0.5.11"
python-version: ${{ inputs.python-version }}
cache: true
cache-dependency-path: |
./pdm.lock
./pdm-install-flags.txt
- name: Install dependencies
shell: bash
if: ${{ (inputs.run-uv-install == 'true') }}
if: ${{ (inputs.run-pdm-install == 'true') && (steps.setup-pdm.outputs.cache-hit != 'true') }}
run: |
pdm install --no-self ${{ inputs.pdm-dependency-install-flags }}
# Now run same command but let the package install too
- name: Install package
shell: bash
# To ensure that the package is always installed, this step is run even if the cache was hit
if: ${{ inputs.run-pdm-install == 'true' }}
run: |
uv sync ${{ inputs.uv-dependency-install-flags }}
pdm install ${{ inputs.pdm-dependency-install-flags }}
pdm run which python
pdm run python --version # Check python version just in case
8 changes: 2 additions & 6 deletions .github/workflows/bump.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
name: Bump version
# For the time being, we still do this with pdm.
# Honestly, it doesn't really matter,
# but one day uv will have a bump command too and we can switch to that.
# Relevant issue in uv: https://github.com/astral-sh/uv/issues/6298

on:
workflow_dispatch:
Expand Down Expand Up @@ -52,7 +48,7 @@ jobs:
- uses: ./.github/actions/setup
with:
python-version: ${{ matrix.python-version }}
uv-dependency-install-flags: "--all-extras --group dev"
pdm-dependency-install-flags: "--group dev --dev"

- name: Create bump and changelog
run: |
Expand All @@ -69,7 +65,7 @@ jobs:
echo "Bumping to version $NEW_VERSION"
# Build CHANGELOG
uv run towncrier build --yes --version v$NEW_VERSION
pdm run towncrier build --yes --version v$NEW_VERSION
# Commit, tag and push
git commit -a -m "bump: version $BASE_VERSION -> $NEW_VERSION"
Expand Down
62 changes: 36 additions & 26 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,33 +20,37 @@ jobs:
- uses: ./.github/actions/setup
with:
python-version: ${{ matrix.python-version }}
uv-dependency-install-flags: "--all-extras --group dev"
pdm-dependency-install-flags: "--group :all --group dev --dev"
- name: mypy
run: |
MYPYPATH=stubs uv run mypy src
MYPYPATH=stubs pdm run mypy src
docs:
if: ${{ !github.event.pull_request.draft }}
runs-on: ubuntu-latest
strategy:
matrix:
os: [ "ubuntu-latest" ]
python-version: [ "3.11" ]
runs-on: "${{ matrix.os }}"
steps:
- name: Check out repository
uses: actions/checkout@v4
- uses: ./.github/actions/setup
with:
python-version: "3.11"
uv-dependency-install-flags: "--all-extras --group docs"
python-version: ${{ matrix.python-version }}
pdm-dependency-install-flags: "--group :all --group docs --dev"
- name: docs
run: |
uv run mkdocs build --strict
pdm run mkdocs build --strict
- uses: ./.github/actions/setup
with:
python-version: "3.11"
uv-dependency-install-flags: "--all-extras --group docs --group dev"
pdm-dependency-install-flags: "--group :all --group docs --group dev --dev"
- name: docs-with-changelog
run: |
# Check CHANGELOG will build too
uv run towncrier build --yes
uv run mkdocs build --strict
pdm run towncrier build --yes
pdm run mkdocs build --strict
# Just in case, undo the staged changes
git restore --staged . && git restore .
Expand Down Expand Up @@ -76,11 +80,11 @@ jobs:
# when people try to run without installing optional dependencies,
# we should add a CI step that runs the tests without optional dependencies too.
# We don't have that right now, because we're not sure this pain point exists.
uv-dependency-install-flags: "--all-extras --group tests"
pdm-dependency-install-flags: "--group :all --group tests --dev"
- name: Run tests
run: |
uv run pytest -r a -v src tests --doctest-modules --cov=src --cov-report=term-missing --cov-report=xml
uv run coverage report
pdm run pytest -r a -v src tests --doctest-modules --cov=src --cov-report=term-missing --cov-report=xml
pdm run coverage report
- name: Upload coverage reports to Codecov with GitHub Action
uses: codecov/[email protected]
env:
Expand All @@ -99,42 +103,48 @@ jobs:
- uses: ./.github/actions/setup
with:
python-version: ${{ matrix.python-version }}
uv-dependency-install-flags: "--no-dev" # no extras is default
pdm-dependency-install-flags: "--prod --without :all"
- name: Check importable without extras
run: uv run python scripts/test-install.py
run: pdm run python scripts/test-install.py

check-build:
runs-on: ubuntu-latest
strategy:
matrix:
os: [ "ubuntu-latest" ]
python-version: [ "3.11" ]
runs-on: "${{ matrix.os }}"
steps:
- name: Check out repository
uses: actions/checkout@v4
- name: Setup uv
id: setup-uv
uses: astral-sh/setup-uv@v4
- name: Setup PDM
uses: pdm-project/[email protected]
with:
version: "0.5.11"
python-version: "3.9"
python-version: ${{ matrix.python-version }}
- name: Build package
run: |
uv build
pdm build
- name: Check build
run: |
tar -tvf dist/continuous_timeseries-*.tar.gz --wildcards '*continuous_timeseries/py.typed'
tar -tvf dist/continuous_timeseries-*.tar.gz --wildcards 'continuous_timeseries-*/LICENCE'
check-dependency-licences:
runs-on: ubuntu-latest
strategy:
matrix:
os: [ "ubuntu-latest" ]
python-version: [ "3.11" ]
runs-on: "${{ matrix.os }}"
steps:
- name: Check out repository
uses: actions/checkout@v4
- uses: ./.github/actions/setup
with:
python-version: "3.9"
uv-dependency-install-flags: "--group dev"
python-version: ${{ matrix.python-version }}
pdm-dependency-install-flags: "--group dev --dev"
- name: Check licences of dependencies
shell: bash
run: |
TEMP_FILE=$(mktemp)
uv export --no-dev > $TEMP_FILE
uv run liccheck -r $TEMP_FILE -R licence-check.txt
pdm export --prod > $TEMP_FILE
pdm run liccheck -r $TEMP_FILE -R licence-check.txt
cat licence-check.txt
11 changes: 4 additions & 7 deletions .github/workflows/deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
strategy:
matrix:
os: [ "ubuntu-latest" ]
python-version: [ "3.9" ]
python-version: [ "3.11" ]
runs-on: "${{ matrix.os }}"
permissions:
# this permission is mandatory for trusted publishing with PyPI
Expand All @@ -28,13 +28,10 @@ jobs:
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup uv
id: setup-uv
uses: astral-sh/setup-uv@v4
- name: Setup PDM
uses: pdm-project/[email protected]
with:
version: "0.5.11"
python-version: ${{ matrix.python-version }}
- name: Publish to PyPI
run: |
uv build
uv publish
pdm publish
2 changes: 1 addition & 1 deletion .github/workflows/install-pypi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
python-version: [ "3.9", "3.10", "3.11" ]
# Check both 'library' install and the 'application' (i.e. locked) install
install-target: ["continuous-timeseries", "continuous-timeseries[locked]"]
runs-on: "${{ matrix.os }}"
runs-on: "${{ matrix.os }}"
steps:
- name: Set up Python "${{ matrix.python-version }}"
id: setup-python
Expand Down
12 changes: 5 additions & 7 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,26 +21,24 @@ jobs:
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup uv
id: setup-uv
uses: astral-sh/setup-uv@v4
- name: Setup PDM
uses: pdm-project/[email protected]
with:
version: "0.5.11"
python-version: ${{ matrix.python-version }}
- name: Add version to environment
run: |
PROJECT_VERSION=`sed -ne 's/^version = "\([0-9\.a]*\)"/\1/p' pyproject.toml`
echo "PROJECT_VERSION=$PROJECT_VERSION" >> $GITHUB_ENV
- name: Build package for PyPI
run: |
uv build
pdm build
- name: Generate Release Notes
run: |
echo "" >> ".github/release_template.md"
echo "## Changelog" >> ".github/release_template.md"
echo "" >> ".github/release_template.md"
uv add typer
uv run python scripts/changelog-to-release-template.py >> ".github/release_template.md"
pdm add typer
pdm run python scripts/changelog-to-release-template.py >> ".github/release_template.md"
echo "" >> ".github/release_template.md"
echo "## Changes" >> ".github/release_template.md"
echo "" >> ".github/release_template.md"
Expand Down
34 changes: 13 additions & 21 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ ci:
autoupdate_schedule: quarterly
autoupdate_branch: pre-commit-autoupdate
# Currently network access isn't supported in the pre-commit CI product.
skip: [uv-lock, uv-export, pdm-lock-check]
skip: [pdm-lock-check, pdm-export, pdm-sync]

# See https://pre-commit.com/hooks.html for more hooks
repos:
Expand Down Expand Up @@ -38,30 +38,22 @@ repos:
- id: ruff
args: [ --fix, --exit-non-zero-on-fix ]
- id: ruff-format
- repo: https://github.com/astral-sh/uv-pre-commit
# uv version.
rev: 0.5.11
hooks:
- id: uv-lock
name: uv-lock-check
args: ["--check"]
# Put requirements.txt files in the repo too
- id: uv-export
name: export-requirements
args: ["-o", "requirements-locked.txt", "--no-hashes", "--no-dev", "--no-emit-project"]
- id: uv-export
name: export-requirements-optional
args: ["-o", "requirements-incl-optional-locked.txt", "--no-hashes", "--no-dev", "--no-emit-project", "--all-extras"]
- id: uv-export
name: export-requirements-docs
args: ["-o", "requirements-docs-locked.txt", "--no-hashes", "--no-dev", "--no-emit-project", "--all-extras", "--group", "docs"]
# # Not released yet
# - id: uv-sync
- repo: https://github.com/pdm-project/pdm
rev: 2.22.1
hooks:
# Check that the lock file is up to date.
# We need the pdm lock file too
# so that we can build the locked version of the package.
- id: pdm-lock-check
args: ["--group", ":all", "--strategy", "inherit_metadata"]
args: ["--group", ":all", "--group", "all-dev", "--dev", "--strategy", "inherit_metadata"]
# Put requirements.txt files in the repo too
- id: pdm-export
name: export-requirements
args: ["-o", "requirements-locked.txt", "--without-hashes", "--prod"]
- id: pdm-export
name: export-requirements-optional
args: ["-o", "requirements-incl-optional-locked.txt", "--without-hashes", "--prod", "--group", ":all"]
- id: pdm-export
name: export-requirements-docs
args: ["-o", "requirements-docs-locked.txt", "--without-hashes", "--group", ":all", "--group", "docs", "--dev"]
- id: pdm-sync
Loading

0 comments on commit 1925633

Please sign in to comment.