Skip to content

feat: Include an API call example section in the pull request description #1413

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@

> Issue links go here

## Usage Example

> Example of how to call it

## Checklists

### Development
Expand Down
8 changes: 7 additions & 1 deletion dangerfile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,23 @@ import collectCoverage, { ReportType } from '@instabug/danger-plugin-coverage';
import { danger, fail, schedule, warn } from 'danger';

const hasSourceChanges = danger.git.modified_files.some((file) => file.startsWith('src/'));
const hasModulesChanges = danger.git.modified_files.some((file) => file.startsWith('src/modules/'));
const declaredTrivial =
!hasSourceChanges || danger.github.issue.labels.some((label) => label.name === 'trivial');

// Make sure PR has a description.
// Make sure PR has a description and ca;;ing example.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo

async function hasDescription() {
const linesOfCode = (await danger.git.linesOfCode()) ?? 0;
const hasNoDiscription = danger.github.pr.body.includes('> Description goes here');
const hasNoExample = danger.github.pr.body.includes('> Example of how to call it');
if (hasNoDiscription && linesOfCode > 10) {
fail('Please provide a summary of the changes in the pull request description.');
}

if (hasNoExample && linesOfCode > 10 && hasModulesChanges) {
warn('Please provide example of how to call it.');
}

if (!danger.git.modified_files.includes('CHANGELOG.md') && !declaredTrivial) {
warn(
'You have not included a CHANGELOG entry! \nYou can find it at [CHANGELOG.md](https://github.com/Instabug/Instabug-React-Native/blob/master/CHANGELOG.md).',
Expand Down