-
Notifications
You must be signed in to change notification settings - Fork 27
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
Enhance workflow #51
base: master
Are you sure you want to change the base?
Enhance workflow #51
Conversation
username: ${{ secrets.DOCKERHUB_USERNAME }} | ||
password: ${{ secrets.DOCKERHUB_TOKEN }} |
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.
- GitHub Actions secrets need to be created for this repo:
DOCKERHUB_USERNAME
,DOCKERHUB_TOKEN
.
@@ -0,0 +1,96 @@ | |||
// Go version | |||
variable "GO_VERSION" { | |||
default = "1.16.3" |
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.
Only one place to change Go version for your project that will be used across all targets (_common
)
RUN apk add --no-cache gcc linux-headers musl-dev | ||
WORKDIR /src | ||
|
||
FROM golangci/golangci-lint:v1.37.1-alpine AS golangci-lint |
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.
If you want to change the golangci-lint version it's here with their official Docker image.
go test -v -coverprofile=/tmp/coverage.txt -covermode=atomic -race ./... && \ | ||
go tool cover -func=/tmp/coverage.txt |
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.
Test and coverage is done here
go tool cover -func=/tmp/coverage.txt | ||
|
||
FROM scratch AS test-coverage | ||
COPY --from=test /tmp/coverage.txt /coverage.txt |
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.
We use a special scratch stage to export coverage result back to the host (output = ["."]
in docker-bake.hcl
).
if [ -n "$(git status --porcelain -- go.mod go.sum)" ]; then \ | ||
echo >&2 'ERROR: Vendor result differs. Please vendor your package with "docker buildx bake vendor-update"'; \ | ||
git status --porcelain -- go.mod go.sum; \ | ||
exit 1; \ | ||
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.
We want to make sure go.mod|sum
is valid.
@psampaz First of all thank you for this great project! Really useful!
As a modest gift, here is a PR that offers some enhancements for the current workflow:
artifact
(current platform) orartifact-all
target for cross-compilation:darwin/amd64
darwin/arm64
linux/amd64
linux/arm/v6
linux/arm/v7
linux/arm64
windows/amd64
push tag
event semver likev0.9.0
:actions/upload-artifact
psampaz/go-mod-outdated:0.9.0
/psampaz/go-mod-outdated:latest
push
(master branch)actions/upload-artifact
psampaz/go-mod-outdated:edge
pull_request
eventactions/upload-artifact
Everything is already in place and tested on https://github.com/crazy-max/go-mod-outdated as well as the GitHub Actions pipeline if you want to take a look.