Skip to content

[go] extract helm version from go.mod to skip too old go versions #719

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

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 27 additions & 4 deletions tests/test_go.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import re

import pytest
from packaging import version
from pytest_container import GitRepositoryBuild
from pytest_container.container import ContainerData
from pytest_container.runtime import LOCALHOST
Expand Down Expand Up @@ -74,15 +75,37 @@ def test_build_kured(auto_container_per_test, container_git_clone):
],
indirect=["container_git_clone"],
)
def test_build_helm(auto_container_per_test, container_git_clone):
def test_build_helm(
auto_container_per_test: ContainerData, container_git_clone
):
"""Try to build `helm <https://github.com/helm/helm.git>`_ inside the
container with :command:`make` pre-installed.

"""

go_version = auto_container_per_test.connection.check_output("go version")
if "go1.20" in go_version or "go1.21" in go_version:
pytest.skip("Helm requires Go >= 1.22")
go_mod_path = (
auto_container_per_test.inspect.config.workingdir / "helm" / "go.mod"
)
go_mod = auto_container_per_test.connection.file(
str(go_mod_path)
).content_string

required_version_match = re.search(
r"^go\s+(?P<version>(\d+\.)+\d+)$", go_mod, re.MULTILINE
)
assert required_version_match
required_go_version = version.parse(
required_version_match.group("version")
)

go_version = version.parse(
auto_container_per_test.inspect.config.env["GOLANG_VERSION"]
)

if required_go_version > go_version:
pytest.skip(
f"Helm requires Go >= {required_go_version}, but we have {go_version}"
Copy link
Member

@dirkmueller dirkmueller Jan 8, 2025

Choose a reason for hiding this comment

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

we're pinning a specific helm release, we know which go versions are supported or not supported.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thank you for the helpful feedback

)

auto_container_per_test.connection.check_output(
container_git_clone.test_command
Expand Down
Loading