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

Revamp schema versioning and dev version trigger #393

Merged
merged 5 commits into from
Sep 12, 2024

Conversation

joanise
Copy link
Collaborator

@joanise joanise commented Aug 26, 2024

PR Goal?

Clean up how schemas a generated and unit tested

Fixes?

Fixes #392

Also fixes the chicken and egg problem when we start working on the next minor: since the setuptools_scm uses tags to determine the current version, you'd have to tag 2.2.0 if the current is 2.1.0 before it would install with the right version, but that's not right since 2.2.0 would not have been published yet. But, in fact, the solution is simple:

  • when we start 2.2.0, tag 2.2.0.dev0
  • prevent pythonpublish.yml from actually publishing that to PyPI, since it's just dev (this PR does that with 65499d6)
  • so ongoing work will now except the schema at 2.2, but the current published version will still be 2.1.x

Feedback sought?

general validation

@roedoejet make sure the schema logic is good
@dhdaines confirm my interpretation of dev tagging with dynamic versioning

Priority?

low

Tests added?

yup, loads!

How to test?

Run g2p update-schema with the current schema being up to date, wrong, a new version without change, a new version with change (unit testing covers all these cases).

Confidence?

moderate

Version change?

No, but will make the next change cleaner.

@joanise joanise requested review from dhdaines and roedoejet August 26, 2024 16:50
Copy link
Contributor

github-actions bot commented Aug 26, 2024

CLI load time: 0:00.05
Pull Request HEAD: 208a8e0e695550e20b92eed8b7f032de9e26e213
Imports that take more than 0.1 s:
import time: self [us] | cumulative | imported package

Copy link

codecov bot commented Aug 26, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 93.54%. Comparing base (54d4e18) to head (208a8e0).
Report is 6 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #393      +/-   ##
==========================================
+ Coverage   93.50%   93.54%   +0.04%     
==========================================
  Files          18       18              
  Lines        2554     2571      +17     
  Branches      576      579       +3     
==========================================
+ Hits         2388     2405      +17     
  Misses         95       95              
  Partials       71       71              

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

@joanise joanise force-pushed the dev.ej/revamp-schema-versioning branch from a4480e4 to f595744 Compare August 26, 2024 19:59
@joanise
Copy link
Collaborator Author

joanise commented Aug 26, 2024

I added one more thing: make the SCM pretend version thing DRY, and validate it so it stays in sync.

@joanise joanise force-pushed the dev.ej/revamp-schema-versioning branch from f595744 to 257b13b Compare September 12, 2024 16:43
joanise added a commit that referenced this pull request Sep 12, 2024
joanise added a commit that referenced this pull request Sep 12, 2024
joanise added a commit that referenced this pull request Sep 12, 2024
@@ -9,7 +9,6 @@ on:
# This **must** match the Major.Minor version of the JSON schema file
Copy link
Collaborator

Choose a reason for hiding this comment

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

probably should remove this comment :)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Right, yes! :)

@joanise
Copy link
Collaborator Author

joanise commented Sep 12, 2024

CI was failing because pydantic 2.9 changes the schema. :(
Fixed by excluding it, but that's annoying because we're generally compatible with it, it's just an irrelevant change, but which has visible effect on the schema file.

run: |
python -m pip install --upgrade pip
pip install -e .[test]
SETUPTOOLS_SCM_PRETEND_VERSION=`cat .SETUPTOOLS_SCM_PRETEND_VERSION` pip install -e .[test]
Copy link
Collaborator

Choose a reason for hiding this comment

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

$(cat .SETUPTOOLS_SCM_PRETEND_VERSION) may be a bit more portable than using backticks here (though specifying bash is still a good idea so you don't get, say, PowerShell!)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I was going to use $(...), but I decided backticks were a better choice. Now I don't remember why...
Does $(...) work with POSIX Bourne shell? I might have hesitated because of not being sure that would be the case, but maybe that's misguided.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

OK, no, that was misguided, https://stackoverflow.com/questions/22709371/backticks-vs-braces-in-bash says $() is POSIX compliant, and backticks are deprecated! I learned something today.

Copy link
Collaborator

Choose a reason for hiding this comment

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

yeah the nice thing about $() is that it nests, e.g.

echo $(echo $(echo foo) $(echo bar))

print(
dedent(
f"""
Schema {schema_path}
Copy link
Collaborator

@dhdaines dhdaines Sep 12, 2024

Choose a reason for hiding this comment

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

these line lengths are rather long!

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Adjusted a bit, but they're sized to look decent after dedenting, so they're going to stay somewhat long.
I agree they were too long, though, so I adjusted them somewhat.

def test_update_schema(self):
# It's an error for the currently saved schema to be out of date
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'll just assume all of this works!

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It works too well, killed CI when it ran with Pydantic 2.9.1... :(

Copy link
Collaborator

@dhdaines dhdaines left a comment

Choose a reason for hiding this comment

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

Ugh, I am not very awake, I clickd "add single comment" when I meant to click "start a review. Sorry about that. This all looks good to me, assuming it passes tests and coverage.

@joanise joanise force-pushed the dev.ej/revamp-schema-versioning branch from 92b037c to c75ffa9 Compare September 12, 2024 18:24
squashed with
  test: exercise the modified g2p update-schema logic
We had forgotten to bump the heroku pretend version from 2.0 to 2.1.
This is going to happen again and again, so let's put a stop to it all
now!

The new file .SETUPTOOLS_SCM_PRETEND_VERSION has the pretend version
we'll use anywhere we have to do these fake mechanics, with the current
major.minor, and we'll make it an error in unit testing if it's out of
sync.

When we start working a the next major or minor version, we'll need that
dev tag for all this to work, which is good because this way we won't
forget! And if we try to put the new major or minor version and didn't
do it, it'll fail to run the tests.
@joanise joanise force-pushed the dev.ej/revamp-schema-versioning branch from c75ffa9 to 208a8e0 Compare September 12, 2024 18:50
@joanise joanise merged commit 5631210 into main Sep 12, 2024
8 checks passed
@joanise joanise deleted the dev.ej/revamp-schema-versioning branch September 12, 2024 18:56
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.

Revamp the schema update tests
2 participants