-
-
Notifications
You must be signed in to change notification settings - Fork 12
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
fix: fix field alignment to avoid panics on 32bit OSes #44
Changes from all commits
eb37578
e6c6709
c5ddd52
2ed9108
724f886
119a5ab
3c2bd7f
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 |
---|---|---|
@@ -1,3 +1,8 @@ | ||
linters-settings: | ||
govet: | ||
enable: | ||
- fieldalignment | ||
|
||
linters: | ||
enable: | ||
# Default linters, plus these: | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,7 @@ BROWSERTEST_VERSION = v0.7 | |
LINT_VERSION = 1.50.1 | ||
GO_BIN = $(shell printf '%s/bin' "$$(go env GOPATH)") | ||
SHELL = bash | ||
ENABLE_RACE = true | ||
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. Note to self: Looks like this var is now unused. 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. 🤦♂️ good catch - that can be deleted |
||
|
||
.PHONY: all | ||
all: lint test | ||
|
@@ -12,7 +13,7 @@ lint-deps: | |
curl -sfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b "${GO_BIN}" v${LINT_VERSION}; \ | ||
fi | ||
@if ! which jsguard >/dev/null; then \ | ||
go install github.com/hack-pad/safejs/jsguard/cmd/jsguard; \ | ||
go install github.com/hack-pad/safejs/jsguard/cmd/jsguard@latest; \ | ||
fi | ||
|
||
.PHONY: lint | ||
|
@@ -31,14 +32,25 @@ test-deps: | |
fi | ||
@go install github.com/mattn/[email protected] | ||
|
||
# only use the race detector on supported architectures | ||
race_goarches := 'amd64' 'arm64' | ||
ifeq (,$(findstring '$(GOARCH)',$(race_goarches))) | ||
TEST_ARGS= | ||
export CGO_ENABLED=0 | ||
else | ||
TEST_ARGS=-race | ||
# the race detector needs cgo (at least on Linux and Windows, and macOS until Go 1.20) | ||
export CGO_ENABLED=1 | ||
endif | ||
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. Ah, bummer about race not being supported, this looks like a reasonable setup. Thank you for handling all of that. This must've been a pain wrangling with CI for so long. 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 was already in the midst doing a similar thing for gomplate so it at least wasn't a new kind of pain 😅 It probably isn't always true, but races tend to happen in the same way on all platforms, so I wouldn't be too worried here. |
||
|
||
.PHONY: test | ||
test: test-deps | ||
go test . # Run library-level checks first, for more helpful build tag failure messages. | ||
go test -race -coverprofile=native-cover.out ./... | ||
go test $(TEST_ARGS) -coverprofile=native-cover.out ./... | ||
if [[ "$$CI" != true || $$(uname -s) == Linux ]]; then \ | ||
set -ex; \ | ||
GOOS=js GOARCH=wasm go test -coverprofile=js-cover.out -covermode=atomic ./...; \ | ||
cd examples && go test -race ./...; \ | ||
cd examples && go test $(TEST_ARGS) ./...; \ | ||
fi | ||
{ echo 'mode: atomic'; cat *-cover.out | grep -v '^mode:'; } > cover.out && rm *-cover.out | ||
go tool cover -func cover.out | grep total: | ||
|
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.
This is great, thanks!
We may want to reduce the matrix a bit to a single 32 bit runner in the future, assuming we can prove the effective coverage is the same. As someone who's worked with 32 bit arch's more than me, do you foresee any problems with only validating those arch's on a single platform and Go version?
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.
The only reason I didn't also add 32-bit ARM as well is that it's a huge pain to do (without Docker) in GitHub Actions, because the GitHub-hosted runners are all AMD64 currently (ARM64 is coming this fall maybe?).
Another option is to use a self-hosted runner, and I happen to be deep in that rabbit-hole right now (hairyhenderson/gomplate#2126) and it's going about as well as you'd expect (i.e. not at all well).
For this particular class of bug any 32-bit platform will generally do, but there are other classes of bugs that can crop up only on 32-bit ARM CPUs. Somewhat ironically it's extremely rare to run into 32-bit Intel systems except for niche embedded use-cases, but it's still quite common to run into 32-bit ARM given the massive proliferation of older Raspberry Pi-type systems and routers strewn across the IoT landscape.