diff --git a/go.mod b/go.mod new file mode 100644 index 0000000..289cd40 --- /dev/null +++ b/go.mod @@ -0,0 +1,4 @@ +module example.com/m + +go 1.22.3 + diff --git a/workflow.yml b/workflow.yml new file mode 100644 index 0000000..80da21a --- /dev/null +++ b/workflow.yml @@ -0,0 +1,45 @@ +name: GoLint + +on: + push: + branches: + - main + pull_request: + branches: + - main + +jobs: + lint: + name: Lint + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v2 + + - name: Set up Go + uses: actions/setup-go@v2 + with: + go-version: '1.22' + + - name: Run linter + run: | + go get -u golang.org/x/lint/golint + golint ./... + + - name: Review code + if: always() + uses: actions/github-script@0.9.0 + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + script: | + const outputs = []; + const lintOutput = require('child_process') + .execSync('golint ./...', { encoding: 'utf8' }); + outputs.push(lintOutput); + if (outputs.length) { + console.log('Found linting issues:'); + outputs.forEach(output => console.log(output)); + throw new Error('Linting issues were found. Please fix them before merging.'); + } else { + console.log('No linting issues found.'); + }