treewide: remove buildFlags use in buildGoModule

Signed-off-by: Paul Meyer <49727155+katexochen@users.noreply.github.com>
This commit is contained in:
Paul Meyer 2024-01-07 11:10:58 +01:00
parent dd540970e2
commit b2f0e7301e
25 changed files with 177 additions and 191 deletions

View File

@ -1,6 +1,7 @@
{ buildGoModule
, fetchFromGitHub
, lib
, go
, tags ? [ "autopilotrpc" "signrpc" "walletrpc" "chainrpc" "invoicesrpc" "watchtowerrpc" "routerrpc" "monitoring" "kvdb_postgres" "kvdb_etcd" ]
}:
@ -19,17 +20,7 @@ buildGoModule rec {
subPackages = [ "cmd/lncli" "cmd/lnd" ];
preBuild = let
buildVars = {
RawTags = lib.concatStringsSep "," tags;
GoVersion = "$(go version | egrep -o 'go[0-9]+[.][^ ]*')";
};
buildVarsFlags = lib.concatStringsSep " " (lib.mapAttrsToList (k: v: "-X github.com/lightningnetwork/lnd/build.${k}=${v}") buildVars);
in
lib.optionalString (tags != []) ''
buildFlagsArray+=("-tags=${lib.concatStringsSep " " tags}")
buildFlagsArray+=("-ldflags=${buildVarsFlags}")
'';
inherit tags;
meta = with lib; {
description = "Lightning Network Daemon";

View File

@ -19,7 +19,8 @@ buildGoModule rec {
ldflags =
let
modulePath = "github.com/git-town/git-town/v${lib.versions.major version}"; in
modulePath = "github.com/git-town/git-town/v${lib.versions.major version}";
in
[
"-s"
"-w"
@ -28,19 +29,22 @@ buildGoModule rec {
];
nativeCheckInputs = [ git ];
preCheck =
preCheck = ''
HOME=$(mktemp -d)
'';
checkFlags =
let
# Disable tests requiring local operations
skippedTests = [
"TestGodog"
"TestMockingShell_MockCommand"
"TestShellRunner_RunStringWith_Input"
"TestMockingRunner/MockCommand"
"TestMockingRunner/QueryWith"
"TestTestCommands/CreateChildFeatureBranch"
];
in
''
HOME=$(mktemp -d)
# Disable tests requiring local operations
buildFlagsArray+=("-run" "[^(${builtins.concatStringsSep "|" skippedTests})]")
'';
[ "-skip=^${builtins.concatStringsSep "$|^" skippedTests}$" ];
postInstall = ''
installShellCompletion --cmd git-town \

View File

@ -15,16 +15,19 @@ buildGoModule rec {
ldflags = [ "-s" "-w" ];
nativeBuildInputs = [
nativeCheckInputs = [
git # required by unit tests
];
preCheck = ''
HOME=$(mktemp -d)
# Disable tests requiring network access to gitlab.com
buildFlagsArray+=("-run" "[^(Test(Run|Start|(Fetch|Pull)With(Go|)Git))]")
'';
checkFlags = [
# Disable tests requiring network access to gitlab.com
"-skip=Test(Run|Start|(Fetch|Pull)With(Go|)Git)"
];
meta = with lib; {
description = "Running git UI commands";
homepage = "https://github.com/isacikgoz/gitbatch";

View File

@ -20,19 +20,20 @@ buildGoModule rec {
ldflags = [ "-s" "-w" ];
preCheck =
preCheck = ''
export USER=$(whoami)
export HOME="$(mktemp -d)"
'';
checkFlags =
let
skippedTests = [
# Disable flaky tests
"TestDialogs"
"TestVoldialogs"
];
in
''
export HOME="$(mktemp -d)"
# Disable flaky tests
buildFlagsArray+=("-run" "[^(${builtins.concatStringsSep "|" skippedTests})]")
'';
[ "-skip=^${builtins.concatStringsSep "$|^" skippedTests}$" ];
passthru.tests.version = testers.testVersion {
package = podman-tui;

View File

@ -81,7 +81,8 @@ buildGoModule rec {
make incus-agent incus-migrate
'';
preCheck =
# Disable tests requiring local operations
checkFlags =
let
skippedTests = [
"TestValidateConfig"
@ -91,10 +92,7 @@ buildGoModule rec {
"TestContainerTestSuite"
];
in
''
# Disable tests requiring local operations
buildFlagsArray+=("-run" "[^(${builtins.concatStringsSep "|" skippedTests})]")
'';
[ "-skip=^${builtins.concatStringsSep "$|^" skippedTests}$" ];
postInstall = ''
installShellCompletion --cmd incus \

View File

@ -71,7 +71,7 @@ buildGo122Module rec {
make lxd-agent lxd-migrate
'';
preCheck =
checkFlags =
let
skippedTests = [
"TestValidateConfig"
@ -81,10 +81,7 @@ buildGo122Module rec {
"TestContainerTestSuite"
];
in
''
# Disable tests requiring local operations
buildFlagsArray+=("-run" "[^(${builtins.concatStringsSep "|" skippedTests})]")
'';
[ "-skip=^${builtins.concatStringsSep "$|^" skippedTests}$" ];
postInstall = ''
installShellCompletion --bash --name lxd ./scripts/bash/lxd-client

View File

@ -17,9 +17,9 @@ buildGoModule rec {
ldflags = [ "-s" "-w" ];
preCheck = ''
buildFlagsArray+="-short"
'';
checkFlags = [
"-short"
];
meta = {
description = "Go testing in the browser. Integrates with `go test`. Write behavioral tests in Go";

View File

@ -41,12 +41,19 @@ buildGoModule rec {
tags = [ "rocksdb_6_16" ];
CGO_LDFLAGS = [
"-L${stdenv.cc.cc.lib}/lib"
"-lrocksdb"
"-lz"
"-lbz2"
"-lsnappy"
"-llz4"
"-lm"
"-lstdc++"
];
preBuild = lib.optionalString stdenv.isDarwin ''
ulimit -n 8192
'' + ''
export CGO_LDFLAGS="-L${stdenv.cc.cc.lib}/lib -lrocksdb -lz -lbz2 -lsnappy -llz4 -lm -lstdc++"
buildFlagsArray+=("-tags=${lib.concatStringsSep " " tags}")
buildFlagsArray+=("-ldflags=${lib.concatStringsSep " " ldflags}")
'';
subPackages = [ "." ];

View File

@ -13,17 +13,17 @@ buildGoModule rec {
vendorHash = "sha256-he2bmcTNkuKRsNGkn1IkhtOe+Eo/5RLWLYlNFWLo/As=";
preCheck = let
skippedTests = [
"TestBacktracking"
"TestInconsistentLabelsE2E"
"TestIssue111"
"TestIssue61"
"TestIssue90"
];
in ''
buildFlagsArray+=("-run" "[^(${builtins.concatStringsSep "|" skippedTests})]")
'';
checkFlags =
let
skippedTests = [
"TestBacktracking"
"TestInconsistentLabelsE2E"
"TestIssue111"
"TestIssue61"
"TestIssue90"
];
in
[ "-skip=^${builtins.concatStringsSep "$|^" skippedTests}$" ];
passthru.tests = { inherit (nixosTests.prometheus-exporters) graphite; };

View File

@ -23,9 +23,9 @@ buildGoModule rec {
];
# skips tests with external dependencies, e.g. on mysqld
preCheck = ''
buildFlagsArray+="-short"
'';
checkFlags = [
"-short"
];
meta = with lib; {
description = "Prometheus exporter for MySQL server metrics";

View File

@ -20,9 +20,10 @@ buildGoModule rec {
CODENAME=$(awk -F "=" '/CODENAME=/ { print $2}' script/binary)
buildFlagsArray+=("-ldflags= -s -w \
-X github.com/traefik/traefik/v${lib.versions.major version}/pkg/version.Version=${version} \
-X github.com/traefik/traefik/v${lib.versions.major version}/pkg/version.Codename=$CODENAME")
ldflags="-s"
ldflags+=" -w"
ldflags+=" -X github.com/traefik/traefik/v${lib.versions.major version}/pkg/version.Version=${version}"
ldflags+=" -X github.com/traefik/traefik/v${lib.versions.major version}/pkg/version.Codename=$CODENAME"
'';
doCheck = false;

View File

@ -1,6 +1,7 @@
{ lib
, buildGoModule
, fetchFromGitHub
, go
}:
buildGoModule rec {
@ -19,22 +20,14 @@ buildGoModule rec {
subPackages = [ "cmd/trickster" ];
preBuild =
let
ldflags = with lib;
concatStringsSep " " (
[ "-extldflags '-static'" "-s" "-w" ] ++
(mapAttrsToList (n: v: "-X main.application${n}=${v}") {
BuildTime = "1970-01-01T00:00:00+0000";
GitCommitID = rev;
GoVersion = "$(go env GOVERSION)";
GoArch = "$(go env GOARCH)";
})
);
in
''
buildFlagsArray+=("-ldflags=${ldflags}")
'';
ldflags = with lib;
[ "-extldflags '-static'" "-s" "-w" ] ++
(mapAttrsToList (n: v: "-X main.application${n}=${v}") {
BuildTime = "1970-01-01T00:00:00+0000";
GitCommitID = rev;
GoVersion = "go${go.version}}";
GoArch = "${go.GOARCH}";
});
# Tests are broken.
doCheck = false;

View File

@ -3,6 +3,7 @@
, fetchFromGitHub
, installShellFiles
, nix-update-script
, go
, testers
, pulsarctl
}:
@ -22,19 +23,17 @@ buildGoModule rec {
nativeBuildInputs = [ installShellFiles ];
preBuild = let
buildVars = {
ReleaseVersion = version;
BuildTS = "None";
GitHash = src.rev;
GitBranch = "None";
GoVersion = "$(go version | egrep -o 'go[0-9]+[.][^ ]*')";
};
buildVarsFlags = lib.concatStringsSep " " (lib.mapAttrsToList (k: v: "-X github.com/streamnative/pulsarctl/pkg/cmdutils.${k}=${v}") buildVars);
in
''
buildFlagsArray+=("-ldflags=${buildVarsFlags}")
'';
ldflags =
let
buildVars = {
ReleaseVersion = version;
BuildTS = "None";
GitHash = src.rev;
GitBranch = "None";
GoVersion = "go${go.version}";
};
in
(lib.mapAttrsToList (k: v: "-X github.com/streamnative/pulsarctl/pkg/cmdutils.${k}=${v}") buildVars);
excludedPackages = [
"./pkg/test"
@ -73,4 +72,3 @@ buildGoModule rec {
mainProgram = "pulsarctl";
};
}

View File

@ -46,32 +46,6 @@ buildGoModule rec {
"-X github.com/pulumi/pulumi/pkg/v3/version.Version=v${version}"
];
doCheck = true;
disabledTests = [
# Flaky test
"TestPendingDeleteOrder"
# Tries to clone repo: github.com/pulumi/templates.git
"TestGenerateOnlyProjectCheck"
# Following tests give this error, not quite sure why:
# Error Trace: /build/pulumi/pkg/engine/lifecycletest/update_plan_test.go:273
# Error: Received unexpected error:
# Unexpected diag message: <{%reset%}>using pulumi-resource-pkgA from $PATH at /build/tmp.bS8caxmTx7/pulumi-resource-pkgA<{%reset%}>
# Test: TestUnplannedDelete
"TestExpectedDelete"
"TestPlannedInputOutputDifferences"
"TestPlannedUpdateChangedStack"
"TestExpectedCreate"
"TestUnplannedDelete"
# Following test gives this error, not sure why:
# --- Expected
# +++ Actual
# @@ -1 +1 @@
# -gcp
# +aws
"TestPluginMapper_MappedNamesDifferFromPulumiName"
];
nativeCheckInputs = [
git
];
@ -93,12 +67,39 @@ buildGoModule rec {
rm codegen/{docs,dotnet,go,nodejs,python,schema}/*_test.go
rm -R codegen/{dotnet,go,nodejs,python}/gen_program_test
# Only run tests not marked as disabled
buildFlagsArray+=("-run" "[^(${lib.concatStringsSep "|" disabledTests})]")
'' + lib.optionalString stdenv.isDarwin ''
export PULUMI_HOME=$(mktemp -d)
'';
checkFlags =
let
disabledTests = [
# Flaky test
"TestPendingDeleteOrder"
# Tries to clone repo: github.com/pulumi/templates.git
"TestGenerateOnlyProjectCheck"
# Following tests give this error, not quite sure why:
# Error Trace: /build/pulumi/pkg/engine/lifecycletest/update_plan_test.go:273
# Error: Received unexpected error:
# Unexpected diag message: <{%reset%}>using pulumi-resource-pkgA from $PATH at /build/tmp.bS8caxmTx7/pulumi-resource-pkgA<{%reset%}>
# Test: TestUnplannedDelete
"TestExpectedDelete"
"TestPlannedInputOutputDifferences"
"TestPlannedUpdateChangedStack"
"TestExpectedCreate"
"TestUnplannedDelete"
# Following test gives this error, not sure why:
# --- Expected
# +++ Actual
# @@ -1 +1 @@
# -gcp
# +aws
"TestPluginMapper_MappedNamesDifferFromPulumiName"
"TestProtect"
];
in
[ "-skip=^${lib.concatStringsSep "$|^" disabledTests}$" ];
# Allow tests that bind or connect to localhost on macOS.
__darwinAllowLocalNetworking = true;

View File

@ -20,17 +20,15 @@ buildGoModule rec {
ldflags = [ "-s" "-w" "-X main.gcsfuseVersion=${version}" ];
preCheck =
checkFlags =
let
skippedTests = [
# Disable flaky tests
"Test_Main"
"TestFlags"
];
in
''
# Disable flaky tests
buildFlagsArray+=("-run" "[^(${builtins.concatStringsSep "|" skippedTests})]")
'';
[ "-skip=^${builtins.concatStringsSep "$|^" skippedTests}$" ];
postInstall = ''
ln -s $out/bin/mount_gcsfuse $out/bin/mount.gcsfuse

View File

@ -18,11 +18,11 @@ buildGoModule rec {
nativeBuildInputs = [ pkg-config ];
buildInputs = [ libusb1 ];
preCheck = ''
checkFlags = [
# Only run tests under mtp/encoding_test.go
# Other tests require an Android deviced attached over USB.
buildFlagsArray+=("-run" "Test(Encode|Decode|Variant).*")
'';
"-run=Test(Encode|Decode|Variant)"
];
meta = with lib; {
description = "A simple FUSE filesystem for mounting Android devices as a MTP device";

View File

@ -48,17 +48,19 @@ buildGoModule rec {
ldflags = [ "-s" "-w" ];
preCheck =
let skippedTests = [
"TestClosest" # Requiring Wayland or X
"TestEveryMinute" # Blocking
"TestNewSimpleEvent" # Blocking
]; in
''
export XDG_RUNTIME_DIR=`mktemp -d`
preCheck = ''
export XDG_RUNTIME_DIR=$(mktemp -d)
'';
buildFlagsArray+=("-run" "[^(${builtins.concatStringsSep "|" skippedTests})]")
'';
checkFlags =
let
skippedTests = [
"TestClosest" # Requiring Wayland or X
"TestEveryMinute" # Blocking
"TestNewSimpleEvent" # Blocking
];
in
[ "-skip=^${builtins.concatStringsSep "$|^" skippedTests}$" ];
meta = {
description = "Utilities for handling monitors, resolutions, and (timed) wallpapers";

View File

@ -16,9 +16,9 @@ buildGoModule rec {
vendorHash = "sha256-kwvEfvHs6XF84bB3Ss1307OjId0nh/0Imih1fRFdY0M=";
preCheck = ''
buildFlagsArray+="-short"
'';
checkFlags = [
"-short"
];
meta = with lib; {
description = "Google Cloud Bigtable Tool";

View File

@ -18,9 +18,9 @@ buildGo122Module rec {
vendorHash = "sha256-sAVMmDeHXEgQXb/Xi4nXYztXjuykE0TFebkeubMTZ3k=";
preCheck = ''
buildFlagsArray+="-short"
'';
checkFlags = [
"-short"
];
meta = with lib; {
description = "Utility for ensuring secure connections to Google Cloud SQL instances";

View File

@ -24,15 +24,14 @@ buildGoModule rec {
# want but also limits the tests
unset subPackages
# checkFlags aren't correctly passed through via buildGoModule so we use buildFlagsArray
# -short only runs the unit-tests tagged short
# move to checkFlags after https://github.com/NixOS/nixpkgs/pull/173702
buildFlagsArray+="-short"
# remove tests that require networking
rm cmd/infracost/{breakdown,diff,hcl,run}_test.go
'';
checkFlags = [
"-short"
];
postInstall = ''
export INFRACOST_SKIP_UPDATE_CHECK=true
installShellCompletion --cmd infracost \

View File

@ -23,7 +23,7 @@ buildGoModule rec {
ldflags = [ "-s" "-w" ];
preCheck =
checkFlags =
let
skippedTests = [
# Possible error about github.com/mattn/go-sqlite3
@ -31,9 +31,7 @@ buildGoModule rec {
"Test_processFileActions"
];
in
''
buildFlagsArray+=("-run" "[^(${builtins.concatStringsSep "|" skippedTests})]")
'';
[ "-skip=^${builtins.concatStringsSep "$|^" skippedTests}$" ];
meta = with lib; {
description = "Easily rename multiple files using your text editor";

View File

@ -19,7 +19,7 @@ buildGoModule rec {
"-X github.com/wakatime/wakatime-cli/pkg/version.Version=${version}"
];
preCheck =
checkFlags =
let
skippedTests = [
# Tests requiring network
@ -33,10 +33,7 @@ buildGoModule rec {
"TestLoadParams_ApiKey_FromVault_Err_Darwin"
];
in
''
# Disable tests
buildFlagsArray+=("-run" "[^(${builtins.concatStringsSep "|" skippedTests})]")
'';
[ "-skip=^${builtins.concatStringsSep "$|^" skippedTests}$" ];
passthru.tests.version = testers.testVersion {
package = wakatime;

View File

@ -17,12 +17,8 @@ buildGoModule rec {
# we fetch the expected tag's timestamp from a file in the root of the
# repository.
preBuild = ''
buildFlagsArray=(
-ldflags="
-X github.com/mdlayher/corerad/internal/build.linkTimestamp=$(<.gittagtime)
-X github.com/mdlayher/corerad/internal/build.linkVersion=v${version}
"
)
ldflags+=" -X github.com/mdlayher/corerad/internal/build.linkVersion=v${version}"
ldflags+=" -X github.com/mdlayher/corerad/internal/build.linkTimestamp=$(<.gittagtime)"
'';
passthru.tests = {

View File

@ -17,32 +17,35 @@ buildGoModule rec {
ldflags = [ "-s" "-w" ];
preCheck =
preCheck = ''
# Fix tests expecting /usr/bin/printf and /bin/echo
substituteInPlace skeema_cmd_test.go \
--replace /usr/bin/printf "${coreutils}/bin/printf"
substituteInPlace internal/fs/dir_test.go \
--replace /bin/echo "${coreutils}/bin/echo" \
--replace /usr/bin/printf "${coreutils}/bin/printf"
substituteInPlace internal/applier/ddlstatement_test.go \
--replace /bin/echo "${coreutils}/bin/echo"
'';
checkFlags =
let
skippedTests = [
# Tests requiring network access to gitlab.com
"TestDirRelPath"
"TestParseDirSymlinks"
"TestParseDir"
# Flaky tests
"TestCommandTimeout"
"TestShellOutTimeout"
# Fails with 'internal/fs/testdata/cfgsymlinks1/validrel/.skeema is a symlink pointing outside of its repo'.
"TestParseDirSymlinks"
];
in
''
buildFlagsArray+=("-run" "[^(${builtins.concatStringsSep "|" skippedTests})]")
# Fix tests expecting /usr/bin/printf and /bin/echo
substituteInPlace skeema_cmd_test.go \
--replace /usr/bin/printf "${coreutils}/bin/printf"
substituteInPlace internal/fs/dir_test.go \
--replace /bin/echo "${coreutils}/bin/echo" \
--replace /usr/bin/printf "${coreutils}/bin/printf"
substituteInPlace internal/applier/ddlstatement_test.go \
--replace /bin/echo "${coreutils}/bin/echo"
'';
[ "-skip=^${builtins.concatStringsSep "$|^" skippedTests}$" ];
passthru.tests.version = testers.testVersion {
package = skeema;

View File

@ -19,15 +19,14 @@ buildGoModule rec {
package = gucci;
};
checkFlags = [ "-short" ];
# Integration tests rely on Ginkgo but fail.
# Related: https://github.com/onsi/ginkgo/issues/602
#
# Disable integration tests.
preCheck = ''
buildFlagsArray+=("-run" "[^(TestIntegration)]")
'';
checkFlags = [
"-short"
# Integration tests rely on Ginkgo but fail.
# Related: https://github.com/onsi/ginkgo/issues/602
#
# Disable integration tests.
"-skip=^TestIntegration"
];
meta = with lib; {
description = "A simple CLI templating tool written in golang";