build(deps): bump actions/setup-go from 6 to 7 #1127
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: | |
| push: | |
| branches: | |
| - master | |
| pull_request: | |
| jobs: | |
| py-black: | |
| name: Python Formatter | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v7 | |
| - uses: psf/black@stable | |
| go-fmt: | |
| name: Go Formatter | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v7 | |
| - name: Read go version | |
| id: go_version | |
| run: | | |
| # Read the variable from the file | |
| GO_VERSION=$(grep '^go ' go.mod | awk '{print $2}') | |
| # Set the variable as an output | |
| echo "GO_VERSION=$GO_VERSION" >> $GITHUB_OUTPUT | |
| - name: Set up Go | |
| uses: actions/setup-go@v7 | |
| with: | |
| go-version: ${{ steps.go_version.outputs.GO_VERSION }} | |
| - name: Run go fmt | |
| run: | | |
| NON_COMPLIANT_FILES=$(gofmt -s -l $(find . -type f -name '*.go'| grep -v "/.template/")) | |
| if [ -n "$NON_COMPLIANT_FILES" ]; then | |
| echo "The following files are not formatted correctly:" | |
| echo "$NON_COMPLIANT_FILES" | |
| mkdir -p /tmp/gofmt | |
| for file in $NON_COMPLIANT_FILES; do | |
| mkdir -p /tmp/gofmt/$(dirname $file) | |
| gofmt -s $file > /tmp/gofmt/$file | |
| done | |
| exit 1 | |
| fi | |
| - name: Upload formatted files | |
| if: failure() | |
| uses: actions/upload-artifact@v7 | |
| with: | |
| name: formatted-files | |
| path: /tmp/gofmt | |
| goimports-and-golangci-lint: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v7 | |
| - name: Read go version | |
| id: go_version | |
| run: | | |
| # Read the variable from the file | |
| GO_VERSION=$(grep '^go ' go.mod | awk '{print $2}') | |
| # Set the variable as an output | |
| echo "GO_VERSION=$GO_VERSION" >> $GITHUB_OUTPUT | |
| - name: Set up Go | |
| uses: actions/setup-go@v7 | |
| with: | |
| go-version: ${{ steps.go_version.outputs.GO_VERSION }} | |
| - name: Other lint | |
| run: | | |
| go install golang.org/x/tools/cmd/goimports@latest | |
| output=$(goimports -d -local "github.com/zmap/zdns" ./) | |
| if [ -n "$output" ]; then | |
| echo "goimports found issues:" | |
| echo "$output" | |
| exit 1 | |
| else | |
| echo "No issues found by goimports." | |
| fi | |
| output=$(gofmt -d .) | |
| if [ -n "$output" ]; then | |
| echo "gofmt found issues:" | |
| echo "$output" | |
| exit 1 | |
| else | |
| echo "No issues found by gofmt." | |
| fi | |
| - name: golangci-lint | |
| uses: golangci/golangci-lint-action@v9.3.0 |