From 383da14f8400b17ada1e353bb480569ce7b4e077 Mon Sep 17 00:00:00 2001 From: Joachim Hill-Grannec Date: Tue, 13 Aug 2024 16:46:31 -0600 Subject: [PATCH] feat: add pr-title check and pre-commit action --- .github/workflows/pr-title.yaml | 25 +++++++++++++++++++++++++ .github/workflows/pre-commit.yaml | 25 +++++++++++++++++++++++++ .pre-commit-config.yaml | 2 +- 3 files changed, 51 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/pr-title.yaml create mode 100644 .github/workflows/pre-commit.yaml diff --git a/.github/workflows/pr-title.yaml b/.github/workflows/pr-title.yaml new file mode 100644 index 00000000..d105f80f --- /dev/null +++ b/.github/workflows/pr-title.yaml @@ -0,0 +1,25 @@ +name: lint-pr-title + +on: + pull_request: + types: [opened, edited, reopened, synchronize] + +jobs: + pr-lint: + runs-on: ubuntu-latest + steps: + - uses: morrisoncole/pr-lint-action@v1.7.1 + with: + # Note: if you have branch protection rules enabled, the `GITHUB_TOKEN` permissions + # won't cover dismissing reviews. Your options are to pass in a custom token + # (perhaps by creating some sort of 'service' user and creating a personal access + # token with the correct permissions) or to turn off `on-failed-regex-request-changes` + # and use action failure to prevent merges instead (with + # `on-failed-regex-fail-action: true`). See: + # https://docs.github.com/en/actions/security-guides/automatic-token-authentication#permissions-for-the-github_token + # https://docs.github.com/en/rest/pulls/reviews#dismiss-a-review-for-a-pull-request + repo-token: "${{ secrets.GITHUB_TOKEN }}" + title-regex: '^(build|chore|ci|docs|feat|fix|perf|refactor|revert|style|test){1}(\([\w\-\.]+\))?(!)?: ([\w ])+([\s\S]*)' + on-failed-regex-fail-action: true + on-failed-regex-create-review: false + on-failed-regex-request-changes: false diff --git a/.github/workflows/pre-commit.yaml b/.github/workflows/pre-commit.yaml new file mode 100644 index 00000000..db192ac8 --- /dev/null +++ b/.github/workflows/pre-commit.yaml @@ -0,0 +1,25 @@ +name: pre-commit +on: + push: + branches: + - main + pull_request: + branches: + - main + +jobs: + pre-commit: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: install pre-commit + run: pip install pre-commit + + - name: Build dependencies Helm - nidhogg + uses: WyriHaximus/github-action-helm3@v4 + with: + exec: helm dependency build charts/nidhogg + + - name: pre-commit + run: pre-commit run --all-files --show-diff-on-failure diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 9d93d706..dc551b5e 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -21,7 +21,7 @@ repos: - id: yamllint args: [--strict, -c=.yamllint] - repo: https://github.com/alessandrojcm/commitlint-pre-commit-hook - rev: v9.11.0 + rev: v9.16.0 hooks: - id: commitlint stages: [commit-msg]