diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index d97c0744..68308422 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -29,5 +29,12 @@ jobs: - name: Test run: go test -v ./... --cover + - name: Test Linux release on a CPU without AVX + run: | + sudo apt-get update + sudo apt-get install --no-install-recommends -y qemu-user + go run github.com/magefile/mage build linux64 + qemu-x86_64 -cpu qemu64 ./coreander --help + - name: Test JavaScript run: node --test internal/webserver/js-tests/*.test.mjs diff --git a/README.md b/README.md index 191b0100..5d7f2b91 100644 --- a/README.md +++ b/README.md @@ -37,6 +37,8 @@ There are two possibilities for building Coreander from source: * If you have [Mage](https://magefile.org) installed in your system, just type `mage install` from the source code folder. * Otherwise, a simple `go build` or `go install` will do, although no version information will be added to the executable. +Release builds (`mage build ` or `mage release`) disable cgo and explicitly target the baseline `GOAMD64=v1` on x86-64, so they do not depend on the build machine's native C compiler CPU settings. For an equivalent portable Linux x86-64 build from source, use `CGO_ENABLED=0 GOOS=linux GOARCH=amd64 GOAMD64=v1 go build`. + Reader interaction regression tests can be run with Node.js using its built-in test runner: `node --test internal/webserver/js-tests/*.test.mjs`. ## How to use diff --git a/magefile.go b/magefile.go index b5099e3e..8f74dbf6 100644 --- a/magefile.go +++ b/magefile.go @@ -71,53 +71,33 @@ func binaryName(platform string) string { } func env(platform string) (map[string]string, error) { - env := map[string]string{} + env := map[string]string{"CGO_ENABLED": "0"} switch platform { case "linux32": - return map[string]string{ - "GOOS": "linux", - "GOARCH": "386", - }, nil + env["GOOS"], env["GOARCH"] = "linux", "386" case "linux64": - return map[string]string{ - "GOOS": "linux", - "GOARCH": "amd64", - }, nil + env["GOOS"], env["GOARCH"] = "linux", "amd64" case "linuxarm32": - return map[string]string{ - "GOOS": "linux", - "GOARCH": "arm", - "GOARM": "7", - }, nil + env["GOOS"], env["GOARCH"], env["GOARM"] = "linux", "arm", "7" case "linuxarm64": - return map[string]string{ - "GOOS": "linux", - "GOARCH": "arm64", - }, nil + env["GOOS"], env["GOARCH"] = "linux", "arm64" case "osxintel": - return map[string]string{ - "GOOS": "darwin", - "GOARCH": "amd64", - }, nil + env["GOOS"], env["GOARCH"] = "darwin", "amd64" case "osxapple": - return map[string]string{ - "GOOS": "darwin", - "GOARCH": "arm64", - }, nil + env["GOOS"], env["GOARCH"] = "darwin", "arm64" case "win32": - return map[string]string{ - "GOOS": "windows", - "GOARCH": "386", - }, nil + env["GOOS"], env["GOARCH"] = "windows", "386" case "win64": - return map[string]string{ - "GOOS": "windows", - "GOARCH": "amd64", - }, nil + env["GOOS"], env["GOARCH"] = "windows", "amd64" + default: + return nil, fmt.Errorf("Platform '%s' not supported", platform) } - return env, fmt.Errorf("Platform '%s' not supported", platform) + if env["GOARCH"] == "amd64" { + env["GOAMD64"] = "v1" + } + return env, nil } func createZip(fileName, zipFileName string) error {