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

update framework #77

Merged
merged 15 commits into from
Jul 19, 2023
Merged

update framework #77

merged 15 commits into from
Jul 19, 2023

Conversation

casperdcl
Copy link
Member

@casperdcl casperdcl commented Jul 6, 2023

Part of #76, closes #11, closes #54, fixes #56

  • migrate setup.py => pyproject.toml
    • use SCM versioning
    • drop unused sphinx dependency
  • migrate unittest => pytest
    • fix & update some tests
  • add CI tests & update workflows
    • purge conda packaging (will do in upstream conda-forge repo instead)
  • misc code tidy
    • esp. reduce duplication in test/test__formUI_status_test.py
  • add qdarkstyle dependency
  • misc minor metadata updates
  • enforce annotated tags for releases
  • https://github.com/paskino/qt-elements/transfer to @TomographicImaging
    • update URLs

follow-up issues for separate PRs

@casperdcl casperdcl added enhancement New feature or request tests gh-actions labels Jul 6, 2023
@casperdcl casperdcl self-assigned this Jul 6, 2023
@casperdcl casperdcl mentioned this pull request Jul 5, 2023
8 tasks
Copy link
Member

@lauramurgatroyd lauramurgatroyd left a comment

Choose a reason for hiding this comment

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

Thanks, it looks great! Please see my comments 😄
Nice work on tidying the tests!

@@ -1,66 +0,0 @@

Copy link
Member

Choose a reason for hiding this comment

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

I think we need to keep the CHANGELOG.
The way we use it is, when anything is merged to master, we add a description of the changes to the change log, for version x.x.x, this continues until we decide to release. Then when we release we copy over the contents of the change log.
So we use it as we go along, before releases.

Copy link
Member Author

@casperdcl casperdcl Jul 6, 2023

Choose a reason for hiding this comment

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

Committed CHANGELOG.txt files were indeed standard in the days of mercurial & subversion, but are becoming less common. A few reasons I can think of:

  • adhering to SSoT/DRY principles, i.e. no duplication across CHANGELOG.txt and github.com/OWNER/REPO/releases
  • not bloating repo size & reducing download time
  • triggering CI
  • webscrapers, automated parsing, webhooks & external tools
    • e.g. zenodo.org picks up changelogs from GH releases' notes rather than changelog files

Meanwhile, for progressively building pre-release notes, you could use one of the following places:

  1. pull request descriptions
  2. commit messages
  3. draft (unpublished) releases

Note that (for the lazy) the latter 2 options are combined as per this1, though personally I find it best to put effort into the first option2.

Always happy to discuss alternatives though :)

Footnotes

  1. which is a lightweight version of GH's IMO-too-verbose-eyecandy autogenerated notes

  2. e.g. https://github.com/NiftyPET/NIMPA/pull/28#issue-1732872191 -> https://github.com/NiftyPET/NIMPA/releases/tag/v2.6.0

LICENSE Outdated
Comment on lines 1 to 7
Copyright 2020 Edoardo Pasca

TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

1. Definitions.
http://www.apache.org/licenses/LICENSE-2.0
Copy link
Member

@lauramurgatroyd lauramurgatroyd Jul 6, 2023

Choose a reason for hiding this comment

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

We need to discuss with @paskino about the licensing, headers, etc. but all contributors should be listed and it's copyright to the institution:

Copyright 2020 United Kingdom Research and Innovation

Then the authors list is separate

Authors:
Edoardo Pasca
etc.

Copy link
Member Author

Choose a reason for hiding this comment

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

Updated.
Also worth a follow-up issue/discussion I think.

eqt/io.py Outdated Show resolved Hide resolved
@@ -1,36 +0,0 @@
package:
name: eqt
Copy link
Member

Choose a reason for hiding this comment

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

My understanding is that the conda build will happen somehow with conda-forge but will we not need any of these files for it?

Copy link
Member Author

Choose a reason for hiding this comment

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

no, it won't be needed :)

pyproject.toml Outdated
[project.urls]
documentation = "https://github.com/paskino/qt-elements#readme"
repository = "https://github.com/paskino/qt-elements"
changelog = "https://github.com/paskino/qt-elements/releases"
Copy link
Member

Choose a reason for hiding this comment

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

When/if we reinstate the changelog.md, we can change the link here

.github/workflows/test.yml Show resolved Hide resolved
Comment on lines 42 to 44
changelog=$(git log --pretty='format:%d%n- %s%n%b---' $(git tag --sort=v:refname | tail -n2 | head -n1)..HEAD)
tag="${GITHUB_REF#refs/tags/}"
gh release create --title "Version $tag" --draft --notes "$changelog" "$tag" dist/${{ steps.dist.outputs.whl }} dist/${{ steps.dist.outputs.targz }}
Copy link
Member

Choose a reason for hiding this comment

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

Does this automatically create the version description from the git logs?
I think we would prefer to use the change log we manually write in CHANGELOG.md

Copy link
Member Author

Choose a reason for hiding this comment

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

yes but as per the updated .github/workflows/README.md instructions; it only creates a --draft release. Manual copyediting & approval of said draft is always required to make it public.

Copy link
Collaborator

Choose a reason for hiding this comment

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

So the concept here is that we use git log to create the draft of the release text, taking from the commit messages. This text accompanies a GitHub draft release and will then be manually edited once we make the actual release.

I like the automation, however I feel that the release text is related to a GitHub feature rather than an integral part of the software.

Often I find myself editing the changelog differently than the commit messages. Maybe it is a good practice to write the commit messages better! My real argument against deleting the CHANGELOG.md is that we tend to cluster changes on topic rather than commit.

As I understand it, there will still be the chance to edit the draft text, but how can we find the final text not on GitHub?

Copy link
Member Author

@casperdcl casperdcl Jul 13, 2023

Choose a reason for hiding this comment

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

I like the automation

It's not about automation. Automation is merely a happy bonus side-effect. It's about DRY/SSoT (see full explanation, including bugs I had to manually fix in the old release noted).

I feel that the release text is related to a GitHub feature rather than an integral part of the software.

  1. the GH release text was already being used before this PR
  2. dev metadata (version history) is NOT meant to be an "integral part of software" (that's the whole point of git commits as well as commit messages)
  3. best practice is to put release notes as comments in annotated tags or merge commits if you want them in a place where a dev will find them easily sans GH web interface
  4. release notes should link to relevant issues & PRs (for context & discussion), which is distinctly inherently a GH-only (non-local-codebase) use case.

Often I find myself editing the changelog differently than the commit messages. Maybe it is a good practice to write the commit messages better!

Still possible here. I do the same. The commit messages injected in the draft ensure:

  1. I don't forget to mention something important
  2. I'm embarrassed by poorly-written unfit-for-purpose messages (which I delete), inspiring me to write better in future

My real argument against deleting the CHANGELOG.md is that we tend to cluster changes on topic rather than commit.

  1. that's what merge commits & tags are for, ergo what should be described in merge commit messages & annotated tags
  2. the changelog was mirrored in two places, I'm simply proposing we delete one of those places

As I understand it, there will still be the chance to edit the draft text, but how can we find the final text not on GitHub?

Annotated tags & (merge) commit messages.

Finally, overall harsh truth:

  • high-level end users: only look at web material (PyPI, GH Readme, GH releases)
  • devs: only look at git commits & git blame
  • nobody: wants changelog file checked out in-repo

I really believe there is zero frustration if changelog.txt simply links to GH releases.

Copy link
Member Author

@casperdcl casperdcl Jul 17, 2023

Choose a reason for hiding this comment

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

@paskino as discussed, I've now updated all git tags to have annotations containing the release notes.

You can git fetch --tags -f to get the updated annotations. To view a changelog without an internet connection1:

git config --global alias.changelog 'for-each-ref --sort=-*authordate --format="# %(contents:subject)%0a%(contents:body)" refs/tags'

git changelog

next step is to https://github.com/paskino/qt-elements/transfer to @TomographicImaging

Footnotes

  1. https://stackoverflow.com/questions/69765351/list-all-git-tags-with-their-annotations

Copy link
Member Author

@casperdcl casperdcl Jul 17, 2023

Choose a reason for hiding this comment

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

added instructions & tests for annotated tags: 4e918e6

test/dialog_example_2_test.py Show resolved Hide resolved
test/test_MainWindowWithSessionManagement.py Show resolved Hide resolved
pyproject.toml Show resolved Hide resolved
Copy link
Collaborator

@paskino paskino left a comment

Choose a reason for hiding this comment

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

It looks great. Please keep the changelog as it is a file which belongs to the repository.

I'd like to understand how to use pytest in the future.

runs-on: ubuntu-latest
strategy:
matrix:
python: [3.7, 3.11]
Copy link
Collaborator

Choose a reason for hiding this comment

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

will the binaries built be only available for Python 3.7 and 3.11? In such a case, I'd like to be sure that these are available for all Python versions compatible with CIL, which are from 3.8 to 3.10!

Copy link
Member Author

Choose a reason for hiding this comment

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

No, binaries are built for all python versions. CI unit tests are only run for min & max supported versions.

Comment on lines 42 to 44
changelog=$(git log --pretty='format:%d%n- %s%n%b---' $(git tag --sort=v:refname | tail -n2 | head -n1)..HEAD)
tag="${GITHUB_REF#refs/tags/}"
gh release create --title "Version $tag" --draft --notes "$changelog" "$tag" dist/${{ steps.dist.outputs.whl }} dist/${{ steps.dist.outputs.targz }}
Copy link
Collaborator

Choose a reason for hiding this comment

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

So the concept here is that we use git log to create the draft of the release text, taking from the commit messages. This text accompanies a GitHub draft release and will then be manually edited once we make the actual release.

I like the automation, however I feel that the release text is related to a GitHub feature rather than an integral part of the software.

Often I find myself editing the changelog differently than the commit messages. Maybe it is a good practice to write the commit messages better! My real argument against deleting the CHANGELOG.md is that we tend to cluster changes on topic rather than commit.

As I understand it, there will still be the chance to edit the draft text, but how can we find the final text not on GitHub?

@@ -82,8 +72,7 @@ def rejected(self):

class DialogTest(unittest.TestCase):
'''Test the margarita mixer GUI'''

@unittest.skipIf(skip_as_conda_build, "On conda builds do not do any test with interfaces")
@skip_ci
Copy link
Collaborator

Choose a reason for hiding this comment

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

How does a decorator work?

Copy link
Member Author

Choose a reason for hiding this comment

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

It was a decorator before too - I just tidied it up so the condition & message aren't repeated a hundred times in the code.

README.md Outdated Show resolved Hide resolved
@casperdcl casperdcl merged commit ade2a2d into main Jul 19, 2023
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Can we delete the conda_build_config file?
3 participants