Skip to content

Commit

Permalink
Start to consume the go formatting actions
Browse files Browse the repository at this point in the history
Signed-off-by: Matt Moore <[email protected]>
  • Loading branch information
mattmoor committed Feb 21, 2022
1 parent 73b46a3 commit 0cc992f
Showing 1 changed file with 19 additions and 36 deletions.
55 changes: 19 additions & 36 deletions .github/workflows/style.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,51 +7,34 @@ on:
permissions: read-all

jobs:
autoformat:
name: Auto-format and Check
gofmt:
name: check gofmt
runs-on: ubuntu-latest

strategy:
fail-fast: false # Keep running if one leg fails.
matrix:
tool:
- goimports
- gofmt
steps:
- name: Set up Go
uses: actions/setup-go@424fc82d43fa5a37540bae62709ddcc23d9520d4 #v2.1.5
with:
go-version: 1.16.x

include:
- tool: gofmt
options: -s
- tool: goimports
importpath: golang.org/x/tools/cmd/goimports
- name: Check out code
uses: actions/checkout@ec3a7ce113134d7a93b817d10a8272cb61118579 #v2.4.0

- uses: chainguard-dev/actions/gofmt@main
with:
args: -s

goimports:
name: check goimports
runs-on: ubuntu-latest

steps:
- name: Set up Go 1.16.x
- name: Set up Go
uses: actions/setup-go@424fc82d43fa5a37540bae62709ddcc23d9520d4 #v2.1.5
with:
go-version: 1.16.x
id: go

- name: Check out code
uses: actions/checkout@ec3a7ce113134d7a93b817d10a8272cb61118579 #v2.4.0

- name: Install Dependencies
if: ${{ matrix.importpath != '' }}
run: |
cd $(mktemp -d)
GO111MODULE=on go get ${{ matrix.importpath }}
- name: ${{ matrix.tool }} ${{ matrix.options }}
shell: bash
run: >
${{ matrix.tool }} ${{ matrix.options }} -w
$(find .
-path './vendor' -prune
-o -path './third_party' -prune
-o -name '*.pb.go' -prune
-o -name 'wire_gen.go' -prune
-o -type f -name '*.go' -print)
- name: Verify ${{ matrix.tool }}
uses: chainguard-dev/actions/nodiff@main
with:
fixup-command: "${{ matrix.tool }} ${{ matrix.options }}"
- uses: chainguard-dev/actions/goimports@main

0 comments on commit 0cc992f

Please sign in to comment.