-
Notifications
You must be signed in to change notification settings - Fork 472
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Multi-OS: Provide binaries #585
Changes from 67 commits
39f240e
af50e67
cffc0bc
1e33748
3b0a2a1
b4b5371
3bf369d
fc0e37c
6f04931
284705a
25b2e67
59b9573
6f04e71
f9011ff
24177a5
4621bbf
91f8f03
955c3bb
daa336f
1ac0fc2
0fbb844
46678fd
35aa225
6b9344f
670cdd4
cc06c9d
77cc3bf
bcea1ce
1ba5427
02ed9cb
09586c3
4ec3fa6
a2c784a
8486de1
78b539c
330bd1c
75eb18a
8227028
fb3921b
e35b1b8
b939438
4f145e9
ee45539
988558f
1a98dfc
f7c2d6f
7bc01d7
9a24740
7a28410
b1f60f5
cfa1584
1e7aa4e
9e94b49
19d5914
926203f
9a4c64c
bc7eaa4
94248a8
f406321
d8042f3
2bd23c3
17d2a39
fae7f38
92c20cf
43f6313
50c8328
97c4250
143e895
9ebab4a
ed0c665
7a762a1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,28 +3,21 @@ export GO15VENDOREXPERIMENT=1 | |
exe = github.com/aelsabbahy/goss/cmd/goss | ||
pkgs = $(shell ./novendor.sh) | ||
cmd = goss | ||
TRAVIS_TAG ?= "0.0.0" | ||
GO_FILES = $(shell find . \( -path ./vendor -o -name '_test.go' \) -prune -o -name '*.go' -print) | ||
GO111MODULE=on | ||
|
||
.PHONY: all build install test release bench fmt lint vet test-int-all gen centos7 wheezy precise alpine3 arch test-int32 centos7-32 wheezy-32 precise-32 alpine3-32 arch-32 | ||
|
||
all: test-all dgoss-sha256 | ||
all: test-short-all test-int-all dgoss-sha256 | ||
|
||
test-all: fmt lint vet test test-int-all | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I introduced The integration tests can't run on non-linux unless we come up with a different approach, but I definitely didn't want to include that scope here. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Honestly, I give up on trying to have a proper integration test for Windows/OSX Solid unit tests + a small smoke test might be sufficient. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, 👍. If we think it becomes worthwhile to do more than unit-test, I reckon it'll be reasonably straightforward to achieve via There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Curious on your Test mail suggestion. Whenever you have a chance (no rush). Can you link me a psudocode gist example of what you mean. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. https://github.com/aelsabbahy/goss/pull/407/files#diff-2e387891f2d94197d8fc70573226de67R17-R34 - the job of the https://github.com/aelsabbahy/goss/pull/407/files#diff-2e387891f2d94197d8fc70573226de67R1 - use a build-tag so that these tests only run via https://github.com/aelsabbahy/goss/pull/407/files#diff-2e387891f2d94197d8fc70573226de67R13 - https://github.com/aelsabbahy/goss/pull/407/files#diff-2e387891f2d94197d8fc70573226de67R36-R63 - table-driven tests that run the binary and compare the output to some golden files, with the option to update those. |
||
test-short-all: fmt lint vet test | ||
|
||
install: release/goss-linux-amd64 | ||
$(info INFO: Starting build $@) | ||
cp release/$(cmd)-linux-amd64 $(GOPATH)/bin/goss | ||
|
||
test: | ||
$(info INFO: Starting build $@) | ||
{ \ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Similar to inside travis, factored these into scripts where it becomes easier to deal with the cross-platform differences. |
||
set -e ;\ | ||
go test -coverprofile=c.out ${pkgs} ;\ | ||
cat c.out | sed 's|github.com/aelsabbahy/goss/||' > c.out.tmp ;\ | ||
mv c.out.tmp c.out ;\ | ||
} | ||
./ci/go-test.sh $(pkgs) | ||
|
||
lint: | ||
$(info INFO: Starting build $@) | ||
|
@@ -36,30 +29,20 @@ vet: | |
|
||
fmt: | ||
$(info INFO: Starting build $@) | ||
{ \ | ||
set -e ;\ | ||
fmt=$$(gofmt -l ${GO_FILES}) ;\ | ||
[ -z "$$fmt" ] && echo "valid gofmt" || (echo -e "invalid gofmt\n$$fmt"; exit 1)\ | ||
} | ||
./ci/go-fmt.sh | ||
|
||
bench: | ||
$(info INFO: Starting build $@) | ||
go test -bench=. | ||
|
||
|
||
|
||
# Pattern rule for platform builds. | ||
# `subst` substitutes space for -, thus making an array | ||
# firstword, and word select indexes from said array. | ||
release/goss-%: $(GO_FILES) | ||
CGO_ENABLED=0 GOOS=$(firstword $(subst -, ,$*)) GOARCH=$(word 2, $(subst -, ,$*)) go build -ldflags "-X main.version=$(TRAVIS_TAG) -s -w" -o $@ $(exe) | ||
sha256sum $@ > $@.sha256 | ||
release/goss-%: | ||
./release-build.sh $* | ||
|
||
release: | ||
$(MAKE) clean | ||
$(MAKE) build | ||
|
||
build: release/goss-linux-386 release/goss-linux-amd64 release/goss-linux-arm | ||
build: release/goss-alpha-darwin-amd64 release/goss-linux-386 release/goss-linux-amd64 release/goss-linux-arm release/goss-alpha-windows-amd64 | ||
|
||
gen: | ||
$(info INFO: Starting build $@) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#!/usr/bin/env bash | ||
set -euo pipefail | ||
|
||
os_name="${1:?"No value from TRAVIS_OS_NAME in 1st arg. This is meant to be run in Travis CI, see also https://docs.travis-ci.com/user/environment-variables/#convenience-variables"}" | ||
|
||
if [[ "${os_name}" != "windows" ]]; then | ||
./cc-test-reporter after-build --exit-code "${TRAVIS_TEST_RESULT}" -d | ||
fi |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#!/usr/bin/env bash | ||
set -euo pipefail | ||
|
||
os_name="${1:?"No value from TRAVIS_OS_NAME in 1st arg. This is meant to be run in Travis CI, see also https://docs.travis-ci.com/user/environment-variables/#convenience-variables"}" | ||
|
||
if [[ "${os_name}" != "windows" ]]; then | ||
./cc-test-reporter before-build | ||
fi |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#!/usr/bin/env bash | ||
set -euo pipefail | ||
|
||
os_name="${1:?"No value from TRAVIS_OS_NAME in 1st arg. This is meant to be run in Travis CI, see also https://docs.travis-ci.com/user/environment-variables/#convenience-variables"}" | ||
|
||
# darwin & windows do not support integration-testing approach via docker, so on those, just run fast tests. | ||
# linux runs all tests; unit and integration. | ||
if [[ "${os_name}" == "osx" ]]; then | ||
make test-short-all release/goss-alpha-darwin-amd64 | ||
# darwin is the GOOS value which is easier to work with | ||
integration-tests/run-tests-alpha.sh "darwin" | ||
elif [[ "${os_name}" == "windows" ]]; then | ||
make test-short-all release/goss-alpha-windows-amd64 | ||
integration-tests/run-tests-alpha.sh "windows" | ||
else | ||
make all | ||
fi |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#!/usr/bin/env bash | ||
set -euo pipefail | ||
|
||
os_name="${TRAVIS_OS_NAME:?"No value from TRAVIS_OS_NAME. This is meant to be run in Travis CI, see also https://docs.travis-ci.com/user/environment-variables/#convenience-variables"}" | ||
|
||
# gofmt must be on PATH | ||
command -v gofmt | ||
|
||
if [[ "${os_name}" == "windows" ]]; then | ||
echo "Skipping go-fmt on Windows because line-endings cause every file to need formatting." | ||
echo "Linux is treated as authoritative." | ||
echo "Exiting 0..." | ||
exit 0 | ||
fi | ||
|
||
fmt="$(go fmt github.com/aelsabbahy/goss/...)" | ||
|
||
if [[ -z "${fmt}" ]]; then | ||
echo "valid gofmt" | ||
else | ||
echo "invalid gofmt:" | ||
echo "${fmt}" | ||
exit 1 | ||
fi |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#!/usr/bin/env bash | ||
set -euo pipefail | ||
|
||
command -v go | ||
|
||
go test -coverprofile="c.out" "${1}" | ||
|
||
sed 's|github.com/aelsabbahy/goss/||' <"c.out" >"c.out.tmp" | ||
|
||
mv "c.out.tmp" "c.out" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#!/usr/bin/env bash | ||
set -euo pipefail | ||
|
||
os_name="${1:?"No value from TRAVIS_OS_NAME in 1st arg. This is meant to be run in Travis CI, see also https://docs.travis-ci.com/user/environment-variables/#convenience-variables"}" | ||
goos="${os_name}" | ||
if [[ "${goos}" == "osx" ]]; then | ||
goos="darwin" | ||
fi | ||
|
||
go get -u golang.org/x/lint/golint | ||
|
||
if [[ "${goos}" != "windows" ]]; then | ||
curl -L "https://codeclimate.com/downloads/test-reporter/test-reporter-latest-${goos}-amd64" > "./cc-test-reporter" | ||
chmod +x "./cc-test-reporter" | ||
fi |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've factored these commands into scripts where it's cleaner to account for the cross-platform differences than within the CI configuration.