|
| 1 | +--- |
| 2 | +name: Add new linter checklist |
| 3 | +on: |
| 4 | + pull_request: |
| 5 | + types: |
| 6 | + - labeled |
| 7 | + |
| 8 | +jobs: |
| 9 | + add-comment: |
| 10 | + if: "github.event.label.name == 'linter: new'" |
| 11 | + runs-on: ubuntu-latest |
| 12 | + permissions: |
| 13 | + pull-requests: write |
| 14 | + |
| 15 | + steps: |
| 16 | + - name: Add checklist |
| 17 | + run: | |
| 18 | + # This is just safety to not spam with new comments if the tag is |
| 19 | + # removed and added back multiple times maliciously. It will reset the |
| 20 | + # checklist but the previous values will be in the edit history. |
| 21 | + comment_exist=$(gh pr view "$NUMBER" \ |
| 22 | + --json comments \ |
| 23 | + --jq '.comments[].author | select(.login=="github-actions") | .login' \ |
| 24 | + | wc -l) |
| 25 | + [ "$comment_exist" -gt 0 ] && edit_last="--edit-last" |
| 26 | +
|
| 27 | + # Comment on the PR with the checklist. |
| 28 | + gh pr comment "$NUMBER" --body "$BODY" $edit_last |
| 29 | + env: |
| 30 | + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 31 | + GH_REPO: ${{ github.repository }} |
| 32 | + NUMBER: ${{ github.event.number }} |
| 33 | + BODY: | |
| 34 | + In order for a pull request adding a linter to be reviewed, the linter and the PR must follow some requirements. |
| 35 | +
|
| 36 | + - [ ] The CLA must be signed |
| 37 | +
|
| 38 | + ### Pull Request Description |
| 39 | +
|
| 40 | + - [ ] It must have a link to the linter repository. |
| 41 | + - [ ] It must provide a short description of the linter. |
| 42 | +
|
| 43 | + ### Linter |
| 44 | +
|
| 45 | + - [ ] It must not be a duplicate of another linter or a rule of a linter. (the team will help to verify that) |
| 46 | + - [ ] It must have a valid license (AGPL is not allowed) and the file must contain the required information by the license, ex: author, year, etc. |
| 47 | + - [ ] The linter repository must have a CI and tests. |
| 48 | + - [ ] It must use [`go/analysis`](https://golangci-lint.run/contributing/new-linters/). |
| 49 | + - [ ] It must have a valid tag, ex: `v1.0.0`, `v0.1.0`. |
| 50 | + - [ ] It must not contain `init()`. |
| 51 | + - [ ] It must not contain `panic()`. |
| 52 | + - [ ] It must not contain `log.fatal()`, `os.exit()`, or similar. |
| 53 | + - [ ] It must not modify the AST. |
| 54 | + - [ ] It must not have false positives/negatives. (the team will help to verify that) |
| 55 | + - [ ] It must have tests inside golangci-lint. |
| 56 | +
|
| 57 | + ### The Linter Tests Inside Golangci-lint |
| 58 | +
|
| 59 | + - [ ] They must have at least one std lib import. |
| 60 | + - [ ] They must have integration tests without configuration (default). |
| 61 | + - [ ] They must have integration tests with configuration (if the linter has a configuration). |
| 62 | +
|
| 63 | + ### `.golangci.next.reference.yml` |
| 64 | +
|
| 65 | + - [ ] The file `.golangci.next.reference.yml` must be updated. |
| 66 | + - [ ] The file `.golangci.reference.yml` must NOT be edited. |
| 67 | + - [ ] The linter must be added to the lists of available linters (alphabetical case-insensitive order). |
| 68 | + - `enable` and `disable` options |
| 69 | + - [ ] If the linter has a configuration, the exhaustive configuration of the linter must be added (alphabetical case-insensitive order) |
| 70 | + - The values must be different from the default ones. |
| 71 | + - The default values must be defined in a comment. |
| 72 | + - The option must have a short description. |
| 73 | +
|
| 74 | + ### Others Requirements |
| 75 | +
|
| 76 | + - [ ] The files (tests and linter) inside golangci-lint must have the same name as the linter. |
| 77 | + - [ ] The `.golangci.yml` of golangci-lint itself must not be edited and the linter must not be added to this file. |
| 78 | + - [ ] The linters must be sorted in the alphabetical order (case-insensitive) in the `lintersdb/builder_linter.go` and `.golangci.next.reference.yml`. |
| 79 | + - [ ] The load mode (`WithLoadMode(...)`): |
| 80 | + - if the linter uses `goanalysis.LoadModeSyntax` -> no `WithLoadForGoAnalysis()` in `lintersdb/builder_linter.go` |
| 81 | + - if the linter uses `goanalysis.LoadModeTypesInfo`, it requires `WithLoadForGoAnalysis()` in `lintersdb/builder_linter.go` |
| 82 | + - [ ] The version in `WithSince(...)` must be the next minor version (`v1.X.0`) of golangci-lint. |
| 83 | + - [ ] `WithURL()` must contain the URL of the repository. |
| 84 | + - [ ] The linter must use go1.21 |
| 85 | +
|
| 86 | + ### Recommendations |
| 87 | +
|
| 88 | + - [ ] The file `jsonschema/golangci.next.jsonschema.json` should be updated. |
| 89 | + - [ ] The file `jsonschema/golangci.jsonschema.json` must NOT be edited. |
| 90 | + - [ ] The linter repository should have a readme and linting. |
| 91 | + - [ ] The linter should be published as a binary. (useful to diagnose bug origins) |
| 92 | + - [ ] The linter repository should have a `.gitignore` (IDE files, binaries, OS files, etc. should not be committed) |
| 93 | + - [ ] A tag should never be recreated. |
| 94 | +
|
| 95 | + --- |
| 96 | +
|
| 97 | + The golangci-lint team will edit this comment to check the boxes before and during the review. |
| 98 | +
|
| 99 | + The code review will start after the completion of those checkboxes (except for the specific items that the team will help to verify). |
| 100 | +
|
| 101 | + The reviews should be addressed as commits (no squash). |
| 102 | +
|
| 103 | + If the author of the PR is a member of the golangci-lint team, he should not edit this message. |
| 104 | +
|
| 105 | + **This checklist does not imply that we will accept the linter.** |
0 commit comments