From a409e521e0911517ed8acdbbde54bf0146cfa8b3 Mon Sep 17 00:00:00 2001 From: Charles Dixon Date: Tue, 15 Oct 2024 09:52:24 +0100 Subject: [PATCH] Add github action for lint validation --- .github/workflows/lint.yml | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 .github/workflows/lint.yml diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml new file mode 100644 index 0000000..4a5f853 --- /dev/null +++ b/.github/workflows/lint.yml @@ -0,0 +1,35 @@ +name: Run Linter +on: + push: + tags: + - v* + branches: + - master + pull_request: +jobs: + lint: + name: Lint + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-go@v5 + with: + go-version: '1.20' + - run: | + go install golang.org/x/tools/cmd/goimports@latest + - name: goimports + run: | + goimports -w . + find . -name go.mod -execdir go mod tidy \; + if [ -n "$(git status --porcelain)" ]; then + echo 'To fix this check, run "goimports -w . && find . -name go.mod -execdir go mod tidy \;"' + git status # Show the files that failed to pass the check. + exit 1 + fi + - name: golangci-lint + uses: golangci/golangci-lint-action@v2 + with: + version: v1.55 + args: --timeout=3m + skip-pkg-cache: true + skip-build-cache: true