Skip to content

Commit 0faf11e

Browse files
a7medevHeshamMegid
authored andcommitted
[MOB-12122] Migrate Danger to TypeScript (#351)
1 parent a0b4ce6 commit 0faf11e

File tree

6 files changed

+984
-16
lines changed

6 files changed

+984
-16
lines changed

.circleci/config.yml

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ version: 2.1
33
orbs:
44
android: circleci/[email protected]
55
flutter: circleci/[email protected]
6+
node: circleci/[email protected]
67

78
commands:
89
setup_flutter:
@@ -73,12 +74,15 @@ commands:
7374

7475
jobs:
7576
danger:
76-
docker:
77-
- image: circleci/ruby:2.6.4
77+
executor:
78+
name: node/default
7879
steps:
7980
- checkout
80-
- run: bundle install
81-
- run: bundle exec danger
81+
- node/install-packages:
82+
pkg-manager: yarn
83+
- run:
84+
name: Run Danger
85+
command: yarn danger ci
8286

8387
test_flutter:
8488
parameters:

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@ ios/**/Generated/
3838
build/
3939
coverage/
4040

41+
# Node related
42+
node_modules
43+
4144
# Android related
4245
**/android/**/gradle-wrapper.jar
4346
**/android/.gradle

Dangerfile

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

dangerfile.ts

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import { danger, fail, schedule, warn } from 'danger';
2+
3+
const hasSourceChanges = danger.git.modified_files.some((file) =>
4+
file.startsWith('lib/')
5+
);
6+
const declaredTrivial =
7+
!hasSourceChanges ||
8+
danger.github.issue.labels.some((label) => label.name === 'trivial');
9+
10+
// Make sure PR has a description.
11+
async function hasDescription() {
12+
const linesOfCode = (await danger.git.linesOfCode()) ?? 0;
13+
const hasNoDescription = danger.github.pr.body.includes(
14+
'> Description goes here'
15+
);
16+
if (hasNoDescription && linesOfCode > 10) {
17+
fail(
18+
'Please provide a summary of the changes in the pull request description.'
19+
);
20+
}
21+
22+
if (!danger.git.modified_files.includes('CHANGELOG.md') && !declaredTrivial) {
23+
warn(
24+
'You have not included a CHANGELOG entry! \nYou can find it at [CHANGELOG.md](https://github.com/Instabug/Instabug-Flutter/blob/master/CHANGELOG.md).'
25+
);
26+
}
27+
}
28+
29+
schedule(hasDescription());

package.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"name": "Instabug-Flutter",
3+
"version": "0.0.0",
4+
"devDependencies": {
5+
"danger": "^11.2.5"
6+
}
7+
}

0 commit comments

Comments
 (0)