Merge #136: Support building with Go modules

49319f6a7a Cirrus: Mark cyclop,revive linters as non-mandatory (Jeremy Rand)
981e87e4e0 Cirrus: Run with both modules enabled and disabled (Jeremy Rand)
ae92da7a1b README: document building with Go modules (Jeremy Rand)

Pull request description:

Top commit has no ACKs.

Tree-SHA512: 14e086a06782b258f742dc6f3a2293454022ec4cd29225d430e3511fa0598d5251f6d1e1b3e9919bcb41e4308680bb2b886f7dc750323f3c290eb4ab90ac9151
pull/137/head
Jeremy Rand 3 years ago
commit 910eaaf3eb
No known key found for this signature in database
GPG Key ID: FD7550C2EB800711

@ -11,10 +11,30 @@ task:
- apt-get install -y libcap-dev
path_script:
- source testdata/move_to_gopath.bash
fetch_script:
- go get -tags "$GOX_TAGS" -d -v -t github.com/$CIRRUS_REPO_FULL_NAME/...
- go generate github.com/namecoin/x509-compressed/...
- go get -tags "$GOX_TAGS" -d -v -t github.com/$CIRRUS_REPO_FULL_NAME/...
matrix:
- env:
GO111MODULE: "off"
fetch_script:
- go get -tags "$GOX_TAGS" -d -v -t github.com/$CIRRUS_REPO_FULL_NAME/...
- GOOS=windows go get -tags "$GOX_TAGS" -d -v -t github.com/$CIRRUS_REPO_FULL_NAME/...
- go generate github.com/namecoin/x509-compressed/...
- go get -tags "$GOX_TAGS" -d -v -t github.com/$CIRRUS_REPO_FULL_NAME/...
- x509_script:
- cd $(go env GOPATH)/src/github.com/"$CIRRUS_REPO_FULL_NAME"
- cd ../
- git clone https://github.com/namecoin/x509-compressed.git
- cd x509-compressed
- go mod init
- go mod tidy
- go generate ./...
- go mod tidy
- go install -v ./...
fetch_script:
- cd $(go env GOPATH)/src/github.com/"$CIRRUS_REPO_FULL_NAME"
- go mod init
- go mod tidy
- go mod edit -replace github.com/namecoin/x509-compressed=../x509-compressed
- go mod tidy
lint_script:
- cd $(go env GOPATH)/src/github.com/$CIRRUS_REPO_FULL_NAME/
- golangci-lint run --no-config --enable-all --disable gochecknoglobals,gomnd $GOLANGCI_ARGS -v --timeout 5m --out-format json > $CIRRUS_WORKING_DIR/lint-report.json
@ -24,7 +44,7 @@ task:
GOLANGCI_ARGS: "--new-from-rev=HEAD~"
- name: Go Lint $GOOS Mandatory
env:
GOLANGCI_ARGS: "--disable=deadcode,errcheck,errorlint,exhaustivestruct,forbidigo,funlen,gci,gocognit,gocritic,godot,godox,goerr113,gofmt,gofumpt,goimports,golint,gosec,gosimple,ineffassign,lll,maligned,nakedret,nestif,nlreturn,nolintlint,paralleltest,scopelint,staticcheck,stylecheck,thelper,unconvert,unparam,unused,whitespace,wrapcheck,wsl"
GOLANGCI_ARGS: "--disable=cyclop,deadcode,errcheck,errorlint,exhaustivestruct,forbidigo,funlen,gci,gocognit,gocritic,godot,godox,goerr113,gofmt,gofumpt,goimports,golint,gosec,gosimple,ineffassign,lll,maligned,nakedret,nestif,nlreturn,nolintlint,paralleltest,revive,scopelint,staticcheck,stylecheck,thelper,unconvert,unparam,unused,whitespace,wrapcheck,wsl"
- name: Go Lint $GOOS
env:
GOLANGCI_ARGS: ""
@ -59,11 +79,38 @@ task:
- apt-get install -y libcap-dev
path_script:
- source testdata/move_to_gopath.bash
fetch_script:
- go get -tags "$GOX_TAGS" -d -v -t github.com/$CIRRUS_REPO_FULL_NAME/...
- go generate github.com/namecoin/x509-compressed/...
- go get -tags "$GOX_TAGS" -d -v -t github.com/$CIRRUS_REPO_FULL_NAME/...
test_script: go test -tags "$GOX_TAGS" -v github.com/$CIRRUS_REPO_FULL_NAME/...
matrix:
- env:
GO111MODULE: "off"
fetch_script:
- go get -tags "$GOX_TAGS" -d -v -t github.com/$CIRRUS_REPO_FULL_NAME/...
- GOOS=windows go get -tags "$GOX_TAGS" -d -v -t github.com/$CIRRUS_REPO_FULL_NAME/...
- go generate github.com/namecoin/x509-compressed/...
- go get -tags "$GOX_TAGS" -d -v -t github.com/$CIRRUS_REPO_FULL_NAME/...
- x509_script:
- cd $(go env GOPATH)/src/github.com/"$CIRRUS_REPO_FULL_NAME"
- cd ../
- git clone https://github.com/namecoin/x509-compressed.git
- cd x509-compressed
- go mod init
- go mod tidy
- go generate ./...
- go mod tidy
- go install -v ./...
fetch_script:
- cd $(go env GOPATH)/src/github.com/"$CIRRUS_REPO_FULL_NAME"
- go mod init
- go mod tidy
- go mod edit -replace github.com/namecoin/x509-compressed=../x509-compressed
- go mod tidy
# Get the test suite
- mkdir -p $(go env GOPATH)/src/github.com/hlandau
- cd $(go env GOPATH)/src/github.com/hlandau
- git clone https://github.com/hlandau/nctestsuite.git
test_script:
- cd $(go env GOPATH)/src/github.com/"$CIRRUS_REPO_FULL_NAME"
- go install -tags "$GOX_TAGS" -v ./...
- go test -tags "$GOX_TAGS" -v github.com/$CIRRUS_REPO_FULL_NAME/...
env:
GOX_TAGS: ""
GO_VERSION: latest
@ -86,17 +133,37 @@ task:
- go get github.com/mitchellh/gox
path_script:
- source testdata/move_to_gopath.bash
fetch_script:
- go get -tags "$GOX_TAGS" -d -v -t github.com/$CIRRUS_REPO_FULL_NAME/...
- GOOS=windows GOARCH=amd64 go get -tags "$GOX_TAGS" -d -v -t github.com/$CIRRUS_REPO_FULL_NAME/...
- go generate github.com/namecoin/x509-compressed/...
- go get -tags "$GOX_TAGS" -d -v -t github.com/$CIRRUS_REPO_FULL_NAME/...
matrix:
- env:
GO111MODULE: "off"
fetch_script:
- go get -tags "$GOX_TAGS" -d -v -t github.com/$CIRRUS_REPO_FULL_NAME/...
- GOOS=windows go get -tags "$GOX_TAGS" -d -v -t github.com/$CIRRUS_REPO_FULL_NAME/...
- go generate github.com/namecoin/x509-compressed/...
- go get -tags "$GOX_TAGS" -d -v -t github.com/$CIRRUS_REPO_FULL_NAME/...
- x509_script:
- cd $(go env GOPATH)/src/github.com/"$CIRRUS_REPO_FULL_NAME"
- cd ../
- git clone https://github.com/namecoin/x509-compressed.git
- cd x509-compressed
- go mod init
- go mod tidy
- go generate ./...
- go mod tidy
- go install -v ./...
fetch_script:
- cd $(go env GOPATH)/src/github.com/"$CIRRUS_REPO_FULL_NAME"
- go mod init
- go mod tidy
- go mod edit -replace github.com/namecoin/x509-compressed=../x509-compressed
- go mod tidy
build_script:
- rm -rf idist
- CGO_ENABLED=1 gox -tags="$GOX_TAGS" -parallel=8 -osarch 'linux/386 linux/amd64 linux/arm linux/arm64 linux/ppc64le' -output "$GOPATH/releasing/idist/$CIRRUS_REPO_NAME-$CIRRUS_TAG-{{.OS}}_{{.Arch}}/bin/{{.Dir}}" github.com/$CIRRUS_REPO_FULL_NAME/...
- CGO_ENABLED=0 gox -tags="$GOX_TAGS" -parallel=8 -osarch 'darwin/amd64 freebsd/386 freebsd/amd64 freebsd/arm linux/ppc64 openbsd/386 openbsd/amd64 netbsd/386 netbsd/amd64 netbsd/arm dragonfly/amd64 solaris/amd64 windows/386 windows/amd64' -output "$GOPATH/releasing/idist/$CIRRUS_REPO_NAME-$CIRRUS_TAG-{{.OS}}_{{.Arch}}/bin/{{.Dir}}" github.com/$CIRRUS_REPO_FULL_NAME/...
- mv $GOPATH/releasing/idist ./idist
- cd $(go env GOPATH)/src/github.com/"$CIRRUS_REPO_FULL_NAME"
- CGO_ENABLED=1 gox -tags="$GOX_TAGS" -parallel=8 -osarch 'linux/386 linux/amd64 linux/arm linux/arm64 linux/ppc64le' -output "$GOPATH/releasing/idist/$CIRRUS_REPO_NAME-$CIRRUS_TAG-{{.OS}}_{{.Arch}}/bin/{{.Dir}}" ./...
- CGO_ENABLED=0 gox -tags="$GOX_TAGS" -parallel=8 -osarch 'darwin/amd64 freebsd/386 freebsd/amd64 freebsd/arm linux/ppc64 openbsd/386 openbsd/amd64 netbsd/386 netbsd/amd64 netbsd/arm dragonfly/amd64 solaris/amd64 windows/386 windows/amd64' -output "$GOPATH/releasing/idist/$CIRRUS_REPO_NAME-$CIRRUS_TAG-{{.OS}}_{{.Arch}}/bin/{{.Dir}}" ./...
dist_script:
- mv $GOPATH/releasing/idist ./idist
- bash "testdata/dist.bash"
binaries_artifacts:
path: "dist/*"

@ -90,21 +90,37 @@ Prerequisites:
installed. (Most distributions will have a package called `libcap-dev` or
similar.)
Option A: Using Go build commands (works on any platform):
Option A: Using Go build commands without Go modules (works on any platform with Bash; only Go 1.15-1.16.x; will not work on Go 1.17+):
1. Ensure you have the GOPATH environment variable set. (For those not
1. Ensure you have the `GOPATH` environment variable set. (For those not
familar with Go, setting it to the path to an empty directory will suffice.
The directory will be filled with build files.)
2. Run `go get -d -t -u github.com/namecoin/ncdns/...`. The ncdns source code will be
2. Run `export GO111MODULE=off` to disable Go modules.
3. Run `go get -d -t -u github.com/namecoin/ncdns/...`. The ncdns source code will be
retrieved automatically.
3. Run `go generate github.com/namecoin/x509_compressed/...`. The compressed public key patch will be applied.
4. Run `go generate github.com/namecoin/x509-compressed/...`. The compressed public key patch will be applied.
5. Run `go get -t -u github.com/namecoin/ncdns/...`. ncdns will be built. The binaries will be at `$GOPATH/bin/ncdns`.
Option B: Using Go build commands with Go modules (works on any platform with Bash; Go 1.15+:
1. Install [x509-compressed](https://github.com/namecoin/x509-compressed) according to its "with Go modules" instructions. Clone ncdns to a sibling directory of x509-compressed.
2. Run the following in the ncdns directory to set up Go modules:
~~~
go mod init
go mod tidy
go mod edit -replace github.com/namecoin/x509-compressed=../x509-compressed
go mod tidy
~~~
4. Run `go get -t -u github.com/namecoin/ncdns/...`. ncdns will be built. The binaries will be at
$GOPATH/bin/ncdns.
3. Run `go install ./...`. ncdns will be built. The binaries will be at `$GOPATH/bin/ncdns`.
Option B: Using Makefile (non-Windows platforms):
Option C: Using Makefile (non-Windows platforms):
1. Run `make`. The source repository will be retrieved via `go get`
automatically.

Loading…
Cancel
Save