Skip to content
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

Server-like make build and ensuring builds are clean in CI #1329

Merged
merged 29 commits into from
Apr 1, 2024

Conversation

Groxx
Copy link
Member

@Groxx Groxx commented Mar 30, 2024

There's more work to be done, but it's a major step towards forcing stability.

Oddly, missing the safe.directory git setting leads to Go failing to get version info, leading to errors building, but for some reason it doesn't show the error that git's reporting (missing safe directory). Just stuff like this with no other output:

error obtaining VCS status:
	Use -buildvcs=false to disable VCS stamping.

Once I fixed that, I learned that go test -exec nonexistent ./... >/dev/null errors, but the "FAIL: command nonexistent not found" error is.... reported on stdout, so it's hidden.
And so is the "FAIL the/package/name" message.
But if you have a failing build, the failure is printed to stderr:

❯ go test -exec true ./... >/dev/null
# go.uber.org/cadence/evictiontest
evictiontest/workflow_cache_eviction_test.go:58:4: missing ',' in composite literal

I have no idea why -exec nonexistent isn't on stderr, but I left a comment in the makefile anyway.

Quite a large amount of weird stuff condensed into a seemingly simple goal.

@Groxx Groxx changed the title tidy Server-like make build and ensuring builds are clean in CI Mar 30, 2024
Copy link

codecov bot commented Mar 30, 2024

Codecov Report

Merging #1329 (20b4c8d) into master (a55fc13) will not change coverage.
The diff coverage is n/a.

Additional details and impacted files

Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update a55fc13...20b4c8d. Read the comment docs.

@Groxx Groxx marked this pull request as ready for review March 30, 2024 00:49
build: $(BUILD)/fmt ## ensure all packages build
go build ./...
$Q # caution: some errors are reported on stdout for some reason
go test -exec true ./... >/dev/null
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

any reason for >/dev/null here?

Copy link
Member Author

@Groxx Groxx Mar 31, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just that it's quite noisy, printing every package at it builds it, and somewhat misleading as it looks like test runs but it didn't run any actual tests.
(same reasons as for the server)

# intentionally capture stderr, so status-errors are also PR-failing.
# in particular this catches "dubious ownership" failures, which otherwise
# do not fail this check and the $() hides the exit code.
if [ -n "$(git status --porcelain 2>&1)" ]; then
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: generally prefer [[ and it's not needed, but also set -o pipefail

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm pretty sure I do still need to capture output with $(), and bash / [[ don't change this semantic in that sense... but this is more than niche enough that I haven't actually tried it so now I'm curious. let's see what happens.

Copy link
Member Author

@Groxx Groxx Apr 1, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

... and I'm struggling to reproduce exactly what I thought I remembered 🤔
I might be getting it mixed up with how export x=$(...) behaves too (as that also suppresses failures).

gonna just stick with what the server does here since it's reasonably well proven over there, and also seems to work correctly here. and that way they're at least consistent and the path to fix/improve if we do find something conclusive is obvious.

bash + pipefail does seem promising enough to check at another time though.

@@ -0,0 +1,18 @@
#!/bin/sh
Copy link
Member

@davidporter-id-au davidporter-id-au Mar 31, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldn't this be /bin/bash?

In this, the year of 50 of Mechagodzilla's incarnation, is there any reason to still use shell?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is basically just copying from github.com/uber/cadence so any change we'd apply here we should probably keep in sync.

but: agreed! though this is mostly executed in docker, and docker is less likely to have bash for space reasons. I suspect our buildkite does have bash installed, but it's not quite a practical guarantee like it is on developer machines.

@@ -1,35 +0,0 @@
// Copyright (c) 2017 Uber Technologies, Inc.
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no longer necessary at all - go build ./... is much better proof of build-ability.

Groxx added 8 commits April 1, 2024 12:32
no pipefail til
going back to before, really not sure any more how bash / sh / $() work.
so match the server setup so we at least have the same behavior (which is reasonably well tested both there and here), and fixing both will be easier if needed.
@@ -165,10 +164,6 @@ $(BIN)/mockery: internal/tools/go.mod
$(BIN)/copyright: internal/cmd/tools/copyright/licensegen.go
go build -mod=readonly -o $@ ./internal/cmd/tools/copyright/licensegen.go

# dummy binary that ensures most/all packages build, without needing to wait for tests.
$(BUILD)/dummy: $(ALL_SRC) $(BUILD)/go_mod_check
go build -mod=readonly -o $@ internal/cmd/dummy/dummy.go
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

go build ./... does this same check substantially better

restore safe.directory
@Groxx Groxx merged commit 68afcb9 into cadence-workflow:master Apr 1, 2024
13 checks passed
@Groxx Groxx deleted the tidy branch April 1, 2024 20:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants