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

buildGoModule: find build/test targets with go list #284568

Draft
wants to merge 9 commits into
base: staging
Choose a base branch
from
3 changes: 3 additions & 0 deletions pkgs/applications/misc/darkman/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ buildGoModule rec {
runHook postBuild
'';

# No test target in Makefile.
doCheck = false;

installPhase = ''
runHook preInstall
make PREFIX=$out install
Expand Down
3 changes: 3 additions & 0 deletions pkgs/applications/networking/cloudflared/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,9 @@ buildGoModule rec {

doCheck = !stdenv.isDarwin;

# Test timed out after 10m0s
checkFlags = [ "-skip=^TestConcurrentUpdateAndRead$" ];

passthru.tests.simple = callPackage ./tests.nix { inherit version; };

meta = with lib; {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@ buildGoModule rec {

subPackages = [ "cmd" ];

checkFlags = [
# Tests asserts on installationManifestsURL which we set in ldflags.
"-skip=^Test_setBootstrapOptsDefaults/Basic$"
];

doInstallCheck = true;
installCheckPhase = ''
$out/bin/argocd-autopilot version | grep ${src.rev} > /dev/null
Expand Down
2 changes: 2 additions & 0 deletions pkgs/applications/networking/cluster/argocd/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ buildGoModule rec {

nativeBuildInputs = [ installShellFiles ];

doCheck = false; # Too many tests are failing

installPhase = ''
runHook preInstall
mkdir -p $out/bin
Expand Down
5 changes: 5 additions & 0 deletions pkgs/applications/networking/cluster/arkade/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@ buildGoModule rec {
"-X github.com/alexellis/arkade/pkg.Version=${version}"
];

checkFlags = [
# Test needs network access
"-skip=^Test_DownloadKubens$"
];

postInstall = ''
installShellCompletion --cmd arkade \
--bash <($out/bin/arkade completion bash) \
Expand Down
27 changes: 26 additions & 1 deletion pkgs/applications/networking/cluster/atlantis/default.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
{ lib, buildGoModule, fetchFromGitHub }:
{ lib
, buildGoModule
, fetchFromGitHub
, git
}:

buildGoModule rec {
pname = "atlantis";
Expand All @@ -19,6 +23,27 @@ buildGoModule rec {

subPackages = [ "." ];

nativeCheckInputs = [
git
];

checkFlags =
let
skippedTests = [
# Tests panic for unknown reason.
"TestPostWorkflowHookRunner_Run"
"TestPreWorkflowHookRunner_Run"
"TestNewServer"
"TestCommandRunnerVCSClientInitialized"
# Tests require Terraform, which is unfree.
"TestGitHubWorkflow"
"TestSimpleWorkflow_terraformLockFile"
"TestGitHubWorkflowWithPolicyCheck"
"TestDefaultProjectCommandBuilder_TerraformVersion"
];
in
[ "-skip=^${lib.concatStringsSep "$|^" skippedTests}$" ];

Comment on lines +30 to +45
Copy link
Member

Choose a reason for hiding this comment

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

We should probably add something like skipTestNames or so to automatically populate this like pytestCheckHook is doing

doInstallCheck = true;
installCheckPhase = ''
$out/bin/atlantis version | grep ${version} > /dev/null
Expand Down
10 changes: 10 additions & 0 deletions pkgs/applications/networking/cluster/calico/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ builtins.mapAttrs (pname: { doCheck ? true, mainProgram ? pname, subPackages }:
};
}) {
calico-apiserver = {
# integration tests require network
doCheck = false;
mainProgram = "apiserver";
subPackages = [
"apiserver/cmd/..."
Expand All @@ -42,6 +44,8 @@ builtins.mapAttrs (pname: { doCheck ? true, mainProgram ? pname, subPackages }:
];
};
calico-cni-plugin = {
# integration tests require network
doCheck = false;
mainProgram = "calico";
subPackages = [
"cni-plugin/cmd/..."
Expand All @@ -64,16 +68,22 @@ builtins.mapAttrs (pname: { doCheck ? true, mainProgram ? pname, subPackages }:
];
};
calico-typha = {
# integration tests require network
doCheck = false;
subPackages = [
"typha/cmd/..."
];
};
calicoctl = {
# integration tests require network
doCheck = false;
subPackages = [
"calicoctl/calicoctl"
];
};
confd-calico = {
# integration tests require network
doCheck = false;
mainProgram = "confd";
subPackages = [
"confd"
Expand Down
22 changes: 22 additions & 0 deletions pkgs/applications/networking/cluster/cloudfoundry-cli/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,28 @@ buildGoModule rec {
"-X code.cloudfoundry.org/cli/version.binaryVersion=${version}"
];

preCheck = ''
export HOME=$TMPDIR
'';

checkFlags =
let
skippedTests = [
# Tests requiring network access.
"TestCloudcontroller"
"TestCommon"
"TestPlugin"
"TestPluginRepo"
# Tests assert on version, which we override in ldflags.
"TestCommands"
"TestConfig"
"TestVersion"
# Panic: sync: negative WaitGroup counter
"TestApplication"
];
in
[ "-skip=^${lib.concatStringsSep "$|^" skippedTests}$" ];

postInstall = ''
mv "$out/bin/cli" "$out/bin/cf"
installShellCompletion --bash $bashCompletionScript
Expand Down
16 changes: 16 additions & 0 deletions pkgs/applications/networking/cluster/clusterctl/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,22 @@ buildGoModule rec {
"-X ${t}.gitVersion=v${version}"
];

preCheck = ''
export HOME=$TMPDIR
'';

excludedPackages = [
# Packages use envtest in their TestMain and panic when executed.
# Excluding these packages here so, as TestMain functions cannot
# be skipped on a per-package basis using '-skip' flag.
"util/patch"
"internal/controllers/clusterclass"
"controllers/remote"
"internal/util/ssa"
"internal/controllers/topology/cluster/structuredmerge"
"internal/controllers/topology/cluster"
];

postInstall = ''
# errors attempting to write config to read-only $HOME
export HOME=$TMPDIR
Expand Down
10 changes: 10 additions & 0 deletions pkgs/applications/networking/cluster/cni/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,16 @@ buildGoModule rec {

ldflags = [ "-s" "-w" ];

checkFlags =
let
skippedTests = [
# Tests require Go module proxy lookup.
"TestInvoke"
"TestLibcni"
];
in
[ "-skip=^${lib.concatStringsSep "$|^" skippedTests}$" ];

meta = with lib; {
description = "Container Network Interface - networking for Linux containers";
license = licenses.asl20;
Expand Down
5 changes: 1 addition & 4 deletions pkgs/applications/networking/cluster/ktop/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
buildGoModule rec {
pname = "ktop";
version = "0.3.5";
excludedPackages = [".ci"];

src = fetchFromGitHub {
owner = "vladimirvivien";
Expand All @@ -15,9 +14,7 @@ buildGoModule rec {
vendorHash = "sha256-IiAMmHOq69WMT2B1q9ZV2fGDnLr7AbRm1P7ACSde2FE=";
ldflags = [ "-s" "-w" "-X github.com/vladimirvivien/ktop/buildinfo.Version=v${version}" ];

postInstall = ''
rm $out/bin/hack
'';
subPackages = [ "." ];

doCheck = false;

Expand Down
9 changes: 7 additions & 2 deletions pkgs/applications/networking/cluster/velero/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ buildGoModule rec {
};

ldflags = [
"-s" "-w"
"-s"
"-w"
"-X github.com/vmware-tanzu/velero/pkg/buildinfo.Version=v${version}"
"-X github.com/vmware-tanzu/velero/pkg/buildinfo.ImageRegistry=velero"
"-X github.com/vmware-tanzu/velero/pkg/buildinfo.GitTreeState=clean"
Expand All @@ -22,7 +23,11 @@ buildGoModule rec {

vendorHash = "sha256-Fu4T2VEW5s/KCdgJLk3bf0wIUhKULK6QuNEmL99MUCI=";

excludedPackages = [ "issue-template-gen" "release-tools" "v1" "velero-restic-restore-helper" ];
subPackages = [
"cmd/velero"
"cmd/velero-helper"
"cmd/velero-restore-helper"
];

doCheck = false; # Tests expect a running cluster see https://github.com/vmware-tanzu/velero/tree/main/test/e2e
doInstallCheck = true;
Expand Down
10 changes: 10 additions & 0 deletions pkgs/applications/networking/coreth/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,16 @@ buildGoModule rec {
"plugin"
];

checkFlags =
let
skippedTests = [
# Tests require additional dependencies not specified in go.mod.
"TestGolangBindings"
"TestGolangBindingsOverload"
];
in
[ "-skip=^${lib.concatStringsSep "$|^" skippedTests}$" ];

postInstall = "mv $out/bin/{plugin,evm}";

meta = with lib; {
Expand Down
2 changes: 1 addition & 1 deletion pkgs/applications/version-management/git-bug/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ buildGoModule rec {

doCheck = false;

excludedPackages = [ "doc" "misc" ];
subPackages = [ "." ];

ldflags = [
"-X github.com/MichaelMure/git-bug/commands.GitCommit=v${version}"
Expand Down
Loading
Loading