Skip to content
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

Feature: complete lifecycle signals and documentation #1147

Merged
merged 7 commits into from
Jun 22, 2022

Conversation

noirbizarre
Copy link
Member

@noirbizarre noirbizarre commented Jun 20, 2022

Pull Request Check List

  • A news fragment is added in news/ describing what is new.
  • Test cases added for changed code.

Describe what you have changed in this PR.

This PR follows #1127 and adds the following:

  • signals:
    • pre_publish executed before publishing
    • post_publish executed before publishing
    • pre_script executed before each script execution (runs multiple times in case of composite script)
    • post_script executed after each script execution (runs multiple times in case of composite script)
    • pre_run executed once before a run (run only once in case of composite script)
    • post_run executed once after a run (run only once in case of composite script)
  • commands:
    • new: just because I documented if and it wasn't existing (I'm also rust/cargo user, I bootstrap project with it)
  • documentation:
    • a new dedicated Lifecycle and hooks section with detailled lifecycle documentation with flow charts
    • update/re-lock doc dependencies (to benefit from latest mermaid)

As it's documentation, as there as been changes since I started writting it (at least the cli reference), there might have some typos and inconsistencies to fix.

It was interesting digging into the commands and the lifecycle. I think some good additions for could be:

  • pre/post_upload hooks
  • more plugin docs on signals (I might do a PR)
  • centralize all signals registeration into hooks.py for clarity and ease of maintainance
  • link commands to their CLI reference instead of the chapter showcasing its usage (page was added during the contribution)

Note: I made a single PR because to me everything is related but I can split into multiple PRs if required

noirbizarre added a commit to noirbizarre/pdm that referenced this pull request Jun 20, 2022
@noirbizarre
Copy link
Member Author

The failing test is also failing on dev locally. I believe this is a flaky test depending on the current PyPI status.
I didn't had time to check why precisely it is failing

@frostming
Copy link
Collaborator

The failing test is also failing on dev locally.

dev branch runs well locally here.

@frostming
Copy link
Collaborator

pre/post_upload hooks

No, just enough hooks :P

more plugin docs on signals (I might do a PR)

Good.

centralize all signals registration into hooks.py for clarity and ease of maintenance

Agree

link commands to their CLI reference instead of the chapter showcasing its usage (page was added during the contribution)

Good

@noirbizarre
Copy link
Member Author

Updated with the comments taken in account (changed some links format, removed the new command and its documentation)
I also removed the lock update (which seemed to be the issue, the test was seeing both a tar.gz and a wheel).

pre/post_upload hooks

No, just enough hooks :P

Noted 😅

more plugin docs on signals (I might do a PR)

Good.

I have some plugin idea I'd like to try, that will be a good opportunity to do it (and dogfooding it at the same time)

centralize all signals registration into hooks.py for clarity and ease of maintenance

Agree

OK, will do 👍🏼

link commands to their CLI reference instead of the chapter showcasing its usage (page was added during the contribution)

Good

Done ✅

@noirbizarre noirbizarre force-pushed the feature/lifecycle branch 4 times, most recently from 0efaf8b to b05bf5b Compare June 21, 2022 18:01
@codecov-commenter
Copy link

codecov-commenter commented Jun 21, 2022

Codecov Report

Merging #1147 (d42ccd7) into dev (c80b7ff) will increase coverage by 0.15%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##              dev    #1147      +/-   ##
==========================================
+ Coverage   84.39%   84.54%   +0.15%     
==========================================
  Files          80       80              
  Lines        7075     7086      +11     
  Branches     1681     1683       +2     
==========================================
+ Hits         5971     5991      +20     
+ Misses        737      730       -7     
+ Partials      367      365       -2     
Flag Coverage Δ
unittests 84.32% <100.00%> (+0.15%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
pdm/cli/commands/build.py 84.61% <ø> (-2.06%) ⬇️
pdm/cli/commands/lock.py 100.00% <ø> (ø)
pdm/cli/commands/init.py 100.00% <100.00%> (ø)
pdm/cli/commands/install.py 90.00% <100.00%> (-0.91%) ⬇️
pdm/cli/commands/publish/__init__.py 86.25% <100.00%> (+0.53%) ⬆️
pdm/cli/commands/run.py 90.95% <100.00%> (+0.37%) ⬆️
pdm/cli/hooks.py 100.00% <100.00%> (ø)
pdm/signals.py 100.00% <100.00%> (ø)
pdm/installers/synchronizers.py 86.26% <0.00%> (+3.86%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update c80b7ff...d42ccd7. Read the comment docs.

Copy link
Collaborator

@frostming frostming left a comment

Choose a reason for hiding this comment

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

Hi, I reviewed the content of the new documentation page and left some comments.

Copy link
Collaborator

@frostming frostming left a comment

Choose a reason for hiding this comment

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

LGTM, @pawamoy any to add?

Copy link
Contributor

@pawamoy pawamoy left a comment

Choose a reason for hiding this comment

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

Awesome docs 🙂

@noirbizarre
Copy link
Member Author

Thx 🙏🏼
Awesome tool so I'm glad to be able to contribute !
LGTM, whenever you want (and whoever has permissions) !

@frostming frostming merged commit c3541ba into pdm-project:dev Jun 22, 2022
@noirbizarre noirbizarre deleted the feature/lifecycle branch June 22, 2022 16:06
frostming pushed a commit that referenced this pull request Jun 24, 2022
* feat(hooks): Added pre-publish hook

* refactor(hooks): dynamic signal/hooks listing avoiding double declaration

* feat(hooks): added (pre|post)_script and (pre|post)_run hooks

* doc(hooks): added lifecycle and hooks documentation

* review fix

* fix(tests): add and use the _echo fixture for cross-plateform and concise test echos

* refactor(hooks): automatically register the script handler for all hooks
frostming pushed a commit that referenced this pull request Jun 24, 2022
* feat(hooks): Added pre-publish hook

* refactor(hooks): dynamic signal/hooks listing avoiding double declaration

* feat(hooks): added (pre|post)_script and (pre|post)_run hooks

* doc(hooks): added lifecycle and hooks documentation

* review fix

* fix(tests): add and use the _echo fixture for cross-plateform and concise test echos

* refactor(hooks): automatically register the script handler for all hooks
frostming pushed a commit that referenced this pull request Jun 28, 2022
* feat(hooks): Added pre-publish hook

* refactor(hooks): dynamic signal/hooks listing avoiding double declaration

* feat(hooks): added (pre|post)_script and (pre|post)_run hooks

* doc(hooks): added lifecycle and hooks documentation

* review fix

* fix(tests): add and use the _echo fixture for cross-plateform and concise test echos

* refactor(hooks): automatically register the script handler for all hooks
frostming added a commit that referenced this pull request Jun 28, 2022
* feat(core): Use tomllib on Python 3.11 (#1072)

* docs: 📝 Fix typo in `pip install pdm` description (#1061)

* Use tomllib on Python 3.11

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* news

* use a compatibility module

* missed one import

Co-authored-by: t106362512 <33215526+t106362512@users.noreply.github.com>
Co-authored-by: hauntsaninja <>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>

* feat(core): Replace halo, click, and termcolor with rich (#1091)

* feat(core): Use `unearth` as the backend to find and download packages (#1096)

* perf(resolver): Speed up the resolution with lazy find_matches (#1098)

* Improve the output of installing packages

* Use confirm instead of ask

* feat(core): New command: pdm publish (#1107)

* Use rich handler for logging to stderr

* feat(scripts): added composite tasks support (#1117)

* feat(core): Add option to skip hooks (#1127)

* fix(scripts): allow pdm test command to receive path arguments

* feat(hooks): added a `--skip` option to skipp scripts and hooks (#1127)

fix #948

* feat(hooks): use PDM_SKIP_HOOKS environement variable as fallback for skip list

* feat(core): Support setup.py import (#1137)

* Update completion script

* fix(resolution): fix a bug that versions with local part can't be found and installed
Close #1093

* feat(core): forbid editable depenencies in project table (#1140)

* Make the error message more friendly

* doc: improve the docs about dependencies

* doc: add CLI reference doc

* doc: use asciiart as the program description

* chore: remove remaining artifacts from #1127 (#1152)

* Feature: complete lifecycle signals and documentation (#1147)

* feat(hooks): Added pre-publish hook

* refactor(hooks): dynamic signal/hooks listing avoiding double declaration

* feat(hooks): added (pre|post)_script and (pre|post)_run hooks

* doc(hooks): added lifecycle and hooks documentation

* review fix

* fix(tests): add and use the _echo fixture for cross-plateform and concise test echos

* refactor(hooks): automatically register the script handler for all hooks

* feat: Update pdm-pep517 to 1.0 (#1153)

* fix(scripts): merge the Script and Description field from listing (#1151)

* feat: fetch the candidate hashes concurrently (#1154)

* feat: fetch the candidate hashes concurrently

* add news

* Feat/respect-source-order (#1155)

* doc: restructure the docs about project metadata and build configuration

* parse pep 621 metadata to avoid build (#1156)

* feat: Remove the compatible support for pdm legacy metadata (#1157)

* fix(config): use platform standard directories for all PDM directories (#1161)

Fixes #1150

* fix(#1156): only trust parsing result when all are static

* New build configuration table

* chore: added a tox.ini file for easier local testing against all Python versions (#1160)

* feat(CLI): Yarn-like root scripts fallback (#1159)

* feat(hooks): added a post_use hook (#1163)

Co-authored-by: Shantanu <12621235+hauntsaninja@users.noreply.github.com>
Co-authored-by: t106362512 <33215526+t106362512@users.noreply.github.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Axel H <noirbizarre@users.noreply.github.com>
frostming pushed a commit that referenced this pull request Jun 28, 2022
* feat(hooks): Added pre-publish hook

* refactor(hooks): dynamic signal/hooks listing avoiding double declaration

* feat(hooks): added (pre|post)_script and (pre|post)_run hooks

* doc(hooks): added lifecycle and hooks documentation

* review fix

* fix(tests): add and use the _echo fixture for cross-plateform and concise test echos

* refactor(hooks): automatically register the script handler for all hooks
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.

4 participants