Skip to content

Commit

Permalink
ci: add yamllint and PR title check
Browse files Browse the repository at this point in the history
Add some basic enforcement of yaml in the repo and that PRs have a good
description for making a release cadence.
  • Loading branch information
cardoe committed Feb 1, 2024
1 parent 2689093 commit 365aec6
Show file tree
Hide file tree
Showing 5 changed files with 80 additions and 0 deletions.
15 changes: 15 additions & 0 deletions .github/pr-title-checker-config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"LABEL": {
"name": "title needs formatting",
"color": "EEEEEE"
},
"CHECKS": {
"prefixes": ["[Bot] docs: "],
"regexp": "^(feat|fix|docs|test|ci|chore)!?(\\(.*\\))?!?:.*"
},
"MESSAGES": {
"success": "PR title is valid",
"failure": "PR title is invalid",
"notice": "PR Title needs to pass regex '^(feat|fix|docs|test|ci|chore)!?(\\(.*\\))?!?:.*"
}
}
29 changes: 29 additions & 0 deletions .github/workflows/pr-title-check.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: "Lint PR"

on:
pull_request_target:
types: [opened, edited, reopened, synchronize]

# IMPORTANT: No checkout actions, scripts, or builds should be added to this workflow. Permissions should always be used
# with extreme caution. https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#pull_request_target
permissions: {}

# PR updates can happen in quick succession leading to this
# workflow being trigger a number of times. This limits it
# to one run per PR.
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}


jobs:
validate:
permissions:
contents: read
pull-requests: read
name: Validate PR Title
runs-on: ubuntu-latest
steps:
- uses: thehanimo/pr-title-checker@0cf5902181e78341bb97bb06646396e5bd354b3f # v1.4.0
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
configuration_path: ".github/pr-title-checker-config.json"
14 changes: 14 additions & 0 deletions .github/workflows/yamllint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name: Validate Manifests

on:
push:
pull_request:
workflow_dispatch:

jobs:
lint-yaml:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: pip install yamllint
- run: yamllint -c .yamllint.yaml --format github .
13 changes: 13 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: fix-byte-order-marker
- id: mixed-line-ending
- repo: https://github.com/adrienverge/yamllint
rev: v1.33.0
hooks:
- id: yamllint
args: [-c, .yamllint.yaml]
9 changes: 9 additions & 0 deletions .yamllint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
extends: default

rules:
document-start: disable
indentation:
indent-sequences: whatever
line-length: disable
truthy:
ignore: .github/workflows/

0 comments on commit 365aec6

Please sign in to comment.