ci: add golangci-lint GitHub Actions workflow #3
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Lint | |
| on: | |
| pull_request: | |
| branches: [ main ] | |
| jobs: | |
| lint: | |
| name: Markdown and Go | |
| runs-on: ubuntu-latest | |
| permissions: | |
| # Required: allow read access to the content for analysis. | |
| contents: read | |
| steps: | |
| - name: Check out code into the Go module directory | |
| uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 | |
| - name: Set up Go | |
| uses: actions/setup-go@4a3601121dd01d1626a1e23e37211e3254c1c06c # v6.4.0 | |
| with: | |
| go-version-file: go.mod | |
| - name: Go formatting | |
| run: | | |
| if [ -z "$(gofmt -l .)" ]; then | |
| echo -e "All '*.go' files are properly formatted." | |
| else | |
| echo -e "Please run 'make lint' to fix. Some files need formatting:" | |
| gofmt -d -l . | |
| exit 1 | |
| fi | |
| - name: Read golangci-lint version from Makefile | |
| id: lint-version | |
| run: echo "version=$(grep -oP 'GOLANGCI_LINT_VERSION\s*=\s*\K\S+' Makefile)" >> $GITHUB_OUTPUT | |
| # https://github.com/golangci/golangci-lint-action?tab=readme-ov-file#verify | |
| - name: Verify linter configuration and Lint go code | |
| uses: golangci/golangci-lint-action@1e7e51e771db61008b38414a730f564565cf7c20 # v9.2.0 | |
| with: | |
| verify: true | |
| args: --timeout=30m | |
| version: ${{ steps.lint-version.outputs.version }} |