-
Notifications
You must be signed in to change notification settings - Fork 132
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
Implement git
submodules for specs
#182
base: add-github-workflow
Are you sure you want to change the base?
Implement git
submodules for specs
#182
Conversation
closes #181 |
@anatoly-scherbakov let's give this a try. Can you expand the README in this PR also to explain what the pre-testing steps would include now (i.e. It would be great to simplify testing. Thanks for exploring this idea! |
@BigBlueHat @davidlehn My apologies for the delay; I think I have something to show here now. |
Hey @anatoly-scherbakov, Sorry for the delay here. I continue to feel a bit squeamish about using git submodules. It's not a pattern we typically use in our other implementations, and it's a rarely used (and oft derided...) git feature. I'm also concerned about the overhead of keeping the sha's pinned accurately. However, I did find that the jsonld.js implementation has a nice approach to this same problem using npm run commands: https://github.com/digitalbazaar/jsonld.js/blob/main/package.json#L96-L101 My thought is that we could do something similar here by providing a simple Python script that would run the Would you be up for taking a crack at that? |
@BigBlueHat thank you for your review. I understand the concern but might disagree in certain regards, let me try to elaborate on them. Let's analyze the approach taken at "fetch-json-ld-org-test-suite": "if [ ! -e test-suites/json-ld.org ]; then git clone --depth 1 https://github.com/json-ld/json-ld.org.git test-suites/json-ld.org; fi", What happens if JSON-LD test suite is updated?
I feel these cases can be very annoying and might hurt developer productivity. Update of the spec version is not tied to an explicit human decision, which goes against normal practice for dependencies in many environments.
Git submodules essentially provide the same level of control over the version of dependencies. It is easy to provide a
I'll add it in a moment in another commit. This will upgrade each submodule to its latest version; afterwards, the developer can run tests, make sure everything is 🟢, and submit to CI. As to the popularity of git submodules, — quick search on Github returns a few popular projects relying upon them: Let me know what you think! |
P. S. To address the concern about testing python tests/runtests.py ~/projects/json-ld-api …as documented in |
@anatoly-scherbakov coming back to this again--sorry for the wait. The experience of using the submodules was fine--not much different than the experience of using the approach we took in jsonld.js, so I'm fine with it. @davidlehn unless you're diametrically opposed to this, I'd like to get it merged sooner than later. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Small tweak which isn't a blocker--and could be done later--so approving.
Thanks for the review @BigBlueHat! I am writing an issue about the This might be also related to me being unable to create a PR in this repository which has another PR as its base. |
@@ -0,0 +1,11 @@ | |||
[submodule "specifications/json-ld-api"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These are the specs, but since their sole purpose here is for testing, could this be named test-suites/
? That's what the scripts in jsonld.js use.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for reviewing!
I can rename those. A few things concern me a bit though:
- Each repository we're checking out contains not just tests but the whole specification, which might be confusing and violate the principle of least surprise;
- We will likely add more tests to the
tests
directory which will not be using the specifications, and the existence of bothtests
andtest-suites
will be confusing; - At some point, we might want to use the specifications for other purposes than tests, for instance, to aid documentation generation, or something.
What do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I prefer the specifications/
folder name, as I do hope/expect we'll get more unit tests added to tests/
at some point, and test-suites/
would certainly be confusing.
@@ -0,0 +1,2 @@ | |||
upgrade-submodules: | |||
git submodule update --remote --init --recursive |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How do you remove all the checked out dirs without leaving git thinking there are unstaged changes? Put another way, how do you undo this command?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you want to undo the version upgrade of the submodules, you can do:
git reset --hard
If you've modified the submodules locally, after having them upgraded (for debugging purposes perhaps) then you do:
git submodule foreach git reset --hard
] | ||
|
||
|
||
def default_test_targets() -> List[Path]: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about changing this so it works something like the jsonld.js test runner and checks for the local test suite dir, then for the sibling dir if not found. That allows for alternate workflows.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It didn't consider missing test suites an error before. I'm not sure what should happen for that. Never seemed a problem in practice.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you believe there is a use case for it? Probably the main goal of turning specifications into submodules is to automate the connection to them, standardizing it across the developers' clones of pyld
repo.
Having the specifications cloned into the root directory of the repo, for instance, will require .gitignore
rules (or it's way too easy to commit them, which is likely not what one wants).
We can later add an error message to this function. If the default test locations are used, and if tests are missing, then probably something is wrong. For instance, the developer forgot to check out the submodules. Their tests will be incorrectly green locally, and then, after a push, failing CI will pose an unpleasant surprise.
|
@anatoly-scherbakov Could you also change the commit message with the fancy "+" and one with ellipses, arrow, and math symbol to use simple ASCII? Nicer to use chars people can easily type. Feel free to argue. :-) |
5798f0b
to
440a251
Compare
@davidlehn thanks again for the review! I have applied a few requested changes.
Yes! I feel that less documentation and more automation is for the better :)
Tools like Dependabot, which post notifications about out-of-date dependencies and even create PRs automatically, are often leveraged. I think I can easily imagine a rather simple scheduled GitHub actions workflow that will update the specs submodules every week, run the tests, and create a PR with that upgrade. Do you think we should create an issue for that?
I see. The
No argument here: I just like those fancy Unicode characters, especially putting them into commit messages 🙂 , and have setup my Linux to easily type them, but this is purely a matter of taste. Removed ✅ |
@davidlehn the key thing I'm beginning to appreciate about the submodule approach is that it will provide git stored evidence of what tests were run--based on the sha stored in It should also provide a means to send updates to the submodule repos--though the porcelain for that feels more like plumbing, so some more commands (as you note) would be helpful. |
@anatoly-scherbakov can you take |
@BigBlueHat the previous address was https://github.com/json-ld/normalization/tests. Right now, https://github.com/json-ld/normalization redirects to https://github.com/w3c-ccg/rdf-dataset-canonicalization. Is that the link we should use? |
Co-authored-by: Anatoly Scherbakov <[email protected]>
Co-authored-by: David I. Lehn <[email protected]>
440a251
to
c195dcd
Compare
I've rebased this branch on top of #185. |
This should be the correct location of the old tests suites: So, still needs an updated URL in this (or another) PR. The Sorry I didn't see that earlier! |
Should we replace |
Yeah...I think we need to add |
Alleviate the step of manually downloading specifications for tests to use them. Instead, put specifications into a dedicated directory using Git submodules mechanism.