-
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
Merged
aelsabbahy
merged 71 commits into
goss-org:master
from
improbable-eng:multi-os-binaries
Jun 16, 2020
Merged
Changes from all commits
Commits
Show all changes
71 commits
Select commit
Hold shift + click to select a range
39f240e
Multi-OS: Provide binaries
af50e67
Make cross-compilation build work (on macOS locally, try CI separately)
cffc0bc
deal with cc-test-reporter
1e33748
oh, Windows
3b0a2a1
Add docs and start of matrix / test-plan
b4b5371
cross-platform CI
3bf369d
debug
fc0e37c
save
6f04931
oops
284705a
debug
25b2e67
oci runtime error try2
59b9573
no windows support for codeclimate
6f04e71
missed that
f9011ff
bash
24177a5
Windows find is, of course, different
4621bbf
CI
91f8f03
fix pasta
955c3bb
fix windows binary name
daa336f
Move to ci folder to avoid cluttering root. Implement fmt and test to…
1ac0fc2
pass through
0fbb844
try just bash
46678fd
oops2
35aa225
TIL go fmt {package} is a thing
6b9344f
no longer needed
670cdd4
windows
cc06c9d
fix table
77cc3bf
fix
bcea1ce
pasta
1ba5427
format table
02ed9cb
revert to master
09586c3
revert
4ec3fa6
make travis_tag consistent for local builds compared to previously
a2c784a
:facepalm:
8486de1
flesh out parity doc
78b539c
expand
330bd1c
tweak
75eb18a
elaborate
8227028
I added tests
fb3921b
simplify I think?
e35b1b8
Name the binaries to denote alphaness
b939438
Output warning before/after, and fail unless GOSS_ALPHA=1
4f145e9
elaborate slightly
ee45539
oops, CI verbiage
988558f
cleaner formatting
petemounce 1a98dfc
support each shell
petemounce f7c2d6f
Test Windows by adding automation
petemounce 7bc01d7
+x
petemounce 9a24740
oops!
petemounce 7a28410
debug
petemounce b1f60f5
bash and debug
petemounce cfa1584
actually building the binary helps when running it!
petemounce 1e7aa4e
apparently it's not on travis
petemounce 9e94b49
Darwin coverage
petemounce 19d5914
fix
petemounce 926203f
enable
petemounce 9a4c64c
rename
petemounce bc7eaa4
skip
petemounce 94248a8
skip
petemounce f406321
no skip
petemounce d8042f3
adjust for darwin
petemounce 2bd23c3
skip the not-working bits
petemounce 17d2a39
Clarify wording, set support expectations
petemounce fae7f38
oops
petemounce 92c20cf
n/a + docs
petemounce 43f6313
try to appease codeclimate
petemounce 50c8328
Surely the codeclimate duplication gods approve now
petemounce 97c4250
well, perhaps the gods like this one?
petemounce 143e895
Return -1 as 'not applicable'
petemounce 9ebab4a
Remember go env
petemounce ed0c665
oops
petemounce 7a762a1
now unnecessary
petemounce File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
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 $@) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#!/usr/bin/env bash | ||
set -euo pipefail | ||
|
||
os_name="$(go env GOOS)" | ||
|
||
if [[ "${os_name}" != "windows" ]]; then | ||
./cc-test-reporter after-build --exit-code "${TRAVIS_TEST_RESULT}" -d | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#!/usr/bin/env bash | ||
set -euo pipefail | ||
|
||
os_name="$(go env GOOS)" | ||
|
||
if [[ "${os_name}" != "windows" ]]; then | ||
./cc-test-reporter before-build | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#!/usr/bin/env bash | ||
set -euo pipefail | ||
|
||
os_name="$(go env GOOS)" | ||
|
||
# darwin & windows do not support integration-testing approach via docker, so on those, just run fast tests. | ||
if [[ "${os_name}" == "darwin" || "${os_name}" == "windows" ]]; then | ||
make test-short-all release/goss-alpha-${os_name}-amd64 | ||
integration-tests/run-tests-alpha.sh "${os_name}" | ||
else | ||
# linux runs all tests; unit and integration. | ||
make all | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#!/usr/bin/env bash | ||
set -euo pipefail | ||
|
||
os_name="$(go env GOOS)" | ||
|
||
# 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#!/usr/bin/env bash | ||
set -euo pipefail | ||
|
||
os_name="$(go env GOOS)" | ||
|
||
go get -u golang.org/x/lint/golint | ||
|
||
if [[ "${os_name}" != "windows" ]]; then | ||
curl -L "https://codeclimate.com/downloads/test-reporter/test-reporter-latest-${os_name}-amd64" > "./cc-test-reporter" | ||
chmod +x "./cc-test-reporter" | ||
fi |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 introduced
test-short-all
to represent all the short tests like lints and unit-tests, which can run on each platform.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 comment
The 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 comment
The 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
TestMain
and blackbox'ing against some golden files.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.
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 comment
The 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
TestMain
is to make sure that the binary is present; in this example it's done viago build
, but it doesn't matter what the implementation is.https://github.com/aelsabbahy/goss/pull/407/files#diff-2e387891f2d94197d8fc70573226de67R1 - use a build-tag so that these tests only run via
go test -tags integration
- this would allow the tests to only be run after the build automation has had a chance to build the release binaries, at which pointTestMain
could just choose which one to use based onruntime.GOOS
/runtime.GOARCH
.https://github.com/aelsabbahy/goss/pull/407/files#diff-2e387891f2d94197d8fc70573226de67R13 -
rendon/testcli
is a package that looked the most similar to a setup I'm familiar with from another language's ecosystem. It makes a small wrapper around os.exec and then allows one to assert against stdout/stderr.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.