generated from kubernetes/kubernetes-template-project
-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This adds sample actions workflows for the verifier (moved from README) and golangci-lint, adapted from the ones in KB and CR, plus instructions.
- Loading branch information
1 parent
f1629d0
commit 4886424
Showing
7 changed files
with
138 additions
and
27 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
run: | ||
deadline: 5m | ||
linters-settings: | ||
dupl: | ||
threshold: 400 | ||
issues: | ||
# don't skip warning about doc comments | ||
exclude-use-default: false | ||
# restore some of the defaults | ||
# (fill in the rest as needed) | ||
exclude-rules: | ||
- linters: [gosec] | ||
path: "test/e2e/*" | ||
# turn this on to ignore return value checks on | ||
# * fmt.Fprintf to stdout/error | ||
# * Close/Flush/Remove/RemoveAll | ||
# * Setenv/UnSetenv | ||
#- linters: [errcheck] | ||
# text: "Error return value of .((os\\.)?std(out|err)\\..*|.*Close|.*Flush|os\\.Remove(All)?|.*printf?|os\\.(Un)?Setenv). is not checked" | ||
linters: | ||
disable-all: true | ||
enable: | ||
# keep these sorted if you modify (e.g. in vim, linewise visual + :sort) | ||
- deadcode | ||
- dupl | ||
- errcheck | ||
- exportloopref | ||
- gocyclo | ||
- gofmt | ||
- goimports | ||
- golint | ||
- gosec | ||
- gosimple | ||
- govet | ||
- ineffassign | ||
- maligned | ||
- misspell | ||
- nakedret | ||
- prealloc | ||
- staticcheck | ||
- structcheck | ||
- typecheck | ||
- unconvert | ||
- unparam | ||
- unused | ||
- varcheck | ||
|
||
# These may be useful, but are generally more annoying than not: | ||
# - goconst # this one doesn't quite know what is and isn't a magic string | ||
# - interfacer # doesn't understand that interfaces have semantic meaning | ||
# - lll # fiddly, use your best judgement |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# Sample GitHub Actions Workflows | ||
|
||
These include GitHub Actions Worflows for use in KubeBuilder projects. | ||
|
||
## PR Verifier | ||
|
||
**File(s)**: | ||
|
||
- [verifier.yml](verifier.yml) (`/.github/workflows/verifier.yml`) | ||
|
||
This uses the [PR Verifier Action](/action.yml) to verify PR title and | ||
contents according to [the PR guidelines](/VERSIONING.md). | ||
|
||
[verifier-action]: /action.yml | ||
|
||
## Lint | ||
|
||
**File(s)**: | ||
|
||
- [lint.yml](lint.yml) (`/.github/workflows/lint.yml`) | ||
- [.golangci.yml](.golangci.yml) (`/.golangci.yml`) | ||
|
||
This uses [golangci-lint](https://github.com/golangci/golangci-lint) to | ||
lint our code. | ||
|
||
Use the included config file at the root of your repo to configure what | ||
linters run by default (golangci-lint has some strange defaults, and this | ||
config should be used more-or-less for all KubeBuilder projects). |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
name: golangci-lint | ||
|
||
on: | ||
# run on PRs... | ||
pull_request_target: | ||
types: [opened, synchronize, reopened] | ||
|
||
# ... and also continuously | ||
push: | ||
branches: | ||
- master | ||
|
||
|
||
jobs: | ||
golangci: | ||
name: lint | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: golangci-lint | ||
uses: golangci/golangci-lint-action@v2 | ||
with: | ||
# Required: the version of golangci-lint is required and must be | ||
# specified without patch version: we always use the latest patch | ||
# version. | ||
version: v1.29 |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
name: PR Verifier | ||
|
||
on: | ||
# NB: using `pull_request_target` runs this in the context of | ||
# the base repository, so it has permission to upload to the checks API. | ||
# This means changes won't kick in to this file until merged onto the | ||
# main branch. | ||
pull_request_target: | ||
# synchronize because this will cause the HEAD commit to change, | ||
# invalidating where we've placed our results | ||
types: [opened, edited, synchronize, reopened] | ||
|
||
jobs: | ||
verify: | ||
runs-on: ubuntu-latest | ||
name: verify PR contents | ||
steps: | ||
- name: Verifier action | ||
id: verifier | ||
uses: kubernetes-sigs/kubebuilder-release-tools@v0.1 | ||
with: | ||
github_token: ${{ secrets.GITHUB_TOKEN }} |