Skip to content

Conversation

cognifloyd
Copy link
Member

@cognifloyd cognifloyd commented Sep 24, 2025

This PR does several things:

  • The primary focus of the PR is to make it easy for @StackStorm/maintainers to regenerate lockfiles and update legacy requirements files. To do that, this PR:
    • Adds a GHA workflow that maintainers manually trigger. That workflow:
      • runs pants generate-lockfiles with several output processing steps:
        • saves the lockfile diff output
        • converts the lockfile diff into a "terminal screenshot" png that preserves formatting and colors
        • saves the png in an AWS S3 bucket so that we can reference it from GitHub Flavored Markdown
        • makes the diff output (including the png) available in a Job Summary and in either a PR description (when creating a new PR) or in a PR comment (when pushing a commit to an existing PR)
      • runs pants run scripts/lockfiles_to_reqs.py. This is a new script that:
        • replaces running make requirements to update the requirements files
        • copies the locked package versions from the lockfiles into fixed-requirements.txt and test-requirements.txt
        • copies the locked package versions of pip and setuptools into Makefile
        • runs the scripts/fixate-requirements.py logic to update the requirements.txt files
        • this script is more hacky than I would like, but I hope it is temporary
      • commits and pushs the lockfile and requirements file updates
      • creates a new PR if the maintainer requested a new PR
      • adds a PR comment if the maintainer requested updates for an existing PR
    • Cherry-picks 98628cd from pants generate-lockfiles: st2, bandit, black, flake8, pants-plugins, pylint, twine st2sandbox/st2#17
      • That's 6567d3a in this PR
      • The new GHA workflow created the st2sandbox/st2 PRin this workflow run.
      • Be sure to check out the Job summaries in that workflow run, as well as the PR description. (You can also see adding a comment to an existing PR in pants generate-lockfiles: twine st2sandbox/st2#12 (comment)). Plus, I copied the PR description into this PR (and updated it to refer to master branch instead of my st2sandbox branch).
  • I also had to fix a few thing to get CI passing
    • apparently the flat_file backend v0.4.0 was broken. I added logging and an assertion in tools/config_gen.py to ease debugging this issue and hopefully catch errors like this more quickly in the future.
    • Update examples.forloop_parse_github_repos to resolve an issue revealed by typing updates in the latest versions of BeautifulSoup4.
    • Cherry-pick st2client install fixes by @guzzijones from delete queues for integration #6354 that prevent ModuleNotFoundError: No module named 'ply'
    • Constrain the version of pyOpenSSL that is getting installed in CircleCI. pyOpenSSL 25.1.0 is the latest that is compatible with cryptography 43.0.3, which is what lockfiles/st2.lock has. Ultimately, I think we can remove the pyOpenSSL dep as I couldn't find any of our code, or any of our transitive dependencies that actually use it (there are some extras that could require it, but we don't use those extras).

Note

I tested in another repo (st2sandbox/st2), because workflow_dispatch workflows like this have to be on the default branch to use them.

Lockfile Diffs

st2 Lockfile Diff

Terminal screenshot of lockfile diff in color. The text from the image is included below.

Lockfile diff: lockfiles/st2.lock (plain text)
__________________________________________________________________
Lockfile diff: lockfiles/st2.lock [st2]
__________________________________________________________________
==                    Upgraded dependencies                     ==
‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾
  bcrypt                         4.3.0        -->   5.0.0
  beautifulsoup4                 4.13.5       -->   4.14.2
  httplib2                       0.30.0       -->   0.31.0
  psutil                         7.0.0        -->   7.1.0
  pycparser                      2.22         -->   2.23
  pynacl                         1.5.0        -->   1.6.0
  pyyaml                         6.0.2        -->   6.0.3
  simplejson                     3.20.1       -->   3.20.2
  st2-auth-backend-flat-file     0.3.0        -->   0.4.1
  wcwidth                        0.2.13       -->   0.2.14
__________________________________________________________________
==                     Removed dependencies                     ==
‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾
  passlib                        1.7.4


(diff from master)

bandit Lockfile Diff

Terminal screenshot of lockfile diff in color. The text from the image is included below.

Lockfile diff: lockfiles/bandit.lock (plain text)
__________________________________________________________________
Lockfile diff: lockfiles/bandit.lock [bandit]
__________________________________________________________________
==                    Upgraded dependencies                     ==
‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾
  pyyaml                         6.0.2        -->   6.0.3


(diff from master)

black Lockfile Diff

No changes required for lockfiles/black.lock (from master)

flake8 Lockfile Diff

No changes required for lockfiles/flake8.lock (from master)

pants-plugins Lockfile Diff

Terminal screenshot of lockfile diff in color. The text from the image is included below.

Lockfile diff: lockfiles/pants-plugins.lock (plain text)
__________________________________________________________________
Lockfile diff: lockfiles/pants-plugins.lock [pants-plugins]
__________________________________________________________________
==                    Upgraded dependencies                     ==
‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾
  pyparsing                      3.2.3        -->   3.2.5
  pyyaml                         6.0.2        -->   6.0.3


(diff from master)

pylint Lockfile Diff

No changes required for lockfiles/pylint.lock (from master)

twine Lockfile Diff

Terminal screenshot of lockfile diff in color. The text from the image is included below.

Lockfile diff: lockfiles/twine.lock (plain text)
__________________________________________________________________
Lockfile diff: lockfiles/twine.lock [twine]
__________________________________________________________________
==                    Upgraded dependencies                     ==
‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾
  pycparser                      2.22         -->   2.23


(diff from master)

🤖 GitHub Actions Workflow Run

@cognifloyd cognifloyd self-assigned this Sep 24, 2025
@pull-request-size pull-request-size bot added the size/L PR that changes 100-499 lines. Requires some effort to review. label Sep 24, 2025
cognifloyd added a commit to st2sandbox/st2 that referenced this pull request Sep 24, 2025
cognifloyd added a commit to st2sandbox/st2 that referenced this pull request Sep 24, 2025
cognifloyd and others added 8 commits September 30, 2025 20:49
It needs to handle new PR and exiting PR. The existing PR can be from a branch
in a fork or in this repo.
It needs to handle new PR and exiting PR. The existing PR can be from a branch
in a fork or in this repo.
bs4 improved their typing allowing pylint to catch a possible coding error
in this example. Ultimately it would not have been an issue because of the
broad try/except block, but this makes pylint happy. The result set can be
None, so handle that case explicitly.
…pylint, twine

__________________________________________________________________
Lockfile diff: lockfiles/st2.lock [st2]
__________________________________________________________________
==                    Upgraded dependencies                     ==
‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾
  bcrypt                         4.3.0        -->   5.0.0
  beautifulsoup4                 4.13.5       -->   4.14.2
  httplib2                       0.30.0       -->   0.31.0
  psutil                         7.0.0        -->   7.1.0
  pycparser                      2.22         -->   2.23
  pynacl                         1.5.0        -->   1.6.0
  pyyaml                         6.0.2        -->   6.0.3
  simplejson                     3.20.1       -->   3.20.2
  st2-auth-backend-flat-file     0.3.0        -->   0.4.1
  wcwidth                        0.2.13       -->   0.2.14
__________________________________________________________________
==                     Removed dependencies                     ==
‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾
  passlib                        1.7.4

__________________________________________________________________
Lockfile diff: lockfiles/bandit.lock [bandit]
__________________________________________________________________
==                    Upgraded dependencies                     ==
‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾
  pyyaml                         6.0.2        -->   6.0.3

__________________________________________________________________
Lockfile diff: lockfiles/pants-plugins.lock [pants-plugins]
__________________________________________________________________
==                    Upgraded dependencies                     ==
‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾
  pyparsing                      3.2.3        -->   3.2.5
  pyyaml                         6.0.2        -->   6.0.3

__________________________________________________________________
Lockfile diff: lockfiles/twine.lock [twine]
__________________________________________________________________
==                    Upgraded dependencies                     ==
‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾
  pycparser                      2.22         -->   2.23

No changes to lockfiles/black.lock

No changes to lockfiles/flake8.lock

No changes to lockfiles/pylint.lock
Copy link
Member Author

Choose a reason for hiding this comment

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

If you want to run this script, the easiest way is pants run scripts/lockfiles_to_reqs.py

This pulls the locked versions from lockfiles, and replaces the pins in both fixed-requirements.txt and test-requirements.txt with those locked versions. Then it runs the fixate-requirements logic to update the rest of the requirements.txt files.

Comment on lines +114 to +121
lockfile_bytes = strip_comments_from_pex_json_lockfile(
Path(lockfile).read_bytes()
)
pex_lock = json.loads(lockfile_bytes.decode("utf-8"))
locked_requirements = pex_lock["locked_resolves"][0]["locked_requirements"]
locked_reqs_name_version_map = {
req["project_name"]: req["version"] for req in locked_requirements
}
Copy link
Member Author

Choose a reason for hiding this comment

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

This is ugly. It relies on implementation details from pants and pex; details that should normally be opaque to us. I look forward to deleting this script and all of the other legacy requirements machinery at some point.

with:
aws-region: ${{ env.AWS_REGION }}
role-session-name: GitHubActions-${{ github.run_id }}
role-to-assume: arn:aws:iam::${{ env.AWS_ACCOUNT_ID }}:role/GitHubActions@org=${{ github.repository_owner }},repo=${{ github.event.repository.name }}
Copy link
Member Author

Choose a reason for hiding this comment

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

I ended up with this @org=...,repo=... because role names cannot contain / characters.

# the next one adds a line of overline chars to replace the ansi overline
/^== .* ==$/{ # heading text line (the matched line goes in pattern space)
h; # save copy of heading line in "hold" space
s/./‾/g; # make an line of overline chars to replace the heading's ansi underline
Copy link
Member Author

Choose a reason for hiding this comment

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

The (unicode "overline" character) is visible in the github UI when I'm using a desktop browser. And it shows up nicely in git log output on my linux machine. On my android phone, it shows up as a box, so the fonts apparently don't have that character. A line of boxes still basically underlines the previous header line, so was the best I could do with raw unicode chars.

Copy link
Member Author

Choose a reason for hiding this comment

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

The changes in this file should improve debugging when auth backends like flat_file aren't working (eg because the wheel on pypi was broken). This is not strictly related to this PR, but it was something I stumbled over while developing it.

I can split it into a separate PR if needed.

@cognifloyd
Copy link
Member Author

CI is green!

@cognifloyd cognifloyd requested a review from a team October 1, 2025 20:26
@cognifloyd cognifloyd merged commit fcf41e4 into master Oct 1, 2025
117 of 121 checks passed
@cognifloyd cognifloyd deleted the gha-lockfile-regen branch October 1, 2025 20:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
external dependency infrastructure: ci/cd pantsbuild size/XXL PR that changes 1000+ lines. You should absolutely split your PR into several.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants