Skip to content

Commit

Permalink
Mark one test from hadolint and golangci_lint backends as platform-sp…
Browse files Browse the repository at this point in the history
…ecific behaviour, test on macOS (#21620)

Continuing #21610, this adds the `platform_specific_behavior` flag to
two additional backends (hadolint and golangci_lint), that require
installing Go on the CI machines.

(I think Hadolint requires Go to build the `dockerfile` Python package
on Linux arm64.)
  • Loading branch information
huonw authored Nov 8, 2024
1 parent d28e5c3 commit 0d139ea
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 3 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -766,6 +766,10 @@ jobs:
with:
distribution: adopt
java-version: '11'
- name: Install Go
uses: actions/setup-go@v5
with:
go-version: 1.19.5
- name: Download native binaries
uses: actions/download-artifact@v4
with:
Expand Down
9 changes: 8 additions & 1 deletion src/python/pants/backend/docker/lint/hadolint/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,11 @@
# Licensed under the Apache License, Version 2.0 (see LICENSE).

python_sources()
python_tests(name="tests")
python_tests(
name="tests",
overrides={
"rules_integration_test.py": {
"tags": ["platform_specific_behavior"],
}
},
)
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ def test_passing(rule_runner: RuleRunner) -> None:
assert_success(rule_runner, tgt)


@pytest.mark.platform_specific_behavior
def test_failing(rule_runner: RuleRunner) -> None:
rule_runner.write_files({"Dockerfile": BAD_FILE, "BUILD": "docker_image(name='t')"})
tgt = rule_runner.get_target(Address("", target_name="t"))
Expand Down
10 changes: 9 additions & 1 deletion src/python/pants/backend/go/lint/golangci_lint/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,12 @@
# Licensed under the Apache License, Version 2.0 (see LICENSE).

python_sources()
python_tests(name="tests", timeout=120)
python_tests(
name="tests",
timeout=120,
overrides={
"rules_integration_test.py": {
"tags": ["platform_specific_behavior"],
}
},
)
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ def test_passing(rule_runner: RuleRunner) -> None:
assert lint_results[0].stderr == ""


@pytest.mark.platform_specific_behavior
def test_failing(rule_runner: RuleRunner) -> None:
rule_runner.write_files(
{
Expand Down
4 changes: 3 additions & 1 deletion src/python/pants_release/generate_github_workflows.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ class Platform(Enum):
SELF_HOSTED = {Platform.LINUX_ARM64, Platform.MACOS10_15_X86_64, Platform.MACOS11_ARM64}
# We control these runners, so we preinstall and expose python on them.
HAS_PYTHON = {Platform.LINUX_ARM64, Platform.MACOS10_15_X86_64, Platform.MACOS11_ARM64}
HAS_GO = {Platform.MACOS12_X86_64, Platform.MACOS10_15_X86_64, Platform.MACOS11_ARM64}
CARGO_AUDIT_IGNORED_ADVISORY_IDS = (
"RUSTSEC-2020-0128", # returns a false positive on the cache crate, which is a local crate not a 3rd party crate
)
Expand Down Expand Up @@ -743,8 +744,9 @@ def test_jobs(
*checkout(),
*(launch_bazel_remote() if with_remote_caching else []),
install_jdk(),
*([install_go()] if helper.platform not in HAS_GO else []),
*(
[install_go(), download_apache_thrift()]
[download_apache_thrift()]
if helper.platform == Platform.LINUX_X86_64
# Other platforms either don't run those tests, or have the binaries
# preinstalled on the self-hosted runners.
Expand Down

0 comments on commit 0d139ea

Please sign in to comment.