Skip to content

GitHub Action to validate if PR description contains phrase "Fixes #issue"

License

Notifications You must be signed in to change notification settings

jstrzebonski/check-pr-fixes-issue

 
 

Repository files navigation

check-pr-fixes-issue

Unit tests

The DARMA-tasking/check-pr-fixes-issue/ is a JavaScript action that checks if PR description contains phrase "Fixes #issue". It also checks if PR title, description and branch mention the same issue number.

Workflow example

name: PR description check

on:
  pull_request:
    types: [opened, edited, reopened]

jobs:
  check:
    name: Check PR description
    runs-on: ubuntu-latest
    steps:
      - uses: DARMA-tasking/check-pr-fixes-issue@master
        with:
          pr_title: ${{ github.event.pull_request.title }}
          pr_description: ${{ github.event.pull_request.body }}

Development

Install the dependencies

$ npm install

Run the tests

$ npm test

 PASS  tests/helpers.test.js
  checkPrBranch function
    ✓ checks if PR branch starts with an issue number (2 ms)
  checkPrTitle function
    ✓ checks if PR title starts with an issue number (3 ms)
  checkPrDescription function
    ✓ checks if PR description contains phrase "Fixes #issue" (2 ms)
  extractBranchIssue function
    ✓ extracts issue number from PR branch (1 ms)
  extractTitleIssue function
    ✓ extracts issue number from PR title (1 ms)
  ...

Run lint

$ npm run lint

> [email protected] lint /home/strz/repos/darma/src/check-pr-fixes-issue
> eslint .

Distribution

Packaging assembles the code into one file that can be checked in to Git, enabling fast and reliable execution and preventing the need to check in node_modules. Packaging the action will create a packaged action in the dist/ folder.

Run prepare

$ npm run prepare

Since the packaged index.js is run from the dist/ folder, it needs to be added

$ git add dist/

GitHub Actions will run the entry point from the action.yml

runs:
  using: "node16"
  main: "dist/index.js" # <== entry point

To do everything at once (lint, prepare and test) do

$ npm run all

About

GitHub Action to validate if PR description contains phrase "Fixes #issue"

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 100.0%