Skip to content
This repository was archived by the owner on Oct 12, 2024. It is now read-only.

Commit c088e8c

Browse files
authored
ci: lint pull request and YAML files (#2)
Makes sure to have valid pull request titles (for semantic versioning) and valid YAML files.
1 parent f8fbb40 commit c088e8c

File tree

4 files changed

+87
-0
lines changed

4 files changed

+87
-0
lines changed

.github/workflows/lint-files.yml

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
---
2+
name: "Lint/Validate files"
3+
4+
on: # yamllint disable-line rule:truthy
5+
pull_request:
6+
7+
jobs:
8+
lint-yaml:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- uses: actions/checkout@v2
12+
- name: Validate YAML file
13+
run: find . \( -name "*.yml" -o -name "*.yaml" \) | xargs yamllint -c .yamllint.yml --strict
+60
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
---
2+
name: "Lint Pull Request"
3+
4+
on: # yamllint disable-line rule:truthy
5+
pull_request_target:
6+
types:
7+
- opened
8+
- edited
9+
- synchronize
10+
11+
jobs:
12+
main:
13+
name: Validate PR title
14+
runs-on: ubuntu-latest
15+
steps:
16+
- uses: amannn/[email protected]
17+
with:
18+
# Default: https://github.com/commitizen/conventional-commit-types
19+
types: |
20+
build
21+
chore
22+
ci
23+
docs
24+
feat
25+
fix
26+
perf
27+
refactor
28+
revert
29+
style
30+
test
31+
# Configure which scopes are allowed.
32+
scopes: |
33+
deps
34+
# Configure that a scope must always be provided.
35+
requireScope: false
36+
# Configure additional validation for the subject based on a regex.
37+
# This example ensures the subject doesn't start with an uppercase character.
38+
subjectPattern: ^(?![A-Z]).+$
39+
# If `subjectPattern` is configured, you can use this property to override
40+
# the default error message that is shown when the pattern doesn't match.
41+
# The variables `subject` and `title` can be used within the message.
42+
subjectPatternError: |
43+
The subject "{subject}" found in the pull request title "{title}"
44+
didn't match the configured pattern. Please ensure that the subject
45+
doesn't start with an uppercase character.
46+
# For work-in-progress PRs you can typically use draft pull requests
47+
# from GitHub. However, private repositories on the free plan don't have
48+
# this option and therefore this action allows you to opt-in to using the
49+
# special "[WIP]" prefix to indicate this state. This will avoid the
50+
# validation of the PR title and the pull request checks remain pending.
51+
# Note that a second check will be reported if this is enabled.
52+
wip: true
53+
# When using "Squash and merge" on a PR with only one commit, GitHub
54+
# will suggest using that commit message instead of the PR title for the
55+
# merge commit, and it's easy to commit this by mistake. Enable this option
56+
# to also validate the commit message for one commit PRs.
57+
validateSingleCommit: false
58+
# Related to `validateSingleCommit` you can opt-in to validate that the PR
59+
# title matches a single commit to avoid confusion.
60+
validateSingleCommitMatchesPrTitle: false

.yamllint.yml

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
---
2+
extends: default
3+
4+
rules:
5+
line-length:
6+
max: 132
7+
level: warning
8+
9+
comments:
10+
min-spaces-from-content: 1

README.md

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
## Workflows
2+
3+
- lints all YAML files
4+
- lints the title of pull requests

0 commit comments

Comments
 (0)