Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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: 20 additions & 1 deletion .github/workflows/cli-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,29 @@ jobs:
timeout-minutes: 10
steps:
- uses: actions/checkout@v3

# We can remove this once we fix nix golangci-lint issue and move to devbox
- uses: actions/setup-go@v4
with:
go-version-file: ./go.mod
- run: go run ./cmd/devbox run fmt
cache: false

- name: Install devbox
uses: jetpack-io/devbox-install-action@v0.7.0
with:
enable-cache: true

- name: Mount golang cache
uses: actions/cache@v3
with:
path: |
~/.cache/golangci-lint
~/.cache/go-build
~/go/pkg
key: go-${{ runner.os }}-${{ hashFiles('go.sum') }}

- run: devbox run fmt

- name: golangci-lint
uses: golangci/golangci-lint-action@v3.7.0
with:
Expand Down
18 changes: 1 addition & 17 deletions devbox.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,23 +21,7 @@
],
"code": "code .",
"lint": "golangci-lint run",
"fmt": [
"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 {} \\+"
],
"fmt": "scripts/gofumpt.sh",
"test": "go test -race -cover ./...",
"update-examples": "devbox run build && go run testscripts/testrunner/updater/main.go"
}
Expand Down
11 changes: 11 additions & 0 deletions scripts/gofumpt.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/bash

mkdir -p dist/tools
export GOBIN="$PWD/dist/tools"
go install mvdan.cc/gofumpt@latest

find . -name '*.go' -exec "$GOBIN/gofumpt" -extra -w {} \+

if [ -n "${CI:-}" ]; then
git diff --exit-code
fi