Skip to content
This repository has been archived by the owner on Nov 5, 2024. It is now read-only.

Commit

Permalink
Developer's experience (#2582)
Browse files Browse the repository at this point in the history
* Improve the "detektFormat" task

* Fix the pre-push hook

* Test the pre-push hook

* Fix file formatting

* Fix messed up files

* Setup DangerJS

* Attempt Danger to comment with the Detekt report

* Try to comment APK file on the PR using Danger

* Update apk.yml

* Remove 5k node modules form .gitignore

* WIP: Setup DangerJS + upgrade wrapper

* Danger PR

* Danger PR (fix Markdown #1)

* Add danger comment for the "APK" workflow

* Add Danger Detekt

* Fix the Danger comment in Detekt

* Update Danger

* Fix Danger "Detekt" message

* WIP Danger

* DangerJS devexp v0.0.1?

* Rerun CI

* Improve Danger

* Improve Danger comments

* Improve Danger comments 2

* Improve Detekt messages

* Danger messages

* Update Detekt baseline

* Add "What's changed?" tip

* PR template improvement
  • Loading branch information
ILIYANGERMANOV authored Sep 9, 2023
1 parent 067b6e2 commit 9f73c9d
Show file tree
Hide file tree
Showing 23 changed files with 1,280 additions and 49 deletions.
9 changes: 9 additions & 0 deletions .danger/apk.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
**Great news! Your PR builds ✅**

We've managed to generate a R8-optimized
_(minify, obfuscate and shrink resources)_ APK with your changes. 👌

It's way faster than the `debug` build type but sometimes it may crash. So please, **test** and enjoy your ligthning-fast **[Ivy-Wallet-Demo.apk]()**. ⚡

_⚠️ It's important to download and test this APK artifact from the **["APK" workflow]()** or the link above because it may introduce runtime crashes in production._

43 changes: 43 additions & 0 deletions .danger/danger_apk.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import { danger, markdown, message } from "danger";

const runID = process.env.GITHUB_RUN_ID;
const repoFullName = danger.github.pr.base.repo.full_name;
const artifactURL = `https://github.com/${repoFullName}/actions/runs/${runID}`;


message(`
## APK ready ✅
We've managed to generate a R8-optimized _(minify, obfuscate, and shrink resources)_ APK with your changes. 👌
It's way faster than the \`debug\` build type but sometimes it may crash. So please, **test** and enjoy your lightning-fast **[Ivy-Wallet-Demo.apk](${artifactURL})**. ⚡
_**Note:** It's important to download and test this APK artifact from the **["APK" workflow](${artifactURL})** or the link above because it may introduce runtime crashes in production._`
);

message(`
## Detekt check finished 🕵️‍♂️
Our code quality check completed. ✅
If it fails, open the **"Detekt" workflow** run on your PR, scroll down and download the attached \`detekt-report.html\`. Please, inspect it and try to fix the errors. 🔎
_**Pstt,** don't worry - sometimes Detekt gives false-positives. Your reviewer will guide you towards the best next steps. 👍_`
);

markdown(`
## Congratulations! 🎉 You're almost there...
Your PR is a fact and it'll be reviewed as soon as possible. The last step is to receive an approving review and merge it. ✅
**The final thing left to do is:**
- Upload a screen recording to prove that your code works. _(without it we can't merge your PR)_
**Code quality tips:**
- The keyword is **simplicity**.
- Can I do it in a more simple and straightforward way?
- Can I do it with less code? If so, delete what's unnecessary.
- Did I over-engineer it?
_Thank you for your contribution! 👏_`
);
32 changes: 32 additions & 0 deletions .danger/danger_detekt.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import { danger, markdown, message } from "danger";

const runID = process.env.GITHUB_RUN_ID;
const repoFullName = danger.github.pr.base.repo.full_name;
const actionRunUrl = `https://github.com/${repoFullName}/actions/runs/${runID}`;

message(`
## Detekt check finished 🕵️‍♂️
Our code quality check completed. ✅
If it fails, open **[the "Detekt" workflow run](${actionRunUrl})** on your PR, scroll down and download the attached \`detekt-report.html\`. Please, inspect it and try to fix the errors. 🔎
_**Pstt,** don't worry - sometimes Detekt gives false-positives. Your reviewer will guide you towards the best next steps. 👍_`
);

markdown(`
## Congratulations! 🎉 You're almost there...
Your PR is a fact and it'll be reviewed as soon as possible. The last step is to receive an approving review and merge it. ✅
**The final thing left to do is:**
- Upload a screen recording to prove that your code works. _(without it we can't merge your PR)_
**Code quality tips:**
- The keyword is **simplicity**.
- Can I do it in a more simple and straightforward way?
- Can I do it with less code? If so, delete what's unnecessary.
- Did I over-engineer it?
_Thank you for your contribution! 👏_`
)
18 changes: 18 additions & 0 deletions .danger/danger_pr.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { markdown } from "danger"

markdown(`
## Congratulations! 🎉 You're almost there...
Your PR is a fact and it'll be reviewed as soon as possible. The last step is to receive an approving review and merge it. ✅
**The final thing left to do is:**
- Upload a screen recording to prove that your code works. _(without it we can't merge your PR)_
**Code quality tips:**
- The keyword is **simplicity**.
- Can I do it in a more simple and straightforward way?
- Can I do it with less code? If so, delete what's unnecessary.
- Did I over-engineer it?
_Thank you for your contribution! 👏_`
)
9 changes: 9 additions & 0 deletions .danger/detekt.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Detekt check finished 🕵️‍♂️

Our code quality check completed. ✅

If it fails, [click here](), scroll down
and download the attached **detekt-report.html**. Please, inspect it and try to fix the errors. 🔎

_**Pstt,** don't worry - sometimes Detekt gives false-positives.
Your reviewer will guide towards the best next steps. 👍_
14 changes: 14 additions & 0 deletions .danger/pr.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
**Congratualstions! 🎉 You're almost there...**

Your PR is a fact and it'll be reviewed as soon as possible. The last step is to receive an approving review and merge it. ✅

**The final thing left to is:**
- Upload a screen recoding to prove that your code works. _(without it we can't merge your PR)_

**Code quality tips:**
- The keyword is **simplicity**.
- Can I do it in a more simple and straightforward way?
- Can I do it with less code? If so, delete what's unnecessary.
- Did I over-engineer it?

_Thank you for your contributuon! 👏_
10 changes: 10 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,16 @@ Please check if your pull request fulfills the following requirements:
- [ ] I confirm that I've run the code locally and everything works as expected.

## What's changed?
<!--
Tip: you can attach screenshots using a markdown table.
Screenshot 1 | Screenshot 2
---|---
copy-paste screenshot 1 | copy-paste 2
Describe things in a short and straightforward manner.
-->

Describe with a few bullets **what's new:**
- a
- b
Expand Down
8 changes: 8 additions & 0 deletions .github/workflows/apk.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,11 @@ jobs:
-F "reply_to_message_id=16118" \
-F "caption=$CAPTION" \
https://api.telegram.org/bot${{ secrets.BOTFATHER_TELEGRAM_BOT_TOKEN }}/sendDocument
- name: Comment APK on the PR with Danger
if: github.event_name == 'pull_request'
uses: danger/[email protected]
with:
args: "--dangerfile .danger/danger_apk.ts"
env:
DANGER_GITHUB_API_TOKEN: ${{ secrets.DANGER_GITHUB_API_TOKEN }}
20 changes: 20 additions & 0 deletions .github/workflows/danger_pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: "Danger (PR)"

on:
pull_request:

jobs:
danger_pr:
runs-on: ubuntu-latest

steps:
- name: Checkout GIT
uses: actions/checkout@v4

- name: Comment on the PR
if: github.event_name == 'pull_request'
uses: danger/[email protected]
with:
args: "--dangerfile .danger/danger_pr.ts"
env:
DANGER_GITHUB_API_TOKEN: ${{ secrets.DANGER_GITHUB_API_TOKEN }}
9 changes: 9 additions & 0 deletions .github/workflows/detekt.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,12 @@ jobs:
name: detekt-report.html
path: build/reports/detekt/detekt.html
#------------------------------------------------------------------

- name: Comment Detekt results on the PR with Danger
if: always()
uses: danger/[email protected]
with:
args: "--dangerfile .danger/danger_detekt.ts"
env:
GITHUB_TOKEN: ${{ secrets.DANGER_GITHUB_API_TOKEN }}

5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -84,4 +84,7 @@ lint/intermediates/
lint/generated/
lint/outputs/
lint/tmp/
# lint/reports/
lint/reports/

# JS
node_modules/*
45 changes: 45 additions & 0 deletions .idea/appInsightsSettings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/kotlinc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import com.ivy.frp.action.FPAction
import com.ivy.frp.then
import com.ivy.wallet.domain.data.core.Transaction
import com.ivy.wallet.io.persistence.dao.TransactionDao
import java.util.*
import java.util.UUID
import javax.inject.Inject

class TrnByIdAct @Inject constructor(
Expand Down
11 changes: 9 additions & 2 deletions buildSrc/src/main/kotlin/ivy.lint.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,15 @@ tasks.withType<Detekt> {
// Disable task caching
outputs.upToDateWhen { false }

val filesToCheck: String? = System.getProperty("detekt.filesToCheck")
setSource(filesToCheck?.split(",") ?: projectDir)
val filesToCheck: List<String>? = System.getProperty("detekt.filesToCheck")
?.split(",")
?.filter { it.isNotBlank() }
if (filesToCheck != null) {
println("Formatting: $filesToCheck")
} else {
println("Formatting all files...")
}
setSource(filesToCheck ?: projectDir)

reports {
html.required.set(true)
Expand Down
Loading

0 comments on commit 9f73c9d

Please sign in to comment.