From f9c0755fab2c2ea00a49aee492985dd7f6c7e804 Mon Sep 17 00:00:00 2001 From: Jordan Barrett Date: Wed, 5 Jul 2023 14:58:58 +1200 Subject: [PATCH] Enforce import order using gci Add linting to the pre-merge checks to enforce Go import groups: - stdlib - 3rd-party / non-Pebble imports - Pebble imports --- .github/.golangci.yml | 10 ++++++++++ .github/workflows/lint.yml | 20 ++++++++++++++++++++ 2 files changed, 30 insertions(+) create mode 100644 .github/.golangci.yml create mode 100644 .github/workflows/lint.yml diff --git a/.github/.golangci.yml b/.github/.golangci.yml new file mode 100644 index 000000000..5c17c06e6 --- /dev/null +++ b/.github/.golangci.yml @@ -0,0 +1,10 @@ +linters: + disable-all: true + enable: + - gci +linters-settings: + gci: + sections: + - standard + - default + - Prefix(github.com/canonical/pebble) \ No newline at end of file diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml new file mode 100644 index 000000000..7fe5a7b5b --- /dev/null +++ b/.github/workflows/lint.yml @@ -0,0 +1,20 @@ +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 + with: + version: latest + args: '-c .github/.golangci.yml' + skip-cache: true \ No newline at end of file