Skip to content
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

Add preliminary Go 1.21 support #427

Merged
merged 20 commits into from
Jan 31, 2024
Merged

Commits on Jan 26, 2024

  1. tests: unit: conftest: Move the env_variables fixture to gomod

    At the same time, make this a 'module' scoped fixture.
    
    Signed-off-by: Erik Skultety <[email protected]>
    eskultety committed Jan 26, 2024
    Configuration menu
    Copy the full SHA
    ca3d3eb View commit details
    Browse the repository at this point in the history
  2. tox: Limit flake8 to cachi2 and tests directories only

    Found this issue by a chance having some random untracked directory
    containing Python code in the repository.
    
    Signed-off-by: Erik Skultety <[email protected]>
    eskultety committed Jan 26, 2024
    Configuration menu
    Copy the full SHA
    61cf449 View commit details
    Browse the repository at this point in the history
  3. package_managers: gomod: Drop the git.objects import

    We're already importing the whole git namespace, so we shouldn't need
    to import another package.
    
    Signed-off-by: Erik Skultety <[email protected]>
    eskultety committed Jan 26, 2024
    Configuration menu
    Copy the full SHA
    fd45128 View commit details
    Browse the repository at this point in the history
  4. package_managers: gomod: Don't use cachito for any filenames/prefixes

    This is clearly a remnant from the old service and needs to be renamed
    to cachi2.
    
    Signed-off-by: Erik Skultety <[email protected]>
    eskultety committed Jan 26, 2024
    Configuration menu
    Copy the full SHA
    3fd37ce View commit details
    Browse the repository at this point in the history
  5. core: utils: Introduce get_cache_dir helper

    Whenever we need to save some downloaded data persistently for repeated
    use, let's use a proper cache directory for that, defaulting to
    $XDG_CACHE_HOME.
    
    Signed-off-by: Erik Skultety <[email protected]>
    eskultety committed Jan 26, 2024
    Configuration menu
    Copy the full SHA
    702c3d5 View commit details
    Browse the repository at this point in the history
  6. package_managers: gomod: Introduce Go toolchain wrapping class

    This patch introduces a skeleton interface to what will ultimately
    become the go CLI command wrapping class for all of the module logic.
    
    Signed-off-by: Erik Skultety <[email protected]>
    eskultety committed Jan 26, 2024
    Configuration menu
    Copy the full SHA
    bf8232b View commit details
    Browse the repository at this point in the history
  7. package_managers: gomod: Go: Implement an internal _run method

    This is essentially a copy-paste of the existing _run_gomod_cmd
    function which it should ultimately replace when we switch the whole
    module to the Go instance interface.
    There are only 3 notable differences compared to the original:
        - use of the more common **kwargs pattern to abstract any
          subprocess.run arguments properly and make them transparent to
          the caller
        - forcing the type of 'cmd' from a Sequence to list (it's going to
          be more handy with future patches)
        - making the error message more generic tied towards the actual Go
          command execution rather than tying it strictly to downloading
          dependencies
    
    Signed-off-by: Erik Skultety <[email protected]>
    eskultety committed Jan 26, 2024
    Configuration menu
    Copy the full SHA
    d6680c1 View commit details
    Browse the repository at this point in the history
  8. package_managers: gomod: Go: Implement an internal _retry method

    This is essentially a copy-paste of the existing _run_download_cmd
    function which it should ultimately replace when we switch the whole
    module to the Go instance interface.
    There are only 3 notable differences compared to the original:
        - use of the more common **kwargs pattern to abstract any
          subprocess.run arguments properly and make them transparent to
          the caller
        - forcing the type of 'cmd' from a Sequence to list (it's going to
          be more handy with future patches)
        - making the error message more generic tied towards the actual Go
          command execution rather than tying it strictly to downloading
          dependencies
    
    Signed-off-by: Erik Skultety <[email protected]>
    eskultety committed Jan 26, 2024
    Configuration menu
    Copy the full SHA
    fa4dde9 View commit details
    Browse the repository at this point in the history
  9. package_managers: gomod: Go: Implement an internal _install method

    This helper will take care of downloading and installing an alternative
    version of Go SDK (including the toolchain) if needed.
    
    This is supposed to take care of cases where:
        - our base Go installation >= 1.21, but we need an older e.g. 1.19
        - our base Go installation < 1.21, but we need to compile with 1.21
    
    Signed-off-by: Erik Skultety <[email protected]>
    eskultety committed Jan 26, 2024
    Configuration menu
    Copy the full SHA
    2e23f11 View commit details
    Browse the repository at this point in the history

Commits on Jan 29, 2024

  1. package_managers: gomod: Go: Implement the __call__ method

    To make the whole Go CLI wrapper interface more convenient, make
    instances of the class callables, so that one can just write
    something like:
        go(["foo", "bar"], env={}, capture_output=False)
    
    So in the end it's supposed to make the usage more intuitive by:
        - passing any CLI arguments to a callable named "go"
        - passing subprocess arguments directly with the base signature
    
    Signed-off-by: Erik Skultety <[email protected]>
    eskultety committed Jan 29, 2024
    Configuration menu
    Copy the full SHA
    91b677d View commit details
    Browse the repository at this point in the history
  2. package_managers: gomod: Go: Implement _locate_toolchain helper

    This helper's purpose is to locate an alternative toolchain
    installation if requested. It scans 2 locations:
        1) system /usr/local/go/go<ver>
            - this one will be pre-installed in the container image to
              save time during runtime
        2) $XDG_CACHE_HOME/cachi2/go
            - this one is targeted at local cachi2 use cases, i.e. without
              using the container image
    
    Signed-off-by: Erik Skultety <[email protected]>
    eskultety committed Jan 29, 2024
    Configuration menu
    Copy the full SHA
    0d966f3 View commit details
    Browse the repository at this point in the history
  3. package_managers: gomod: Go: Implement release property

    The release property is essentially just a gateway to extracting the
    version number. It uses and parses 'go version' to get the information.
    
    Signed-off-by: Erik Skultety <[email protected]>
    eskultety committed Jan 29, 2024
    Configuration menu
    Copy the full SHA
    3040772 View commit details
    Browse the repository at this point in the history
  4. package_managers: gomod: Go: Implement version property

    This property is going to be used for comparisons with the
    recommended/required toolchain versions coming from go.mod file, so it
    returns packaging.version.Version instead of plain string.
    
    Signed-off-by: Erik Skultety <[email protected]>
    eskultety committed Jan 29, 2024
    Configuration menu
    Copy the full SHA
    e0522d2 View commit details
    Browse the repository at this point in the history
  5. package_managers: gomod: Introduce _get_gomod_version function helper

    This helper is crucial in that it determines our behaviour based on the
    Go version specified in the package's go.mod file. Unfortunately for us
    we cannot utilize Go's native functionality of parsing the go.mod file
    for us as older versions of Go will have issues with go.mod files based
    on newer version of the language. Therefore, let's extract the
        'go <ver>' line manually.
    
    Signed-off-by: Erik Skultety <[email protected]>
    eskultety committed Jan 29, 2024
    Configuration menu
    Copy the full SHA
    8028bf7 View commit details
    Browse the repository at this point in the history
  6. package_managers: gomod: Adopt the Go toolchain wrapping class

    This patch wires everything up by routing all 'go' calls through the
    wrapper class.
    
    Signed-off-by: Erik Skultety <[email protected]>
    eskultety committed Jan 29, 2024
    Configuration menu
    Copy the full SHA
    d989085 View commit details
    Browse the repository at this point in the history
  7. package_managers: gomod: Don't log Go's version outside a Go instance

    We used to log the version of Go used for pre-fetching of the deps. We
    can still do that, but not outside of a Go instance since we may need
    alternate version of SDK to be installed, so that information would
    then be misleading. Since we already log this (and much more) as part
    of the Go class, we don't need the dropped hunk anymore.
    
    Signed-off-by: Erik Skultety <[email protected]>
    eskultety committed Jan 29, 2024
    Configuration menu
    Copy the full SHA
    ee1d296 View commit details
    Browse the repository at this point in the history
  8. package_managers: gomod: Drop _run_download_cmd and _run_gomod_cmd

    The logic of these helpers has been extracted into the Go class and so
    these have become unused and can be dropped.
    
    Signed-off-by: Erik Skultety <[email protected]>
    eskultety committed Jan 29, 2024
    Configuration menu
    Copy the full SHA
    cdc4ed4 View commit details
    Browse the repository at this point in the history
  9. package_managers: gomod: Add preliminary support for Go 1.21

    One of Go 1.21's main features is specifying the suggested version of
    toolchain to be used for compiling modules as a means of forwards
    compatibility.
    However, this patch only adds preliminary support for Go 1.21 in that it
    essentially explicitly denies usage of toolchains (which is fine,
    because those versions are only suggestive, Go always prefers building
    with the bundled toolchain anyway) by the means of explicitly setting
    the GOTOOLCHAIN env variable to 'local' which instructs Go to always
    use the bundled toolchain (provided it's new enough to conform to the
    minimum required version of Go indicated by the 'go' line).
    This patch makes sure we set GOTOOLCHAIN=local during both pre-fetch as
    well as for user container builds.
    
    Future patches will add proper support for 1.21 dealing with
    alternative toolchain versions that will need to be prefetched.
    
    STONEBLD-2046
    
    Signed-off-by: Erik Skultety <[email protected]>
    eskultety committed Jan 29, 2024
    Configuration menu
    Copy the full SHA
    dbd3474 View commit details
    Browse the repository at this point in the history

Commits on Jan 30, 2024

  1. Containerfile: Bump the image from Fedora 38 -> 39

    The main motivation behind this change is the Go 1.21 version which
    isn't available on Fedora 38 but is on Fedora 39.
    
    Resolves: containerbuildsystem#387
    
    Signed-off-by: Erik Skultety <[email protected]>
    eskultety committed Jan 30, 2024
    Configuration menu
    Copy the full SHA
    9e88c94 View commit details
    Browse the repository at this point in the history
  2. tests: unit: gomod: Update mock data with Go 1.21

    Since we bumped the container image to Fedora 39 shipping with 1.21, we
    need to update our Go mock data with 1.21.
    
    Signed-off-by: Erik Skultety <[email protected]>
    eskultety committed Jan 30, 2024
    Configuration menu
    Copy the full SHA
    1a0303e View commit details
    Browse the repository at this point in the history