Skip to content

[CICD] Move gofumpt check to CICD, add cache #1518

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

Merged
merged 7 commits into from
Oct 2, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 16 additions & 5 deletions .github/workflows/cli-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,23 @@ jobs:
- uses: actions/setup-go@v4
with:
go-version-file: ./go.mod
- run: go run ./cmd/devbox run fmt
- name: golangci-lint
uses: golangci/[email protected]

- name: Install devbox
uses: jetpack-io/[email protected]
with:
enable-cache: true

- name: Mount golang cache
uses: actions/cache@v3
with:
args: "--out-${NO_FUTURE}format colored-line-number --timeout=10m"
skip-cache: true
path: |
~/.cache/golangci-lint
~/.cache/go-build
~/go/pkg
key: ${{ runner.os }}-${{ hashFiles('go.work.sum') }}
Copy link
Collaborator

Choose a reason for hiding this comment

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

go.sum? We don't have a go-workspace in devbox.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

good catch. My copy paste bad.

Copy link
Collaborator

Choose a reason for hiding this comment

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

suggestion:

key: ${{ runner.os }}-devbox-go-${{ hashFiles('go.work.sum') }}
restore-keys: ${{ runner.os }}-devbox-go-

https://github.com/actions/cache/blob/main/caching-strategies.md#using-restore-keys-to-download-the-closest-matching-cache

This may make it faster in the event of a cache miss, since it'll use the pre-existing "closest" cache as a starting point and then download the handful of changed dependencies to update the cache.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Agree with using restore keys, but not with adding devbox-go-. (I would just use a generic go or cache-go like the example you shared). This would allow sharing between go projects if they happen to have identical dependencies. (though that is rare)


- run: devbox run fmt && git diff --exit-code
- run: devbox run lint

test:
strategy:
Expand Down
2 changes: 1 addition & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
run:
go: "1.20"
go: "1.21"
linters:
disable-all: true
enable:
Expand Down
11 changes: 0 additions & 11 deletions devbox.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,6 @@
"mkdir -p dist/tools",
"export GOBIN=\"$PWD/dist/tools\"",
"go install mvdan.cc/gofumpt@latest",
"if [ -n \"${CI:-}\" ]; then",
" unformatted=\"$(find . -name '*.go' -exec \"$GOBIN/gofumpt\" -l {} \\+ | awk '{ print \"\t\" $0 }')\"",
" if [ -n \"$unformatted\" ]; then",
" echo 'The following files need to be formatted with gofumpt:'",
" echo",
" echo \"$unformatted\"",
" echo",
" echo 'Run `devbox run fmt` to format them.'",
" exit 1",
" fi",
"fi",
"find . -name '*.go' -exec \"$GOBIN/gofumpt\" -extra -w {} \\+"
],
"test": "go test -race -cover ./...",
Expand Down