Skip to content

Commit 0c67747

Browse files
a7medevHeshamMegid
authored andcommitted
[MOB-11085] Migrate Danger to TypeScript (#957)
1 parent 32da31b commit 0c67747

File tree

5 files changed

+676
-28
lines changed

5 files changed

+676
-28
lines changed

.circleci/config.yml

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,15 @@ commands:
2626
- << parameters.working_directory >>/Pods
2727
jobs:
2828
danger:
29-
docker:
30-
- image: circleci/ruby:2.6.4
29+
executor:
30+
name: node/default
3131
steps:
3232
- advanced-checkout/shallow-checkout
33-
- run: bundle install
34-
- run: bundle exec danger
33+
- node/install-packages:
34+
pkg-manager: yarn
35+
- run:
36+
name: Run Danger
37+
command: yarn danger ci
3538

3639
lint:
3740
executor:

Dangerfile

Lines changed: 0 additions & 12 deletions
This file was deleted.

dangerfile.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import { danger, fail, schedule, warn } from 'danger';
2+
3+
const hasSourceChanges = danger.git.modified_files.some((file) => file.startsWith('src/'));
4+
const declaredTrivial =
5+
!hasSourceChanges || danger.github.issue.labels.some((label) => label.name === 'trivial');
6+
7+
// Make sure PR has a description.
8+
async function hasDescription() {
9+
const linesOfCode = (await danger.git.linesOfCode()) ?? 0;
10+
const hasNoDiscription = danger.github.pr.body.includes('> Description goes here');
11+
if (hasNoDiscription && linesOfCode > 10) {
12+
fail('Please provide a summary of the changes in the pull request description.');
13+
}
14+
15+
if (!danger.git.modified_files.includes('CHANGELOG.md') && !declaredTrivial) {
16+
warn(
17+
'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).',
18+
);
19+
}
20+
}
21+
22+
schedule(hasDescription());

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@
5757
"babel-core": "7.0.0-bridge.0",
5858
"babel-jest": "^24.8.0",
5959
"commander": "^9.4.1",
60+
"danger": "^11.2.5",
6061
"eslint": "^8.24.0",
6162
"eslint-plugin-prettier": "^4.2.1",
6263
"esprima": "^4.0.1",

0 commit comments

Comments
 (0)