Dev #15
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: Pre-commit Hooks | |
| on: | |
| pull_request: | |
| branches: | |
| - main | |
| paths: | |
| - '**/*.go' | |
| jobs: | |
| pre-commit: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Set up Go | |
| uses: actions/setup-go@v4 | |
| with: | |
| go-version: '1.24.1' | |
| - name: Cache pre-commit environments | |
| uses: actions/cache@v3 | |
| with: | |
| path: ~/.cache/pre-commit | |
| key: pre-commit-${{ runner.os }}-${{ hashFiles('.pre-commit-config.yaml') }} | |
| restore-keys: | | |
| pre-commit-${{ runner.os }}- | |
| - name: Cache golangci-lint binary | |
| uses: actions/cache@v3 | |
| with: | |
| path: ~/.golangci-lint | |
| key: golangci-lint-${{ runner.os }}-v2.0.2 | |
| restore-keys: | | |
| golangci-lint-${{ runner.os }}- | |
| - name: Install pre-commit | |
| run: | | |
| pip install pre-commit | |
| - name: Install golangci-lint (if not cached) | |
| run: | | |
| if [ ! -f "$(go env GOPATH)/bin/golangci-lint" ]; then | |
| curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v2.0.2 | |
| fi | |
| echo "$(go env GOPATH)/bin" >> $GITHUB_PATH | |
| - name: Run pre-commit hooks | |
| run: pre-commit run --all-files |