Skip to content

Commit

Permalink
Add go fmt to CI lint job
Browse files Browse the repository at this point in the history
  • Loading branch information
brandonc committed Feb 21, 2023
1 parent 4d37358 commit 6c95c0f
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 7 deletions.
16 changes: 9 additions & 7 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
name: CI Tests
name: CI
on:
push:
branches: [ main ]
pull_request:
jobs:
lint:
name: Lint and Codegen
name: Lint
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
Expand All @@ -22,6 +22,8 @@ jobs:
with:
version: v1.50.1

- run: make fmtcheck

- name: Install mockgen
run: |
set -eux -o pipefail
Expand All @@ -42,7 +44,7 @@ jobs:
- name: verify go.mod and go.sum are consistent
run : go mod tidy

- name: Ensure nothing changed
- name: Ensure mocks are generated
run: git diff --exit-code

tests:
Expand All @@ -52,8 +54,8 @@ jobs:
fail-fast: false
matrix:
# If you adjust these parameters, also adjust the jrm input files on the "Merge reports" step below
parallel: [4]
index: [0, 1, 2, 3]
parallel: [ 4 ]
index: [ 0, 1, 2, 3 ]

timeout-minutes: 30
steps:
Expand Down Expand Up @@ -120,7 +122,7 @@ jobs:

tests-combine-summaries:
name: Combine Test Reports
needs: [tests]
needs: [ tests ]
runs-on: ubuntu-latest
steps:
- uses: actions/setup-node@v3
Expand All @@ -144,7 +146,7 @@ jobs:

tests-summarize:
name: Summarize Tests
needs: [tests]
needs: [ tests ]
runs-on: ubuntu-latest
if: ${{ always() }}
steps:
Expand Down
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ vet:
fmt:
gofmt -s -l -w .

fmtcheck:
./scripts/gofmtcheck.sh

lint:
golangci-lint run .

Expand Down
11 changes: 11 additions & 0 deletions scripts/gofmtcheck.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/usr/bin/env bash

# Copyright (c) HashiCorp, Inc.
# SPDX-License-Identifier: MPL-2.0

if ! gofmt -l -s .; then
echo "gofmt found some files that need to be formatted. You can use the command: \`make fmt\` to reformat code."
exit 1
fi

exit 0

0 comments on commit 6c95c0f

Please sign in to comment.