diff --git a/.changes/unreleased/Added-20230414-160033.yaml b/.changes/unreleased/Added-20230414-160033.yaml new file mode 100644 index 00000000..ac665dc3 --- /dev/null +++ b/.changes/unreleased/Added-20230414-160033.yaml @@ -0,0 +1,5 @@ +kind: Added +body: add workflow to run pre-commit checks +time: 2023-04-14T16:00:33.720896+01:00 +custom: + GithubIssue: "" diff --git a/.github/workflows/pre-commit.yml b/.github/workflows/pre-commit.yml new file mode 100644 index 00000000..5c34465a --- /dev/null +++ b/.github/workflows/pre-commit.yml @@ -0,0 +1,50 @@ +--- +# yamllint disable-line rule:truthy +on: + pull_request: + +name: pre-commit + +env: + # https://laszlo.cloud/setting-gopath-in-github-actions + GOPATH: /home/runner/work/woodpecker/go + +jobs: + linting: + name: Run Checks + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + + # https://github.com/actions/setup-python#usage + - name: Set up Python 3.x + uses: actions/setup-python@v4 + with: + python-version: 3.x + + # yamllint disable-line rule:line-length + # https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#adding-a-system-path + - name: Update PATH + run: | + echo $PATH + echo "$GOPATH/bin" >> $GITHUB_PATH + + - name: Install external deps for precommit + # yamllint disable rule:line-length + run: | + curl -fsSL https://raw.githubusercontent.com/infracost/infracost/master/scripts/install.sh | sh + go install github.com/sqs/goreturns@latest + go install github.com/securego/gosec/v2/cmd/gosec@latest + go install github.com/mgechev/revive@latest + go install golang.org/x/tools/cmd/goimports@latest + # goreturns doesn't share its version + # goimports doesn't share its version + gosec --version + revive --version + # yamllint enable rule:line-length + + - name: Run precommit checks + run: | + pip install pre-commit + pre-commit run --all-files