Skip to content

Commit

Permalink
ci: enforce semantic PRs; PR template (#70)
Browse files Browse the repository at this point in the history
Co-authored-by: Anurag Gupta <[email protected]>
  • Loading branch information
anuragxxd authored Jun 20, 2023
1 parent 81f7611 commit fa62ec3
Show file tree
Hide file tree
Showing 3 changed files with 89 additions and 66 deletions.
55 changes: 55 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: Deployment Workflow

on:
push:
branches:
- main

jobs:

linters:
name: Linting checks
runs-on: ubuntu-latest

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
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
37 changes: 23 additions & 14 deletions .github/workflows/main.yml → .github/workflows/pr_evaluation.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
name: PR Evaluation & Deployment Workflow
name: PR Evaluation

on:
pull_request:
types: edited
branches: ['main']
push:
types: [opened, synchronize, reopened, ready_for_review, edited]
branches: ['main']

jobs:

lint_pr:
name: Validate PR 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:
Expand All @@ -31,8 +30,6 @@ jobs:
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}$).+$
Expand All @@ -44,23 +41,34 @@ jobs:
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
strategy:
matrix:
node-version: [18.x, 20.x]
needs: semantic_pr

steps:
- name: Check out code
uses: actions/checkout@v3
with:
fetch-depth: 2

- name: Use Node.js ${{ matrix.node-version }}
- name: Use Node.js 20.x
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
node-version: 20.x
cache: 'npm'

- name: Install dependencies
Expand All @@ -72,6 +80,7 @@ jobs:
tests:
name: Test checks
runs-on: ubuntu-latest
needs: semantic_pr
strategy:
matrix:
node-version: [18.x, 20.x]
Expand All @@ -92,4 +101,4 @@ jobs:
run: npm install

- name: Run tests
run: npm run test
run: npm run test
63 changes: 11 additions & 52 deletions PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -1,65 +1,24 @@
## Description

> Please include a summary of the change and the relevant issue(s) it resolves,
> if any (otherwise delete that line). Please also include relevant motivation
> and context briefly, especially if there exists no related issue and the
> change is non-trivial. List any dependencies that are required for this
> change. Please use bullet points for the description. For very trivial issues
> that are duly explained by the PR title, a description can be omitted.
-
> Please include a summary of the change and the relevant issue(s) it resolves, if any (otherwise delete that line).
Fixes #(issue)

## Checklist

> Please go through the following checklist to ensure that your change is ready
> for review. Please do not forget to double check the list after you have
> modified your PR, e.g., if you have added commits to address reviewer
> comments or to fix failing automated checks. Please check items also if they
> do not apply to your change, e.g., if your change does not require an update
> of the user-facing documentation, then still check the box. Generally, PRs
> are only reviewed when all boxes are ticked off and all automated checks pass
> (use the comment section below if you believe that your PR is ready to be
> merged even though not all boxes were ticked off).
> Please go through the following checklist to ensure that your change is ready for review.
- [ ] My code follows the [contributing guidelines][contributing] of this
project, including, in particular, with regard to any style guidelines
- [ ] The title of my PR complies with the [Conventional Commits
specification][conventional-commits]; in particular, it clearly indicates
that a change is a breaking change
- [ ] I am aware that all my commits will be squashed into a single commit,
using the PR title as the commit message.
- [ ] I have performed a self-review of my own code
- [ ] I have commented my code in hard-to-understand areas
- [ ] I have updated the user-facing documentation to describe any new or
changed behavior
- [ ] I have added type annotations for all function/class/method interfaces
or updated existing ones
- [ ] I have provided [JSDoc][jsdoc] block tags for all
functions/classes/methods or updated existing ones
- [ ] My changes generate no new warnings
- [ ] I have added tests that prove my fix is effective or that my feature
works
- [ ] New and existing unit tests pass locally with my changes
- [ ] I have not reduced the existing code coverage
- [ ] I have asked the [@all-contributors bot][all-contributors-bot] to
acknowledge my contributions by commenting on this PR with a request of
the form `@all-contributors please add @YOUR_GH_HANDLE for TYPE_1,
TYPE_2, ...`, where `TYPE_1` etc. refer to [contribution types supported
by the All Contributors Specification][all-contributors-types] OR I do
not want my contributions to be acknowledged
- [ ] My code follows the [contributing guidelines][contributing] of this project.
- [ ] I am aware that all my commits will be squashed into a single commit, using the PR title as the commit message.
- [ ] I have performed a self-review of my own code.
- [ ] I have commented my code in hard-to-understand areas.
- [ ] I have updated the user-facing documentation to describe any new or changed behavior.
- [ ] My changes generate no new warnings.
- [ ] I have added tests that prove my fix is effective or that my feature works.
- [ ] I have not reduced the existing code coverage.

## Comments

> If there are unchecked boxes in the list above, but you would still like your
> PR to be reviewed or considered for merging, please describe here why boxes
> were not checked. For example, if you are positive that your commits should
> _not_ be squased when merging, please explain why you think the PR warrants
> or requires multiple commits to be added to the history.
> If there are unchecked boxes in the list above, but you would still like your PR to be reviewed or considered for merging, please describe here why boxes were not checked.
[all-contributors-bot]: https://allcontributors.org/docs/en/bot/overview
[all-contributors-types]: https://allcontributors.org/docs/en/emoji-key
[contributing]: CONTRIBUTING.md
[conventional-commits]: https://www.conventionalcommits.org/en/v1.0.0/
[jsdoc]: https://jsdoc.app/index.html

0 comments on commit fa62ec3

Please sign in to comment.