Skip to content

ci: enforce semantic PRs; PR template #75

ci: enforce semantic PRs; PR template

ci: enforce semantic PRs; PR template #75

Workflow file for this run

name: PR Evaluation
on:
pull_request:
types: [opened, synchronize, reopened, ready_for_review, edited]
branches: ['main']
jobs:
debug:
name: Debug
runs-on: ubuntu-latest
steps:
- name: Dump GitHub context
env:
GITHUB_CONTEXT: ${{ toJson(github.event.changes) }}
run: echo "$GITHUB_CONTEXT"
- name: Dump GitHub context (is title)
env:
IS_TITLE: ${{ github.event.changes.title }}
run: echo "$IS_TITLE"
semantic_pr:
name: Semantic PR title
runs-on: ubuntu-latest
if: ${{ github.event.action != 'edited' || github.event.changes.title != null }}
steps:
- uses: amannn/action-semantic-pull-request@v5
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
# Configure which types are allowed (newline-delimited).
# Default: https://github.com/commitizen/conventional-commit-types
types: |
fix
feat
docs
style
refactor
perf
test
build
ci
chore
revert
# Configure that a scope must always be provided.
requireScope: true
# Configure additional validation for the subject based on a regex.
# This example ensures the subject doesn't start with an uppercase character & has more than 50 chars.
subjectPattern: ^(?![A-Z])(?=.{1,50}$).+$
# If `subjectPattern` is configured, you can use this property to override
# the default error message that is shown when the pattern doesn't match.
# The variables `subject` and `title` can be used within the message.
subjectPatternError: |
The subject "{subject}" found in the pull request title "{title}"
didn't match the configured pattern. Please ensure that the subject
doesn't start with an uppercase character & not have more than 50 characters.
detect-unresolved-conflicts:
name: Detect unresolved merge conflicts
runs-on: ubuntu-latest
needs: semantic_pr
steps:
- uses: actions/checkout@v3
- name: List files with merge conflict markers
run: git --no-pager grep "<<<<<<<" ":(exclude).github/" || true
- name: Fail or succeed job if any files with merge conflict markers have been checked in
# Find lines containing "<<<<<<<", then count the number of lines.
# 0 matching lines results in exit code 0, i.e. success.
run: exit $(git grep "<<<<<<<" ":(exclude).github/" | wc --lines)
linters:
name: Linting checks
runs-on: ubuntu-latest
needs: semantic_pr
steps:
- name: Check out code
uses: actions/checkout@v3
with:
fetch-depth: 2
- name: Use Node.js 20.x
uses: actions/setup-node@v3
with:
node-version: 20.x
cache: 'npm'
- name: Install dependencies
run: npm install
- name: Run linters
run: npm run lint
tests:
name: Test checks
runs-on: ubuntu-latest
needs: semantic_pr
strategy:
matrix:
node-version: [18.x, 20.x]
steps:
- name: Check out code
uses: actions/checkout@v3
with:
fetch-depth: 2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'
- name: Install dependencies
run: npm install
- name: Run tests
run: npm run test