Skip to content

Update pyproject.toml & actions to poetry 2.x / PEP 621 #387

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 10 commits into
base: main
Choose a base branch
from

Conversation

dalito
Copy link
Member

@dalito dalito commented Apr 12, 2025

This is a clean start based on #364

  • change pyproject.toml to PEP621 style for poetry 2.x
  • update all gh-actions for poetry 2.x
  • changed pypi-publish action to follow the suggested 2-step process of building in one job and publishing in another
  • prepared pypi-publish action for trusted publishing; it is commented out now since you need to change the configuration in PyPI as well to enable it. Note that the env name is not pypias in the screenshots of the PyPI-docs but pypi-release.
  • enable dependabot for monthly action-updates (it will create PRs but not autoupdate)

Part of the work on linkml/linkml#2615

Closes linkml/linkml#2520

@dalito dalito force-pushed the poetry2-upgrade-contd branch 3 times, most recently from de8fc05 to 9165dc9 Compare April 12, 2025 15:39
Copy link

codecov bot commented Apr 12, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 63.79%. Comparing base (905789c) to head (445b1a5).

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #387   +/-   ##
=======================================
  Coverage   63.79%   63.79%           
=======================================
  Files          63       63           
  Lines        8951     8951           
  Branches     2587     2587           
=======================================
  Hits         5710     5710           
  Misses       2634     2634           
  Partials      607      607           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@dalito dalito marked this pull request as ready for review April 12, 2025 16:39
@dalito dalito requested a review from amc-corey-cox April 12, 2025 16:40
@dalito dalito force-pushed the poetry2-upgrade-contd branch from d1e81aa to ed642f1 Compare April 12, 2025 16:48
@dalito dalito mentioned this pull request Apr 12, 2025
4 tasks

version: 2
updates:
- package-ecosystem: github-actions

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a plan to have dependabot manage python deps, too?

Copy link
Member Author

@dalito dalito Apr 15, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not that I am aware of. But I remember that Patrick mentioned another tool for updating the dependencies somewhere else (renovate?). I would suggest to do it step by step (so not in this PR).

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dependabot currently supports poetry-mediated python dependency management via the pip configuration.

uv support has recently been announced.

I suggest adding in a config section for watching python deps since you're adding in GHA support in this PR.

@dalito dalito force-pushed the poetry2-upgrade-contd branch from b66f3c7 to cd28a04 Compare April 18, 2025 14:18

on:
release:
# Trigger the workflow only for real releases but no for draft releases
Copy link

@ialarmedalien ialarmedalien Apr 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

but not for draft releases (typo)

steps:
- uses: actions/checkout@v2
- uses: actions/[email protected]
# By default the ref (branch, tag or SHA) that triggered the workflow,

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

extremely pedantic 😁 : no need for the comma after "workflow"

Comment on lines 32 to 33
# Check if correct tag is available
git describe --tags --abbrev=0

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what happens if the correct tag isn't available?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm. I just found out that it is surprisingly possible to create a release without selecting a tag on the release-creation page. So it may be safer to not rely on it and use the full checkout with tags to derive the version safely. I'll change this.

Comment on lines 66 to 71
# Used actions: (updates managed by dependabot)
# - https://github.com/actions/checkout
# - https://github.com/actions/setup-python
# - https://github.com/actions/upload-artifact
# - https://github.com/actions/download-artifact
# - https://github.com/pypa/gh-action-pypi-publish/

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. Some files have this list at the top, some at the bottom. Can we standardise on a location?

  2. Is this list useful if deps are managed by dependabot anyway?

Copy link
Member Author

@dalito dalito Apr 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is only useful for other developers. Dependabot does not need it. Maybe we should remove this info everywhere?

--> I removed it.

if: github.event_name == 'release'
uses: pypa/[email protected]
with:
user: __token__

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does this get substituted in from somewhere?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just copied the code from the former version. __token__ is supplied by the pypi-publish action https://github.com/pypa/gh-action-pypi-publish/?tab=readme-ov-file#specifying-a-different-username

But based on the docs the line user: __token__ is not be needed. I remove it.

Comment on lines 96 to 98
with:
# don't specify repository like this or else we won't get pull request branches correctly
# repository: linkml/linkml-runtime

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this looks like cruft - can it be removed?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.


- name: Load cached venv
id: cached-poetry-dependencies
uses: actions/cache@v3
uses: actions/cache@1bd1e32a3bdc45362d1e726936510720a7c30a57

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do some actions use specific commits but others use versions? Can we standardise?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

packages = [
{ include = "linkml_runtime" }
include = ["linkml_runtime"]
requires-python = ">=3.9"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we need to add an upper bound?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not for requires-python, see python-poetry/poetry#10136

run: pipx install poetry==1.3.2
run: |
pipx install poetry
pipx inject poetry poetry-dynamic-versioning

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

don't need the dynamic versioning plugin unless you're releasing a package to pypi

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your comment made me look at the action in detail: I believe it does not do what it should do. My understanding is that it should run the tests with updated dependencies but it just installs from the current (possibly outdated) lock file. Then it removes the lockfile but does not create an updated one before running the tests. So the tests are exactly the same as when run from main.yaml.

Would you agree that the idea here is to update the lock file first and then test? In this case dynamic-versioning would be needed for the dependency update.

I'll update the logic.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sierra-moxon created the action, but accidentally removed the re-installation with updated dependencies in 0579243

Copy link

@ialarmedalien ialarmedalien Apr 23, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I also noticed that this action seems to duplicate a lot of the main.yaml actions so it may be time for a general GHA overhaul -- these actions could be written more efficiently and it's likely that some can be generalised and served organisation-wide.

@sierra-moxon would have to comment on the purpose of the action. IMO dependency updates should be done by developers, with dependabot, renovate, or something similar to alert devs to when updates are needed. I would not use a GHA to test whether the code still functions with all deps updated to the latest version because it doesn't actually do anything with the information -- if the tests fail, there's no prompt to limit versions and if newer deps are available, there's nothing to prompt devs to update the deps.

@ialarmedalien
Copy link

LGTM! Unfortunately I don't have write access to be able to approve this for merging, though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Failing linkml-runtime action test_upstream.yaml (poetry2-related?)
3 participants