ipdxco / unified-github-workflows

Automatically distribute GitHub Actions workflow across repositories.
Other
8 stars 10 forks source link

feat: run go tests with CGO=0 #91

Open galargh opened 1 month ago

galargh commented 1 month ago

It has been suggested that

more and more of the base stack is being careful to avoid CGO where possible
it would be great to have a per-repository flag to run all the tests with CGO disabled, so that future regressions are easily caught

The way to run the tests is: CGO_ENABLED=0 go test

ribasushi commented 1 month ago

The way to run the tests is: CGO_ENABLED=0 go test

Do note - the important part for test/compilation/debug is CGO_ENABLED=0. Whether you specifically use go test after that or some other process/workflow is free-form.

ribasushi commented 1 month ago

@galargh another area where CGO_ENABLED=0 is crucial:

For Go programs that don’t need cgo, a reproducible build is as simple as compiling with CGO_ENABLED=0 go build -trimpath. Disabling cgo removes the host C toolchain as a relevant input, and -trimpath removes the current directory.