-
Notifications
You must be signed in to change notification settings - Fork 739
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
Danger #6637
Danger #6637
Changes from all commits
a52a250
56691f6
630a981
a062093
036521a
b77475a
cc6dad3
4d62e75
66fa285
fb67499
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
name: Danger CI | ||
|
||
on: [pull_request] | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
name: Danger | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- run: | | ||
npm install --save-dev @babel/plugin-transform-flow-strip-types | ||
- name: Danger | ||
uses: danger/[email protected] | ||
with: | ||
args: "--dangerfile tools/danger/dangerfile.js" | ||
env: | ||
DANGER_GITHUB_API_TOKEN: ${{ secrets.DANGER_GITHUB_API_TOKEN }} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,80 +29,50 @@ jobs: | |
- uses: actions/checkout@v3 | ||
- name: Run knit | ||
run: | | ||
./gradlew knit | ||
./gradlew knitCheck | ||
|
||
# ktlint for all the modules | ||
ktlint: | ||
name: Kotlin Linter | ||
# Check the project: ktlint, detekt, lint | ||
lint: | ||
name: Android Linter | ||
runs-on: ubuntu-latest | ||
# Allow all jobs on main and develop. Just one per PR. | ||
concurrency: | ||
group: ${{ github.ref == 'refs/heads/main' && format('ktlint-main-{0}', github.sha) || github.ref == 'refs/heads/develop' && format('ktlint-develop-{0}', github.sha) || format('ktlint-{0}', github.ref) }} | ||
group: ${{ github.ref == 'refs/heads/main' && format('lint-main-{0}', github.sha) || github.ref == 'refs/heads/develop' && format('lint-develop-{0}', github.sha) || format('lint-{0}', github.ref) }} | ||
cancel-in-progress: true | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Run ktlint | ||
run: | | ||
./gradlew ktlintCheck --continue | ||
- name: Run detekt | ||
if: always() | ||
run: | | ||
./gradlew detekt $CI_GRADLE_ARG_PROPERTIES | ||
- name: Run lint | ||
# Not always, if ktlint or detekt fail, avoid running the long lint check. | ||
run: | | ||
./gradlew lintGplayRelease --stacktrace $CI_GRADLE_ARG_PROPERTIES | ||
./gradlew lintFdroidRelease --stacktrace $CI_GRADLE_ARG_PROPERTIES | ||
- name: Upload reports | ||
if: always() | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: ktlinting-report | ||
name: linting-report | ||
path: | | ||
*/build/reports/ktlint/ktlint*/ktlint*.txt | ||
- name: Handle Results | ||
*/build/reports/**/*.* | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. All reports are correctly exported, see https://github.com/vector-im/element-android/actions/runs/2753115871 |
||
- name: Prepare Danger | ||
if: always() | ||
id: ktlint-results | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is not necessary anymore, since Danger will post comments for each detected ktlint issue |
||
run: | | ||
results="$(cat */*/build/reports/ktlint/ktlint*/ktlint*.txt */build/reports/ktlint/ktlint*/ktlint*.txt | sed -r "s/\x1B\[([0-9]{1,3}(;[0-9]{1,2})?)?[mGK]//g")" | ||
if [ -z "$results" ]; then | ||
echo "::set-output name=add_comment::false" | ||
else | ||
body="👎\`Failed${results}\`" | ||
body="${body//'%'/'%25'}" | ||
body="${body//$'\n'/'%0A'}" | ||
body="${body//$'\r'/'%0D'}" | ||
body="$( echo $body | sed 's/\/home\/runner\/work\/element-android\/element-android\//\`<br\/>\`/g')" | ||
body="$( echo $body | sed 's/\/src\/main\/java\// 🔸 /g')" | ||
body="$( echo $body | sed 's/im\/vector\/app\///g')" | ||
body="$( echo $body | sed 's/im\/vector\/lib\/attachmentviewer\///g')" | ||
body="$( echo $body | sed 's/im\/vector\/lib\/multipicker\///g')" | ||
body="$( echo $body | sed 's/im\/vector\/lib\///g')" | ||
body="$( echo $body | sed 's/org\/matrix\/android\/sdk\///g')" | ||
body="$( echo $body | sed 's/\/src\/androidTest\/java\// 🔸 /g')" | ||
echo "::set-output name=add_comment::true" | ||
echo "::set-output name=body::$body" | ||
fi | ||
- name: Find Comment | ||
if: always() && github.event_name == 'pull_request' | ||
uses: peter-evans/find-comment@v2 | ||
id: fc | ||
with: | ||
issue-number: ${{ github.event.pull_request.number }} | ||
comment-author: 'github-actions[bot]' | ||
body-includes: Ktlint Results | ||
- name: Add comment if needed | ||
if: always() && github.event_name == 'pull_request' && steps.ktlint-results.outputs.add_comment == 'true' | ||
uses: peter-evans/create-or-update-comment@v2 | ||
with: | ||
comment-id: ${{ steps.fc.outputs.comment-id }} | ||
issue-number: ${{ github.event.pull_request.number }} | ||
body: | | ||
### Ktlint Results | ||
|
||
${{ steps.ktlint-results.outputs.body }} | ||
edit-mode: replace | ||
- name: Delete comment if needed | ||
if: always() && github.event_name == 'pull_request' && steps.fc.outputs.comment-id != '' && steps.ktlint-results.outputs.add_comment == 'false' | ||
uses: actions/github-script@v3 | ||
npm install --save-dev @babel/core | ||
npm install --save-dev @babel/plugin-transform-flow-strip-types | ||
yarn add danger-plugin-lint-report --dev | ||
- name: Danger lint | ||
if: always() | ||
uses: danger/[email protected] | ||
with: | ||
script: | | ||
github.issues.deleteComment({ | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
comment_id: ${{ steps.fc.outputs.comment-id }} | ||
}) | ||
args: "--dangerfile tools/danger/dangerfile-lint.js" | ||
env: | ||
DANGER_GITHUB_API_TOKEN: ${{ secrets.DANGER_GITHUB_API_TOKEN }} | ||
|
||
# Gradle dependency analysis using https://github.com/autonomousapps/dependency-analysis-android-gradle-plugin | ||
dependency-analysis: | ||
|
@@ -122,107 +92,3 @@ jobs: | |
with: | ||
name: dependency-analysis | ||
path: build/reports/dependency-check-report.html | ||
|
||
# Lint for main module | ||
android-lint: | ||
name: Android Linter | ||
runs-on: ubuntu-latest | ||
# Allow all jobs on main and develop. Just one per PR. | ||
concurrency: | ||
group: ${{ github.ref == 'refs/heads/main' && format('android-lint-main-{0}', github.sha) || github.ref == 'refs/heads/develop' && format('android-lint-develop-{0}', github.sha) || format('android-lint-{0}', github.ref) }} | ||
cancel-in-progress: true | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: actions/cache@v3 | ||
with: | ||
path: | | ||
~/.gradle/caches | ||
~/.gradle/wrapper | ||
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} | ||
restore-keys: | | ||
${{ runner.os }}-gradle- | ||
- name: Lint analysis | ||
run: ./gradlew clean :vector:lint --stacktrace $CI_GRADLE_ARG_PROPERTIES | ||
- name: Upload reports | ||
if: always() | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: lint-report | ||
path: | | ||
vector/build/reports/*.* | ||
|
||
# Lint for Gplay and Fdroid release APK | ||
apk-lint: | ||
name: Lint APK (${{ matrix.target }}) | ||
runs-on: ubuntu-latest | ||
if: github.ref != 'refs/heads/main' | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
target: [ Gplay, Fdroid ] | ||
# Allow all jobs on develop. Just one per PR. | ||
concurrency: | ||
group: ${{ github.ref == 'refs/heads/develop' && format('apk-lint-develop-{0}-{1}', matrix.target, github.sha) || format('apk-lint-{0}-{1}', matrix.target, github.ref) }} | ||
cancel-in-progress: true | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: actions/cache@v3 | ||
with: | ||
path: | | ||
~/.gradle/caches | ||
~/.gradle/wrapper | ||
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} | ||
restore-keys: | | ||
${{ runner.os }}-gradle- | ||
- name: Lint ${{ matrix.target }} release | ||
run: ./gradlew clean lint${{ matrix.target }}Release --stacktrace $CI_GRADLE_ARG_PROPERTIES | ||
- name: Upload ${{ matrix.target }} linting report | ||
if: always() | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: release-lint-report-${{ matrix.target }} | ||
path: | | ||
vector/build/reports/*.* | ||
|
||
detekt: | ||
name: Detekt Analysis | ||
runs-on: ubuntu-latest | ||
# Allow all jobs on main and develop. Just one per PR. | ||
concurrency: | ||
group: ${{ github.ref == 'refs/heads/main' && format('detekt-main-{0}', github.sha) || github.ref == 'refs/heads/develop' && format('detekt-develop-{0}', github.sha) || format('detekt-{0}', github.ref) }} | ||
cancel-in-progress: true | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Run detekt | ||
run: | | ||
./gradlew detekt $CI_GRADLE_ARG_PROPERTIES | ||
- name: Upload reports | ||
if: always() | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: detekt-report | ||
path: | | ||
*/build/reports/detekt/detekt.html | ||
|
||
# towncrier: | ||
# name: Towncrier check | ||
# runs-on: ubuntu-latest | ||
# if: github.event_name == 'pull_request' && github.head_ref == 'develop' | ||
# steps: | ||
# - uses: actions/checkout@v3 | ||
# - name: Set up Python 3.8 | ||
# uses: actions/setup-python@v4 | ||
# with: | ||
# python-version: 3.8 | ||
# - name: Install towncrier | ||
# run: | | ||
# python3 -m pip install towncrier | ||
# - name: Run towncrier | ||
# # Fetch the pull request' base branch so towncrier will be able to | ||
# # compare the current branch with the base branch. | ||
# # Source: https://github.com/actions/checkout/#fetch-all-branches. | ||
# run: | | ||
# git fetch --no-tags origin +refs/heads/${BASE_BRANCH}:refs/remotes/origin/${BASE_BRANCH} | ||
# towncrier check --compare-with origin/${BASE_BRANCH} | ||
# env: | ||
# BASE_BRANCH: ${{ github.base_ref }} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,3 +17,8 @@ | |
/fastlane/report.xml | ||
|
||
/**/build | ||
|
||
# Added by yarn | ||
/package.json | ||
/yarn.lock | ||
/node_modules |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
source "https://rubygems.org" | ||
|
||
gem "fastlane" | ||
gem 'danger' |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Setup Danger to the project |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is
@babel/plugin-transform-flow-strip-types
mandatory to run danger? I'm wondering if there's a local package.json/babel config we should apply this to as well 🤔There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, without this line, I got an error, see https://github.com/vector-im/element-android/runs/7524822865 :
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually this is more https://github.com/vector-im/element-android/runs/7526127685 :