Skip to content
Merged
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
25 changes: 25 additions & 0 deletions acceptance/acceptance_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import (
"github.com/databricks/cli/libs/testdiff"
"github.com/databricks/cli/libs/testserver"
"github.com/stretchr/testify/require"
"go.yaml.in/yaml/v3"
)

var (
Expand Down Expand Up @@ -301,6 +302,12 @@ func testAccept(t *testing.T, inprocessMode bool, singleTest string) int {
t.Logf("Writing coverage to %s", coverDir)
}

// Build the CLI with the FIPS toolchain so a plain `go test` produces the
// same FIPS binary as `task` (which sets GOFIPS140 in its env) and the
// release pipeline; without it acceptance/fips fails outside `task`. The
// build below inherits os.Environ(), so setting it here is enough.
t.Setenv("GOFIPS140", readGOFIPS140(t, cwd))

execPath := ""
cliVersion := ""

Expand Down Expand Up @@ -1289,6 +1296,24 @@ func BuildCLI(t *testing.T, buildDir, coverDir, osName, arch string) string {
return execPath
}

// readGOFIPS140 returns the GOFIPS140 version the Taskfile pins for `task`
// builds; the release pipeline pins the same value independently in
// .goreleaser.yaml.
func readGOFIPS140(t *testing.T, cwd string) string {
path := filepath.Join(cwd, "..", "Taskfile.yml")
data, err := os.ReadFile(path)
require.NoError(t, err)

var taskfile struct {
Env struct {
GOFIPS140 string `yaml:"GOFIPS140"`
} `yaml:"env"`
}
require.NoError(t, yaml.Unmarshal(data, &taskfile))
require.NotEmpty(t, taskfile.Env.GOFIPS140, "GOFIPS140 not set in Taskfile.yml")
return taskfile.Env.GOFIPS140
}

// CreateReleaseArtifacts builds release artifacts for the given OS using amd64 and arm64 architectures,
// archives them into zip files, and returns the directory containing the release artifacts.
func CreateReleaseArtifacts(t *testing.T, cwd, coverDir, osName string) string {
Expand Down
Loading