mirror of
https://github.com/EttusResearch/uhd.git
synced 2026-10-25 17:36:10 +00:00
Add commitlint workflow for testing
This commit is contained in:
parent
0d7ed3b1a4
commit
7612928ca1
38
.github/workflows/.commitlintrc.cjs
vendored
Normal file
38
.github/workflows/.commitlintrc.cjs
vendored
Normal file
@ -0,0 +1,38 @@
|
||||
// Parse UHD's area-prefixed subjects and apply repository message limits.
|
||||
module.exports = {
|
||||
parserPreset: {
|
||||
parserOpts: {
|
||||
headerPattern: /^(\S(?:.*\S)?): (\S(?:.*\S)?)$/,
|
||||
headerCorrespondence: ['scope', 'subject'],
|
||||
},
|
||||
},
|
||||
plugins: [
|
||||
{
|
||||
rules: {
|
||||
'header-ideal-length': (parsed, when, value) => {
|
||||
const isValid = parsed.header.length <= value;
|
||||
return [
|
||||
when === 'never' ? !isValid : isValid,
|
||||
`header should be ${value} characters or fewer`,
|
||||
];
|
||||
},
|
||||
'no-fixup-commit': (parsed) => [
|
||||
!/^fixup!\s/i.test(parsed.header)
|
||||
&& !/:\s*fixup!\s/i.test(parsed.header),
|
||||
'fixup commits are not allowed',
|
||||
],
|
||||
},
|
||||
},
|
||||
],
|
||||
defaultIgnores: false,
|
||||
rules: {
|
||||
'scope-empty': [2, 'never'],
|
||||
'subject-empty': [2, 'never'],
|
||||
'header-ideal-length': [1, 'always', 50],
|
||||
'header-max-length': [2, 'always', 72],
|
||||
'body-empty': [2, 'never'],
|
||||
'body-leading-blank': [2, 'always'],
|
||||
'body-max-line-length': [2, 'always', 72],
|
||||
'no-fixup-commit': [2, 'always'],
|
||||
},
|
||||
};
|
||||
35
.github/workflows/commitlint.yml
vendored
Normal file
35
.github/workflows/commitlint.yml
vendored
Normal file
@ -0,0 +1,35 @@
|
||||
name: Commit Message Lint
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
types: [opened, synchronize, reopened, ready_for_review]
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
commitlint:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Check out pull request head
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
ref: ${{ github.event.pull_request.head.sha }}
|
||||
fetch-depth: 0
|
||||
persist-credentials: false
|
||||
|
||||
- name: Set up Node.js
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 20
|
||||
|
||||
- name: Lint pull request commits
|
||||
env:
|
||||
BASE_SHA: ${{ github.event.pull_request.base.sha }}
|
||||
HEAD_SHA: ${{ github.event.pull_request.head.sha }}
|
||||
run: |
|
||||
# Lint only commits introduced by this pull request.
|
||||
npx --yes --package @commitlint/cli@19.8.1 -- commitlint \
|
||||
--config .github/workflows/.commitlintrc.cjs \
|
||||
--from="$BASE_SHA" \
|
||||
--to="$HEAD_SHA"
|
||||
Loading…
Reference in New Issue
Block a user