containerbuildsystem / cachi2

Cachi2 is a CLI tool that pre-fetches your project's dependencies to aid in making your build process network-isolated.
GNU General Public License v3.0
8 stars 26 forks source link

Fix our go.mod version string parser regex pattern #575

Closed eskultety closed 3 months ago

eskultety commented 3 months ago

We currently don't allow prerelease version identifiers (e.g. beta/rc, etc.) and commentaries on the version string line (e.g. go 1.21.0//comment.

This PR mainly fixes a nasty bug where we fell back to picking an older Go version because of ^this which resulted in a very strange error trying to build buildah from git:

2024-05-29 15:48:50,010 INFO Fetching the gomod dependencies at subpath buildah
2024-05-29 15:48:50,011 INFO Fetching the gomod dependencies at the "buildah" directory
2024-05-29 15:48:52,913 INFO go.mod reported versions: '1.20'[go], '-'[toolchain] (cachi2 enforced)
2024-05-29 15:48:52,927 INFO Using Go release: go1.20
2024-05-29 15:48:52,928 INFO Vendoring the gomod dependencies
2024-05-29 15:49:17,954 INFO Retrieving the list of packages
2024-05-29 15:49:23,014 ERROR RuntimeError: Package parent module was not found
Traceback (most recent call last):

even though buildah uses 1.21 already. This PR also updates some unit tests and adds debug logs to keep better track of dealing with version string parsing.

Maintainers will complete the following section

Note: if the contribution is external (not from an organization member), the CI pipeline will not run automatically. After verifying that the CI is safe to run:

eskultety commented 3 months ago

Note that commits 5 and 6 are going to be squashed together before merging, I split them only for review purposes to make the regex changes easier to track.

eskultety commented 3 months ago

Since v1:

eskultety commented 3 months ago

Note that commits 5 and 6 are going to be squashed together before merging, I split them only for review purposes to make the regex changes easier to track.

As advertised, I squashed the two before merging.