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
mkhtml: Generate local JSON file with core modules and their last commit #2140
mkhtml: Generate local JSON file with core modules and their last commit #2140
Conversation
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 need to look at this more, but it seems that something like this is the only way to get all the info from Git. I assume others already looked into bending Git to be more like Subversion and that didn't work. I would still ask though, why is carrying this generated file in the code necessary?
As for the implementation, the automatic commit won't work well here as far as I can tell. Doing on the PR branch will record wrong commit hashes. Doing it on the main branch will result in doubling the amount of commits as every commit (merge) will require another commit as an update for this file. (And also disabling some of the mandatory checks may be needed to make it work.)
I came up with two scenarios which could work:
- Make the workflow a dispatch workflow (or whatever these are called) so that it is called manually. Part of the release procedure would be to trigger this workflow, it would create a PR against the release branch (or commit, but PR sounds safer!). This is closer to your current proposal, than the other option.
- Make the generated file a GitHub Actions artifact (possible for all commits on all branches) and let people download it from GitHub when needed or, for convenience, upload it somewhere from GitHub actions (using scp or FTP). This could be part of creating the release tarball. Requires more manual work, but doesn't require to have the generated file in the source code.
a768d3c
to
29a7e7c
Compare
Auto commit has some limitation but in our case Git repository allow Squash and Merge and if this GitHub action is allowed on the only main branch, it is work as expected (update this JSON file is triggered on push to main branch and one auto commit is pushed). I tested it on my test repository and it worked as expected. |
Tested with 7.8.7 release branch and it work properly
|
Yes you are right it is not necessary.
I decided to implement this procedure. The resulting GitHub workflow pgms-with-last-commit-patch-file artifact will create a pgms_with_last_commit.patch (new pgms_with_last_commit.json file) that will be downloadable as zip file for the GRASS GIS GNU/Linux distribution maintainer and applicable as a patch in its package build process. |
@neteler, I think we should include this PR in the next release 8.0.1 and 7.8.7 and solve GitHub REST API rate limit completely (which means every core module manual page will have commit and commit date, when GRASS GIS is compile from release archive which doesn't have Git). The generated |
…mmit For every pushed commit GitHub Generate PGMS last commit JSON file action worflow update "pgms_with_last_commit.json" file (auto commit), which contains all PGMS (core modules) with last commit. JSON file data structure: {"pgm": {"commit": "git log -1 PGM src dir"}, ...} During compilation source code without .git dir, this local file "pgms_with_last_commit.json" is used instead of getting Git commit from remote GitHub API server.
This reverts commit 29a7e7c.
… last commit" This reverts commit a3f56c0.
…mmit For every pushed commit GitHub 'Generate PGMS last commit JSON file action worflow artifact' create "pgms_with_last_commit.patch" patch file, which contains all PGMS (core modules) with last commit. Which is donwloadable from GitHub actions workflows page as pgms-with-last-commit-patch-file.zip file. JSON file data structure: {"pgm": {"commit": "git log -1 PGM src dir"}, ...} During compilation source code without .git dir, this local file "pgms_with_last_commit.json" is used instead of getting Git commit from remote GitHub API server.
Thanks for your work on this PR! I am a bit undecided if 8.0.1 and 7.8.7 or better 8.0.2 and 7.8.8? If the former, then we will need a longer test phase (I just published 8.0.1RC1 yesterday, see grass-dev mailing list). I suggest to discuss it on grass-dev to reach more people. |
…mmit For every pushed commit GitHub Generate PGMs last commit JSON file action worflow generate "pgms_with_last_commit.json" file (pgms-with-last-commit-patch-file artifact that will be downloadable as zip file), which contains all PGMs (core modules) with last commit. JSON file data structure: {"PGM": {"commit": "git log -1 PGM src dir"}, ...} During compilation source code without .git dir, this local file "pgms_with_last_commit.json" is used instead of getting Git commit from remote GitHub API REST server.
718c945
to
fc46089
Compare
I would prefer 7.8.7 and 8.0.1 |
I prefer after 7.8.7 and 8.0.1 or later. This is not even reviewed, while 8.0.1 is ready to go. Let's not backport large or invasive changes and let's not backport quickly or right before a release. As far as I'm concerned, this can sit on the main branch all the way to 8.2.0. Date in a man page is not important enough to risk breaking compilation on a release branch. |
I will try to explain in more detail what other consequences the exceeded GitHub REST API rate limit has during compilation, which is reported in the issue #2186, and that is why I suggest integrating it into 8.0.1 and 7.8.7 as soon as possible after thorough testing:
As already mentioned, the main problem is that we are depend on proprietary GitHub REST API (g.extension module) which has limitation and who has control over us, not we over him.
It is just a sugestion that explains in much more detail why it will be good to implement these changes as soon as possible. Code changes with this PR:
Code changes with PR #2193:
|
Please see my comments on #2193 |
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.
OK. I invstigated the possibility to deploy to a gist to circumvent the API (content could be downloaded as raw file directly), but only users seem to be able to own gists (not organizations (here osgeo) and repos (grass)...
So, I guess artifacts are the best option if we do not publish the JSON file other places (which would have other drawbacks).
Another question is if we could find a mechanism where the JSON file is attempted to be downloaded only once (i.e. at start of compilation) or if it has been updated since the last download or lder than e.g one hour.
That said, this PR definately improves the current situation.
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.
This seems like a step in the right direction if we want to harvest all the information from Git.
If I remember correctly, GitHub artifacts don't have predictable URLs. Any plans for that? We could upload somewhere from GitHub Actions using something like FTP/SCP and secrets.
I would like to see this running on PRs as well for testing purposes, esp., for cases when you make change here. The additional_checks.yml workflow/job is meant for random things like this, so you could add the generator script there with some check of the JSON content.
utils/mkhtml.py
Outdated
commit[0]["commit"]["author"]["date"], | ||
"%Y-%m-%dT%H:%M:%SZ", | ||
).strftime(datetime_format) | ||
if gs: |
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.
The whole "can't import grass.script therefore I'm compiling" is shaky, but perhaps good enough for this PR.
Right, I think everyone agrees with that. My point is that there is no reason to have anything like that in the source code in the first place when it brings no benefit and since the code as is doesn't work, we can just drop it and, in some cases, live with some missing metadata in manual pages for 7.8 and 8.0. For 8.2, we can see how this PR works. |
I assumed that this one manual step would be enough. When we want make new release (source code without Git), person which make this release via GitHub page, first download |
The release procedure is already a lot of work. We should be working towards minimizing the steps and automating ideally everything.
The GitHub page says you can include binary files...in the binaries box. I don' see anything about combining that with the tarball. However, the download links in a release are stable and it seems you can upload to release from GitHub actions (softprops/action-gh-release, svenstaro/upload-release-action, JasonEtco/upload-to-release, ...). |
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.
The release draft action is a great improvement. I'm not sure about the actions/create-release part since it is kind of buried in the context of this PR. The actions/upload-release-asset is more clear, but the this specific action is not maintained (of the ones I linked is a suggested replacement). Would you consider splitting the PR?
I still think something the like python utils/generate_core_modules_with_last_commit_json_file.py .
should run also in additional_checks.yaml with some subsequent check (like load to Python and check basic structure or one of the values).
Thanks for the rename. Perhaps the new one is little too long? generate_last_commit_file.py
gets most of the important things in.
…capture_output param" This reverts commit 3f61f88. capture_output parmeter is supported by Python version >= 3.8
Ok. I opened new PR #2224.
Ok. I created pytest file
Yes, I agree with you. I have included all your previous suggestions. |
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.
Getting there. Awesome example of full pytest usage.
I also integrated the remaining suggestions. |
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'm not sure about the use of UNIX timestamp instead of a readable date and use of sophisticated pytest with depends on an external state, but I think this can be merged.
I don't know where documentation should go, esp. in context of #2224 (automated upload to release draft).
All right, I'll change to the readable date format ISO 8601. |
This is in 8.2 branch and it is not a general backport material (so no 8.0 which has another fix), so removing the label. |
… last commit (OSGeo#2140) For every new pushed repository branch Git tag e.g. `git tag -a 8.2.0 -m "Release 8.2.0"` and `git push origin 8.2.0` is automatically with GitHub "Create new release draft" action workflow created new release draft which include downloadable core_modules_with_last_commit.json and core_modules_with_last_commit.patch file. During compilation source code without .git dir, this local file is used instead of getting Git commit from remote GitHub API REST server. JSON file data structure: "r.pack": { "commit": "547ff44e6aecfb4c9cbf6a4717fc14e521bec0be", "date": "2022-02-03T11:10:06+01:00" }, commit key value is commit hash date key value is author date (strict ISO 8601 date time format)
… last commit (OSGeo#2140) For every new pushed repository branch Git tag e.g. `git tag -a 8.2.0 -m "Release 8.2.0"` and `git push origin 8.2.0` is automatically with GitHub "Create new release draft" action workflow created new release draft which include downloadable core_modules_with_last_commit.json and core_modules_with_last_commit.patch file. During compilation source code without .git dir, this local file is used instead of getting Git commit from remote GitHub API REST server. JSON file data structure: "r.pack": { "commit": "547ff44e6aecfb4c9cbf6a4717fc14e521bec0be", "date": "2022-02-03T11:10:06+01:00" }, commit key value is commit hash date key value is author date (strict ISO 8601 date time format)
Backport of #2550 to G78, fixing Python 3.11 error after deprecation. * fix #2538 * Use getencoding() where only encoding is needed; getlocale() otherwise Additional changes: - sync of `tools/mkhtml.py` with `main` branch - selected backport from #2140 to get `utils/generate_last_commit_file.py` - selective sync of `lib/init/grass.py`
… last commit (OSGeo#2140) For every new pushed repository branch Git tag e.g. `git tag -a 8.2.0 -m "Release 8.2.0"` and `git push origin 8.2.0` is automatically with GitHub "Create new release draft" action workflow created new release draft which include downloadable core_modules_with_last_commit.json and core_modules_with_last_commit.patch file. During compilation source code without .git dir, this local file is used instead of getting Git commit from remote GitHub API REST server. JSON file data structure: "r.pack": { "commit": "547ff44e6aecfb4c9cbf6a4717fc14e521bec0be", "date": "2022-02-03T11:10:06+01:00" }, commit key value is commit hash date key value is author date (strict ISO 8601 date time format)
In the context of creating and using a core_modules_with_last_commit.json file after creating and submitting a new release tag to remote repository e.g.
git tag -a 8.2.0 -m "Release 8.2.0"
andgit push origin 8.2.0
a new draft is automatically created with GitHub action workflow "Create new release draft" #2224 with attached two files core_modules_with_last_commit.json and core_modules_with_last_commit.patch.JSON file data structure:
During compilation source code without .git dir, this local file "core_modules_with_last_commit.json" is used instead of getting Git commits from remote GitHub API server.