From de8218916f5f809871bbb22dfc2bf02fc988abec Mon Sep 17 00:00:00 2001 From: alingse Date: Sun, 30 Jun 2024 21:06:59 +0800 Subject: [PATCH] add all code --- .github/jobs/alingse-makezero.yaml | 1 + ...-repos.yml => go-linter-runner-submit.yml} | 6 +- .../{run-repo.yml => go-linter-runner.yml} | 2 +- README.md | 82 ++++++++++++++----- action.yaml | 5 +- cmd/root.go | 2 +- linter-config-example.yaml | 1 + 7 files changed, 72 insertions(+), 27 deletions(-) rename .github/workflows/{submit-repos.yml => go-linter-runner-submit.yml} (84%) rename .github/workflows/{run-repo.yml => go-linter-runner.yml} (93%) diff --git a/.github/jobs/alingse-makezero.yaml b/.github/jobs/alingse-makezero.yaml index 8741fa1..9e3748f 100644 --- a/.github/jobs/alingse-makezero.yaml +++ b/.github/jobs/alingse-makezero.yaml @@ -7,4 +7,5 @@ includes: excludes: - assigned by index - funcall + - called by funcs issue_id: 1 diff --git a/.github/workflows/submit-repos.yml b/.github/workflows/go-linter-runner-submit.yml similarity index 84% rename from .github/workflows/submit-repos.yml rename to .github/workflows/go-linter-runner-submit.yml index ba8f981..67b457b 100644 --- a/.github/workflows/submit-repos.yml +++ b/.github/workflows/go-linter-runner-submit.yml @@ -1,5 +1,5 @@ name: submit-repos -run-name: "submit repo urls for run-repo.yml" +run-name: "submit repo urls for go-linter-runner.yml" on: workflow_dispatch: @@ -12,8 +12,8 @@ on: workflow: description: | the workflow to submit with each repo - Default 'run-repo.yml' - default: "run-repo.yml" + Default 'go-linter-runner.yml' + default: "go-linter-runner.yml" permissions: actions: write diff --git a/.github/workflows/run-repo.yml b/.github/workflows/go-linter-runner.yml similarity index 93% rename from .github/workflows/run-repo.yml rename to .github/workflows/go-linter-runner.yml index b06ddfc..3bcc428 100644 --- a/.github/workflows/run-repo.yml +++ b/.github/workflows/go-linter-runner.yml @@ -34,7 +34,7 @@ jobs: install_command: go install github.com/alingse/makezero@f6a823578e89de5cdfdfef50d4a5d9a09ade16dd linter_command: makezero includes: '["go", "github"]' - excludes: '["assigned by index", "funcall"]' + excludes: '["assigned by index", "funcall", "called by funcs"]' issue_id: 1 repo_url: ${{ inputs.repo_url }} env: diff --git a/README.md b/README.md index 495e11a..ef93e2e 100644 --- a/README.md +++ b/README.md @@ -1,35 +1,79 @@ # go-linter-runner -A launcher to run a specific linter for a large number of Go repositories using Github Actions. +使用 GitHub Actions 为公开的 Go 仓库运行 Go linter 并以 issue comment 的形式报告 -# Why +# 背景 -After implementing certain linters, you may want to check if online repositories also have similar issues. +在实现某些 linter 后,您可能希望检查在线仓库是否也存在类似的问题。例如,https://github.com/alingse/asasalint 和 https://github.com/ashanbrown/makezero#15 都发现了大量的在线 bug +但是,手动观察 Actions 的结果并忽略一些特定的错误可能相当繁琐,因此可以使用此项目自动化 -For example, https://github.com/alingse/asasalint and https://github.com/ashanbrown/makezero/pull/15 +# 使用 -Both have detected numerous online bugs. +推荐集成到 Github Workflow 中 -However, manually observing the results of Actions and ignoring some specific errors can be quite exhausting. +## 配置检查单个 Repo 的 Workflow -Here, you can configure additional `includes` and `excludes` to exclude false-positives that don't need to be addressed. +参考 [`.github/workflows/go-linter-runner.yml`](https://github.com/alingse/go-linter-runner/blob/main/.github/workflows/go-linter-runner.yml) 配置安装和运行 linter 的参数 -# Effects +```yaml + - name: Example -> go-linter-runner run with yaml job config + uses: alingse/go-linter-runner@main + with: + action: run + yaml_config: .github/jobs/alingse-makezero.yaml + repo_url: ${{ inputs.repo_url }} + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} -see -1. https://github.com/alingse/go-linter-runner/issues/1 -2. https://github.com/alingse/go-linter-runner/issues/2 + - name: Example -> go-linter-runner use direct job config + uses: alingse/go-linter-runner@main + with: + action: run + install_command: go install github.com/alingse/makezero@f6a823578e89de5cdfdfef50d4a5d9a09ade16dd + linter_command: makezero + includes: '["go", "github"]' + excludes: '["assigned by index", "funcall", "called by funcs"]' + issue_id: 1 + repo_url: ${{ inputs.repo_url }} + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} +``` -# Dev +## 配置提交大量检查任务的 Workflow -## storage +参考 [`.github/workflows/go-linter-runner-submit.yml`](https://github.com/alingse/go-linter-runner/blob/main/.github/workflows/go-linter-runner-submit.yml) 配置需要提交的信息 -we use https://getpantry.cloud/ as center storage when run a job +```yaml + - name: Example -> go-linter-runner submit 10 repos + uses: alingse/go-linter-runner@main + with: + action: submit + submit_source_file: top.txt + submit_repo_count: ${{ inputs.count }} + submit_workflow: ${{ inputs.workflow }} + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} +``` -# TODO +## 以本地二进制文件运行 -- [] Ability to configure more linter yaml -- [] Provide data aggregation (multiple failed Actions consolidated into a Sheet or a specific issue) -- [] Automatic issue creation for projects(may use AI) -- [] Automatic execution +```bash +go install github.com/alingse/go-linter-runner@latest +``` + +运行参考 + +```bash +go-linter-runner --help +``` + +# 其他 + +## Github 效果 + +参考 https://github.com/alingse/go-linter-runner/issues/1 的最新评论效果 + +# 贡献 + +欢迎试用, 提交 Issue 和 Pull Request! diff --git a/action.yaml b/action.yaml index 335812d..c85a87d 100644 --- a/action.yaml +++ b/action.yaml @@ -19,7 +19,6 @@ inputs: repo_url: description: | The repo to run lint, only work for github repo now - required: true workdir: description: | 'run' option: Work directory. @@ -59,8 +58,8 @@ inputs: submit_workflow: description: | 'submit' option: the workflow to auto - Default 'run-repo.yml' - default: 'run-repo.yml' + Default 'go-linter-runner.yml' + default: 'go-linter-runner.yml' runs: using: "composite" diff --git a/cmd/root.go b/cmd/root.go index 1f96f59..75627ec 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -10,7 +10,7 @@ var rootCmd = &cobra.Command{ Use: "go-linter-runner", Short: "A cli to run linter for repos use github action", Long: `A cli for run linter for github repo, and it post the result as issue comment, -It can submit many run-repo.yml task by trigger many github workflow action`, +It can submit many go-linter-runner.yml task by trigger many github workflow action`, } func Execute() { diff --git a/linter-config-example.yaml b/linter-config-example.yaml index 8741fa1..9e3748f 100644 --- a/linter-config-example.yaml +++ b/linter-config-example.yaml @@ -7,4 +7,5 @@ includes: excludes: - assigned by index - funcall + - called by funcs issue_id: 1