Skip to content

[MOB-12122] Migrate Danger to TypeScript #351

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

Merged
merged 2 commits into from
Apr 10, 2023
Merged
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
12 changes: 8 additions & 4 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ version: 2.1
orbs:
android: circleci/android@2.0
flutter: circleci/flutter@1.0
node: circleci/node@5.1.0

commands:
setup_flutter:
Expand Down Expand Up @@ -73,12 +74,15 @@ commands:

jobs:
danger:
docker:
- image: circleci/ruby:2.6.4
executor:
name: node/default
steps:
- checkout
- run: bundle install
- run: bundle exec danger
- node/install-packages:
pkg-manager: yarn
- run:
name: Run Danger
command: yarn danger ci

test_flutter:
parameters:
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ ios/**/Generated/
build/
coverage/

# Node related
node_modules

# Android related
**/android/**/gradle-wrapper.jar
**/android/.gradle
Expand Down
12 changes: 0 additions & 12 deletions Dangerfile

This file was deleted.

29 changes: 29 additions & 0 deletions dangerfile.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { danger, fail, schedule, warn } from 'danger';

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

// Make sure PR has a description.
async function hasDescription() {
const linesOfCode = (await danger.git.linesOfCode()) ?? 0;
const hasNoDescription = danger.github.pr.body.includes(
'> Description goes here'
);
if (hasNoDescription && linesOfCode > 10) {
fail(
'Please provide a summary of the changes in the pull request description.'
);
}

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-Flutter/blob/master/CHANGELOG.md).'
);
}
}

schedule(hasDescription());
7 changes: 7 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"name": "Instabug-Flutter",
"version": "0.0.0",
"devDependencies": {
"danger": "^11.2.5"
}
}
Loading