Skip to content

Commit

Permalink
Enforce import order using gci
Browse files Browse the repository at this point in the history
Add linting to the pre-merge checks to enforce Go import groups:
- stdlib
- 3rd-party / non-Pebble imports
- Pebble imports
  • Loading branch information
barrettj12 authored and jnsgruk committed Jul 31, 2023
1 parent a375695 commit 731299e
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 0 deletions.
14 changes: 14 additions & 0 deletions .github/.golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
linters:
disable-all: true
enable:
- gci
linters-settings:
gci:
sections:
- standard
- default
- Prefix(github.com/canonical/pebble)
issues:
# these values ensure that all issues will be surfaced
max-issues-per-linter: 0
max-same-issues: 0
30 changes: 30 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Lint
on: [push, pull_request]

jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- uses: actions/setup-go@v4
with:
go-mod-file: 'go.mod'
cache: false

- name: golangci-lint
uses: golangci/golangci-lint-action@v3
id: lint
with:
version: latest
args: '-c .github/.golangci.yml --out-format=colored-line-number'
skip-cache: true

- name: Print error message
if: always() && steps.lint.outcome == 'failure'
run: |
echo '
Linting failed. On your local machine, please run
golangci-lint run -c .github/.golangci.yml --fix
and check in the changes.'
exit 1

0 comments on commit 731299e

Please sign in to comment.