我正在尝试使用 github 操作中与 golang 相关的一些挂钩运行 pre-commit.com 脚本。似乎测试环境缺少一些工具来执行 go-imports 和 golangci-lint。我已经在预提交步骤之前添加了在环境中设置所需工具的步骤,但这没有帮助。
.pre-commit-config.yaml:
repos:
- repo: https://github.com/dnephin/pre-commit-golang
rev: v0.5.0
hooks:
- id: go-imports
- id: golangci-lint
- id: go-unit-tests
github动作文件配置:
name: pre-commit
on:
pull_request:
push:
branches: [main]
jobs:
pre-commit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
- uses: actions/setup-go@v3
- run: go install golang.org/x/tools/cmd/goimports@latest
- run: curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.49.0
- uses: pre-commit/action@v2.0.2
Gihub 操作输出: 所有 go invironments 设置步骤已成功完成
pre-commit/action@v2.0.2 详情:
[...]
[INFO] This may take a few minutes...
go imports...............................................................Failed
- hook id: go-imports
- exit code: 127
/home/runner/.cache/pre-commit/repow0byklud/run-go-imports.sh: line 8: goimports: command not found
golangci-lint............................................................Failed
- hook id: golangci-lint
- exit code: 127
/home/runner/.cache/pre-commit/repow0byklud/run-golangci-lint.sh: 2: exec: golangci-lint: not found
go-unit-tests............................................................Passed
[...]
皈依舞
相关分类