<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">

	<title>Prashant C Chaturvedi's Blog</title>
	<link href="http://pccofvns.github.io/blog/atom.xml" rel="self"/>
	<link href="http://pccofvns.github.io/blog"/>
	<updated>2026-03-21T16:39:27+00:00</updated>
	<id>http://pccofvns.github.io/blog</id>
	<author>
		<name>Prashant C Chaturvedi</name>
		<email>pccfrmvns@gmail.com</email>
	</author>

	
		<entry>
			<title>Best Practices: Enforcing Pull Request Template</title>
			<link href="http://pccofvns.github.io/2024/01/01/enforcing-pull-request-template.html"/>
			<updated>2024-01-01T00:00:00+00:00</updated>
			<id>http://pccofvns.github.io/2024/01/01/enforcing-pull-request-template</id>
			<content type="html">&lt;h2 id=&quot;overview&quot;&gt;Overview&lt;/h2&gt;

&lt;p&gt;Maintaining consistency and adherence to best practices is crucial in software development, especially when the codebase is old, and collaborating on projects with multiple contributors. In this particular scenario, we’re solving following problems:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Ensuring that the code changes contain relevant information&lt;/strong&gt;
We need to make sure that there is enough information about the code change so that it can be traced to some requirement/defect so that everyone can understand what was done and why. It is also required that we describe the reason and impact of all the changes for other teams like QA.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Avoid manual repetition of information on multiple platforms&lt;/strong&gt;
It would’ve sufficed to link the pull request to some Issue Key of issue tracking tools (say JIRA). However, some details are required to be put in the pull request so that when someone looking into commit logs, they don’t have to go to the issue tracker for each commit to find the relevant details which should’ve been in the commit in the first place. Putting details in JIRA also creates a need to validate the relevant details. Since, there would be some overlap of the details that are written in the pull request and what is there in JIRA; developer aren’t too keen to put those details again in JIRA. In our case GitHub and JIRA are not integrated. The Management, QA and non Engineering Teams are more keen to have all relevant details in the JIRA. I personally like to have all the possible details related to code change, its impact, and tests executed on the pull request itself so that it helps with Code Review process.&lt;/p&gt;

&lt;p&gt;All cross-functional teams agreed upon a pull request template, that contains minimum basic information needed for both Pull Request, and JIRA.&lt;/p&gt;

&lt;h3 id=&quot;automating-the-process-and-ensuring-adherence&quot;&gt;Automating the Process and ensuring adherence.&lt;/h3&gt;

&lt;p&gt;The task is to ensure that this whole process is automated and there is no lapse.&lt;/p&gt;

&lt;h4 id=&quot;create-a-pull-request-template&quot;&gt;Create a pull request template&lt;/h4&gt;

&lt;ol&gt;
  &lt;li&gt;Create file named &lt;a href=&quot;https://gist.githubusercontent.com/pccofvns/a02fd59870d78da437bf7a57211f930d/raw/a27bdd73b1963a0cf480b820c09d0bf233d4fa2b/pull_request_template.md&quot;&gt;pull_request_template.md&lt;/a&gt;
    &lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;## Description of Changes
### RCA
&amp;lt;!--- Root Cause Analysis. The title of the story shall be enough in case the changes are related to a user story --&amp;gt;
### Code Changes
&amp;lt;!--- Describe the code changes done to implement the story or to fix the defect--&amp;gt;
### Impact Analysis
&amp;lt;!--- Describe the impact of this change on other modules and/features --&amp;gt;
## Issue ticket number(s)
JIRA-0000
## Tests
- [ ] This the detail of the first test case that you&apos;ve run. You can add more below.
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;    &lt;/div&gt;
  &lt;/li&gt;
  &lt;li&gt;Place this file in an appropriate place, which is the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;.github&lt;/code&gt; directory inside the repository, or the organisation wide &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;.github&lt;/code&gt; repository. Now every time a pull request is created, the pull request details would be pre populated with this content for the developer to fill.&lt;/li&gt;
&lt;/ol&gt;

&lt;h3 id=&quot;create-a-script-to-validate-the-pull-request-validate&quot;&gt;Create a script to validate the Pull Request Validate&lt;/h3&gt;

&lt;p&gt;Since I wanted to this pull request template to be used across all my repositories, it would make sense to keep such validation script in some common place.&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;Create a GitHub repository say &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;scripts&lt;/code&gt;.&lt;/li&gt;
  &lt;li&gt;Inside this repo, create a file to parse with Github pull request title and body as below
&lt;script src=&quot;https://gist.github.com/e4d7a60733c782d3e175560da461d0b9.js?file=gh_pull_request_linter.py&quot;&gt; &lt;/script&gt;&lt;/li&gt;
  &lt;li&gt;A &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;requirements.txt&lt;/code&gt; file at the same location to install dependencies as below:
    &lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;requests==2.32.3
urllib3==1.26.19
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;    &lt;/div&gt;
  &lt;/li&gt;
&lt;/ol&gt;

&lt;h3 id=&quot;create-github-action-to-validate-pull-requests&quot;&gt;Create GitHub action to validate pull requests&lt;/h3&gt;

&lt;p&gt;Say you want to use the pull request validation in a this scripts repo, where you’ve this aforementioned &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;pull_request_template.md&lt;/code&gt; inside &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;.github&lt;/code&gt; directory.&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;Create a folder &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;workflows&lt;/code&gt; inside this &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;.github&lt;/code&gt; directory (if it doesn’t exist already)&lt;/li&gt;
  &lt;li&gt;Create a file &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;pull_request_lint.yml&lt;/code&gt; as below:
&lt;script src=&quot;https://gist.github.com/7bc7c2af93b1b172567fc65f24430be9.js?file=gha_pr_lint.yml&quot;&gt; &lt;/script&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h3 id=&quot;create-branch-protection-rules-to-ensure-that-this-workflow-must-pass-before-a-pull-request-can-be-merged&quot;&gt;Create branch protection rules to ensure that this workflow must pass before a Pull Request can be merged&lt;/h3&gt;

&lt;p&gt;While the action will itself run when a PR is created targeting &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;main&lt;/code&gt; branch. You can update it to suit your needs.&lt;/p&gt;

&lt;p&gt;Final structure of scripts repo:&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;scripts
├── .github
│   ├── pull_request_template.md
│   └── workflows
│		└── pull_request_lint.yml
├── requirements.txt
├── gh_pull_request_linter.py
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h2 id=&quot;working-examples&quot;&gt;Working Examples&lt;/h2&gt;

&lt;p&gt;You can visit my &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;[pccofvns/scripts](https://github.com/pccofvns/scripts)&lt;/code&gt; repo for working example. To use the same pr lint process in other repos, see &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;[pccofvns/takshashila](https://github.com/pccofvns/takshashila)&lt;/code&gt; repo.&lt;/p&gt;
</content>
		</entry>
	

</feed>
