Skip to content

Conversation

@kaste
Copy link
Contributor

@kaste kaste commented Nov 5, 2025

Implements a Github action. Refer gh_action/README.md for its usage. But in a nutshell you just do

$ gh_action/action.sh --pr https://github.com/wbond/package_control_channel/pull/9236

Ref packagecontrol/thecrawl#66
Ref packagecontrol/thecrawl#166

@kaste
Copy link
Contributor Author

kaste commented Nov 5, 2025

Very verbose output.

$ gh_action/action.sh --pr https://github.com/wbond/package_control_channel/pull/9236
Resolving PR metadata via gh: https://github.com/wbond/package_control_channel/pull/9236
Base URL:   https://raw.githubusercontent.com/wbond/package_control_channel/f66915f42e9918b98117a291ff62e158cf33aba9/repository.json
Target URL: https://raw.githubusercontent.com/wbond/package_control_channel/60b6bf1a23b2554ac1da363c8908a3a0f40a88b5/repository.json
Using thecrawl at: /c/Users/c-flo/Desktop/st_package_reviewer/.thecrawl
Generating base registry…
Fetching registered packages...
Found 4672 packages and 91 dependencies in 1 repositories.
Prepared packages in 0.47 seconds.
Saved registry as C:\Users\c-flo\AppData\Local\Temp\tmp.SdCldtscb4\base_registry.json
Generating target registry…
Fetching registered packages...
Found 4673 packages and 91 dependencies in 1 repositories.
Prepared packages in 0.46 seconds.
Saved registry as C:\Users\c-flo\AppData\Local\Temp\tmp.SdCldtscb4\head_registry.json
Removed (none)
Changed (none)
Added JenkinsDoc
Crawling 1 package(s) from target registry…
- Crawling: JenkinsDoc
Note: BITBUCKET_TOKEN environment variable is not set. Running anonymously.
Note: GITLAB_TOKEN environment variable is not set. Running anonymously.
Note: CODEBERG_TOKEN environment variable is not set. Running anonymously.
{
  "id": "R_kgDON01wzw",
  "name": "JenkinsDoc",
  "description": "Jenkins Pipeline documentation and autocompletion plugin for Sublime Text",
  "author": "Tsahi Elkayam",
  "readme": "https://raw.githubusercontent.com/Tsahi-Elkayam/JenkinsDoc/main/README.md",
  "donate": "https://github.com/Tsahi-Elkayam",
  "default_branch": "main",
  "created_at": "2025-02-05 15:48:51",
  "details": "https://github.com/Tsahi-Elkayam/JenkinsDoc",
  "releases": [
    {
      "sublime_text": ">=3000",
      "platforms": [
        "*"
      ],
      "base": "https://github.com/Tsahi-Elkayam/JenkinsDoc",
      "date": "2025-10-24 12:59:03",
      "url": "https://codeload.github.com/Tsahi-Elkayam/JenkinsDoc/zip/v1.0.0",
      "version": "1.0.0"
    }
  ],
  "homepage": "https://github.com/Tsahi-Elkayam/JenkinsDoc",
  "labels": [
    "snippets",
    "completions",
    "auto-complete",
    "utilities"
  ],
  "source": "https://raw.githubusercontent.com/wbond/package_control_channel/60b6bf1a23b2554ac1da363c8908a3a0f40a88b5/repository.json",
  "schema_version": "3.0.0",
  "first_seen": "2025-11-05 16:55:57",
  "last_seen": "2025-11-05 16:55:57",
  "last_modified": "2025-10-24 12:59:03",
  "next_crawl": "2025-11-05 17:55:57"
}
---
1 packages in db.
GitHub {'limit': 5000, 'remaining': 4974, 'used': 26, 'reset': 1762363818, 'reset_formatted': '2025-11-05 18:30:18', 'resource': 'graphql'}
: https://codeload.github.com/Tsahi-Elkayam/JenkinsDoc/zip/v1.0.0
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 2833k    0 2833k    0     0  2588k      0 --:--:--  0:00:01 --:--:-- 2592k
  Unpacking…
  Reviewing with st_package_reviewer: /tmp/tmp.SdCldtscb4/review/JenkinsDoc/1.0.0/JenkinsDoc-1.0.0
Package path: C:\Users\c-flo\AppData\Local\Temp\tmp.SdCldtscb4\review\JenkinsDoc\1.0.0\JenkinsDoc-1.0.0

## Report for JenkinsDoc-1.0.0 ########################

No failures

Reporting 1 warnings:
- Found multiple command prefixes: Jenkins, Open. Consider using one single prefix so as to not clutter the command namespace.


For more details on the report messages (for example how to resolve them), go to:
https://github.com/packagecontrol/st_package_reviewer/wiki

Completed crawling successfully.

@braver
Copy link
Member

braver commented Nov 5, 2025

Awesome.

How about output formats? Current the report is in a format that would works as a comment on the PR. In packagecontrol/st-package-reviewer-action#5 I've made it output in the message format that GitHub can use to present annotations on the PR. Example:

Scherm­afbeelding 2025-11-05 om 20 51 34

Since we're here we might be able to change the output format at the root of the reviewer script instead of transforming it later?

@kaste
Copy link
Contributor Author

kaste commented Nov 5, 2025

That was not in the plan. But if you already, just recently, patched the reviewer you likely remember the code path. (?) For the action.sh here ... should that be in Python to make something like that easier? Let's just look at the function signature, what we have is report(msg, kind: error|notice|warning, title) (add **kwargs if that matters but you only use these) and then we print echo "::kind title=title::msg".

If the reviewer output is stable, we could read

Reporting 1 warnings:
- Found multiple command prefixes: Jenkins, Open. Consider using one single prefix so as to not clutter the command namespace.

and transform it to

echo ::warning ::Found multiple command prefixes:...

What would be the title? How does the typical output look like? "Reporting 3 errors..."

Maybe that's easier if we just do it here. Formatters are applied as late as possible so that we get a good look on CLI and on CI.

@michaelblyons
Copy link

michaelblyons commented Nov 5, 2025

I have this (possibly bad) idea wherein you use a basic logger for CLI running and an alternative GitHub logger for the Action output.

I don't really want to push back release, though. Happy to file a discussion or issue later. 🙂

@kaste
Copy link
Contributor Author

kaste commented Nov 5, 2025

It depends on what we have to support. It is enterprisy if

diff --git a/gh_action/action.sh b/gh_action/action.sh
index 8f235c8..9d70159 100644
--- a/gh_action/action.sh
+++ b/gh_action/action.sh
@@ -259,7 +259,17 @@ PY
     fi
 
     echo "  Reviewing with st_package_reviewer: $topdir" >&2
-    if ! uv run st_package_reviewer "$topdir"; then
+    if ! uv run st_package_reviewer "$topdir" | awk '
+      /^Reporting [0-9]+ errors:/   { mode = "error";   next }
+      /^Reporting [0-9]+ warnings:/ { mode = "warning"; next }
+      /^- / && mode {
+        sub(/^- /, "");
+        print "::" mode "::" $0;
+        next;
+      }
+      { mode = ""; print }
+    ';
+    then
       echo "  ! Review failed for $pkg@$disp_ver" >&2
       failures=$((failures+1))
       continue

would suffice.

That prints

...
## Report for JenkinsDoc-1.0.0 ########################

No failures

::warning::Found multiple command prefixes: Jenkins, Open. Consider using one single prefix so as to not clutter the command namespace.


For more details on the report messages (for example how to resolve them), go to:
https://github.com/packagecontrol/st_package_reviewer/wiki

Completed crawling successfully.

Maybe we're lucky and that's enough.

@braver
Copy link
Member

braver commented Nov 6, 2025

you likely remember the code path

Sort of... 😅 But I changed the action script mostly, not the reviewer script, most of it in packagecontrol/st-package-reviewer-action@90d487d

What would be the title

The title isn't super relevant. In various contexts it's not even used and overwritten with something else by GitHub. So the message is the important bit. I went for very short PASS/FAIL/WARN like titles.

How does the typical output look like?

On the action tab in a PR you'll see callouts for the number of messages:
https://github.com/wbond/package_control_channel/pull/9239/checks

Scherm­afbeelding 2025-11-06 om 08 09 42

If you look at an individual action you'll see:

Scherm­afbeelding 2025-11-06 om 08 10 34

In other words, you don't need to dive into the job output to find information in all the logs, it picks out the lines that have the right format and presents them separately.

On the PR conversation tab you don't see anything (assuming the jobs pass) sadly. So warnings are mostly just there for those who dig a bit deeper, and they're there for the reviewer (ie. me). But it does also make errors easier to find.

@kaste
Copy link
Contributor Author

kaste commented Nov 6, 2025

Ok. These annotations look nice. I added log groups and annotations logging.

@braver
Copy link
Member

braver commented Nov 8, 2025

I'm having some issues running this locally:

~/c/st_package_reviewer ((2e538bc8)|1) [127]$ ./gh_action/action.sh --pr https://github.com/wbond/package_control_channel/pull/9239
::group::Fetching PR metadata
Resolving PR metadata via gh: https://github.com/wbond/package_control_channel/pull/9239
Base URL:   https://raw.githubusercontent.com/wbond/package_control_channel/2e840eafa99c823f533a32d228693f1570bdde96/repository.json
Target URL: https://raw.githubusercontent.com/wbond/package_control_channel/8c3a9430c0254ef62221dc173d8fb70de3fbb229/repository.json
::endgroup::
::group::Getting thecrawl
Using thecrawl at: /Users/koenlageveen/code/st_package_reviewer/.thecrawl
::endgroup::
::group::Generating base registry…
Fetching registered packages...
Found 4671 packages and 91 dependencies in 1 repositories.
Prepared packages in 0.31 seconds.
Saved registry as /var/folders/_g/g4s658wd54v2g9grfrfwcydw0000gn/T/tmp.LvmXKGAuab/base_registry.json
::endgroup::
::group::Generating target registry…
Fetching registered packages...
Found 4672 packages and 91 dependencies in 1 repositories.
Prepared packages in 0.46 seconds.
Saved registry as /var/folders/_g/g4s658wd54v2g9grfrfwcydw0000gn/T/tmp.LvmXKGAuab/head_registry.json
::endgroup::
./gh_action/action.sh: line 181: mapfile: command not found
Traceback (most recent call last):
  File "/Users/koenlageveen/code/st_package_reviewer/gh_action/diff_repository.py", line 145, in <module>
    sys.exit(main())
  File "/Users/koenlageveen/code/st_package_reviewer/gh_action/diff_repository.py", line 29, in main
    with open(args.base_file, 'r', encoding='utf-8') as f:
FileNotFoundError: [Errno 2] No such file or directory: '/var/folders/_g/g4s658wd54v2g9grfrfwcydw0000gn/T/tmp.LvmXKGAuab/base_registry.json'

@kaste
Copy link
Contributor Author

kaste commented Nov 8, 2025

mapfile: command not found

Easiest would be if you update your Bash which you maybe never did. (T.i. you would run stock bash.) Otherwise I need to implement a loop here.

@braver
Copy link
Member

braver commented Nov 8, 2025

I think I'm just at stock MacOS bash (GNU bash, version 3.2.57(1)-release (arm64-apple-darwin25)). I can upgrade via homebrew.
Maybe it would be more portable to use python over shell scripts as much as possible?

@kaste
Copy link
Contributor Author

kaste commented Nov 8, 2025

I refactored to not use mapfile which I think is the only things requiring Bash4. How can you a justify a Python rewrite?

@braver
Copy link
Member

braver commented Nov 8, 2025

Looks like that worked indeed. I was worried for a second... bash can at times be annoyingly less portable than one hopes for. I'm really out of bash scripting, haven't done anything serious in it for like 7 years+ and am not going to pretend I understand halve of what goes on in action.sh 😅 For the same reason, I can test this in practice, but I'm not in a position (knowledge or experience wise) to review the PR.

But this is great 👍🏻 It's a clean interface for the action and output on the CLI looks good. I did have to set the executable bit on action.sh. Maybe you want to do that and check that in?

So, what do you want to do? I can start using this for PRs on the main package_control_channel and get some real world usage feedback. I can do that right now based on HEAD of your fork. Or should I wait for this PR to get reviewed?

@kaste
Copy link
Contributor Author

kaste commented Nov 8, 2025

I thought you just use it. (This is actually re-usable I think. So it could be used in SL or LSP channel repositories.)

Likely we need output tuning for the annotations etc.

No-one reviews such plumbing scripts tbh. It is just 300 lines anyway (but I made a patch in thecrawl for example to make it work. One needs that knowledge for the inter-op.)

@kaste
Copy link
Contributor Author

kaste commented Nov 8, 2025

If we also require curl and unzip as deps we could remove some lines.

@braver
Copy link
Member

braver commented Nov 8, 2025

Using curl and unzip are fine by me. I imagine they're available on ubuntu-latest as well.

@braver
Copy link
Member

braver commented Nov 16, 2025

Alright, finally got a test setup. This PR adds the new reviewer action next to the existing one. I've then replicated the change from wbond/package_control_channel#9235 on top of that so we can compare the output.

I'm running into an error I don't understand though, see https://github.com/wbond/package_control_channel/actions/runs/19407178504/job/55523567264?pr=9246.

error: Failed to spawn: `st_package_reviewer`
  Caused by: No such file or directory (os error 2)

A quick Google says "failed to spawn" is an error from uv, but no easy answers as to what to do about it.

@kaste
Copy link
Contributor Author

kaste commented Nov 16, 2025

Try again with baec27a.

@braver
Copy link
Member

braver commented Nov 16, 2025

Got a step further. Looks like the virtual environment isn't what it should be?

https://github.com/wbond/package_control_channel/actions/runs/19411270967/job/55532991089?pr=9246

Scherm­afbeelding 2025-11-16 om 21 06 18

...

      Make sure you're either building from a fully intact git repository
      or PyPI tarballs. Most other sources (such as GitHub's tarballs, a git
      checkout without the .git folder) don't contain the necessary metadata
      and will not work.

      For example, if you're using pip, instead of
      https://github.com/user/proj/archive/master.zip use
      git+https://github.com/user/proj.git#egg=proj

      Alternatively, set the version with the environment variable
      SETUPTOOLS_SCM_PRETEND_VERSION_FOR_${NORMALIZED_DIST_NAME} as described
      in https://setuptools-scm.readthedocs.io/en/latest/config/

      hint: This usually indicates a problem with the package or the build
      environment.

@kaste
Copy link
Contributor Author

kaste commented Nov 17, 2025

The Github action environment isn't what I thought it to be. But also impossible to have that in your head tbh.

Just try again. 780217d

@braver
Copy link
Member

braver commented Nov 17, 2025

Got it, works 🎉

https://github.com/wbond/package_control_channel/actions/runs/19437333329/job/55611547454

We're however missing annotations for the actual failures. It reports "Completed with 1 failure(s)" whereas the old one reports "messages folder exists, but messages.json does not", which is information you now have to go find in the logs (it's there though). So that's still an open todo here.

@kaste
Copy link
Contributor Author

kaste commented Nov 17, 2025

Hm. It is reporting "Reporting 1 failures:", I was expecting "Reporting 1 errors:". I think you can reference the branch actually instead of the exact commit hash.

@braver
Copy link
Member

braver commented Nov 18, 2025

I think you can reference the branch actually instead of the exact commit hash.

Sure, but bumping the hash gives a bit more control.

Do you think it's possible to report the individual errors? Since I did that on the old implementation I can also give it a go if you want?

@kaste
Copy link
Contributor Author

kaste commented Nov 19, 2025

You say the awk script collates all failures into one message? Maybe you can patch the script to your liking. I neither know what the reviewer actually emits nor what you had before tbh. Ideally we collate the reviewers output and post it as PR comment. Likely wbond doesn't have the secrets stored here in the repo but at home on his laptop. 🤔

You can also post example output from the reviewer and how that should be formatted/transformed. 🤷‍♀️

@braver
Copy link
Member

braver commented Nov 19, 2025

at home on his laptop

He doesn't even have a laptop though.

I'm going to dig into the script, see what's what. Ideally it can do both a collated comment, and streaming annotations. Maybe the thing to do is let the awk script do it's thing, but add a "verbose" option to the reviewer itself that let's it print anything it finds immediately.

@kaste
Copy link
Contributor Author

kaste commented Nov 20, 2025

He doesn't even have a laptop though.

LOL, a modern form of, we all stand naked before God.

@FichteFoll
Copy link
Member

FichteFoll commented Nov 21, 2025

Just a heads-up, since I've been looking at some GitHub notifications today: I won't merge this. Not because I don't like your changes per se but because I believe this to belong into https://github.com/packagecontrol/st-package-reviewer-action.

The package reviewer itself (this repo) is intended to be a standalone Python application, much like a linter that can lint ST packages. It should produce readable output for both humans and machines (the latter is not exactly considered currently because of the way output is structured) and can then be used by developers locally, in CI for an individual package, or for the more complex operation that is reviewing Package Control Channel additions. However, the logic of the latter should not bleed into this repo.

Edit: Forgot to mention that I didn't look at the changes in detail and also probably won't for the next couple weeks.

@kaste kaste force-pushed the gh-action branch 3 times, most recently from caf22ef to ee0516e Compare November 26, 2025 09:37
@FichteFoll
Copy link
Member

FYI, I'm marking this as a draft to indicate that it is not ready for merge (and will never be), but feel free to continue pushing commits here and to mention me for questions.

@FichteFoll FichteFoll marked this pull request as draft November 29, 2025 15:24
@kaste kaste closed this Nov 29, 2025
@kaste
Copy link
Contributor Author

kaste commented Nov 29, 2025

To the readers here: The PR here is self-contained and adds a new directory to this
repository. The whole contents of st-package-reviewer-action could be wiped and replaced
with that directory. That would have been a rude PR IMO. I neither have commit access anyway.
And open source without commit access is actually bananas as proven here and everywhere.

The actual maintainers can pull the changes.

I don't think splitting this into two repositories can be justified as it just adds a cross-
dependency between two things that will never get any greater traction and change-througput
anyway. Kind of irrelevant of course, as I'm not the maintainer of that dependency.

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