mirror of
https://github.com/element-hq/element-android
synced 2024-11-28 13:38:49 +03:00
Merge pull request #4888 from vector-im/feature/aris/linter__remove_github_comment_on_success
Add comment only on ktlint fail
This commit is contained in:
commit
10e8808b88
2 changed files with 19 additions and 7 deletions
25
.github/workflows/quality.yml
vendored
25
.github/workflows/quality.yml
vendored
|
@ -32,13 +32,13 @@ jobs:
|
||||||
*/build/reports/ktlint/ktlint*/ktlint*.txt
|
*/build/reports/ktlint/ktlint*/ktlint*.txt
|
||||||
- name: Handle Results
|
- name: Handle Results
|
||||||
if: always()
|
if: always()
|
||||||
id: get-comment-body
|
id: ktlint-results
|
||||||
run: |
|
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")"
|
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
|
if [ -z "$results" ]; then
|
||||||
body="👍 ✅ 👍"
|
echo "::set-output name=add_comment::false"
|
||||||
else
|
else
|
||||||
body="👎 ❌ 👎 \`Failed${results}\`"
|
body="👎\`Failed${results}\`"
|
||||||
body="${body//'%'/'%25'}"
|
body="${body//'%'/'%25'}"
|
||||||
body="${body//$'\n'/'%0A'}"
|
body="${body//$'\n'/'%0A'}"
|
||||||
body="${body//$'\r'/'%0D'}"
|
body="${body//$'\r'/'%0D'}"
|
||||||
|
@ -50,8 +50,9 @@ jobs:
|
||||||
body="$( echo $body | sed 's/im\/vector\/lib\///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/org\/matrix\/android\/sdk\///g')"
|
||||||
body="$( echo $body | sed 's/\/src\/androidTest\/java\// 🔸 /g')"
|
body="$( echo $body | sed 's/\/src\/androidTest\/java\// 🔸 /g')"
|
||||||
fi
|
echo "::set-output name=add_comment::true"
|
||||||
echo "::set-output name=body::$body"
|
echo "::set-output name=body::$body"
|
||||||
|
fi
|
||||||
- name: Find Comment
|
- name: Find Comment
|
||||||
if: always()
|
if: always()
|
||||||
uses: peter-evans/find-comment@v1
|
uses: peter-evans/find-comment@v1
|
||||||
|
@ -60,8 +61,8 @@ jobs:
|
||||||
issue-number: ${{ github.event.pull_request.number }}
|
issue-number: ${{ github.event.pull_request.number }}
|
||||||
comment-author: 'github-actions[bot]'
|
comment-author: 'github-actions[bot]'
|
||||||
body-includes: Ktlint Results
|
body-includes: Ktlint Results
|
||||||
- name: Publish ktlint results to PR
|
- name: Add comment if needed
|
||||||
if: always()
|
if: always() && steps.ktlint-results.outputs.add_comment == 'true'
|
||||||
uses: peter-evans/create-or-update-comment@v1
|
uses: peter-evans/create-or-update-comment@v1
|
||||||
with:
|
with:
|
||||||
comment-id: ${{ steps.fc.outputs.comment-id }}
|
comment-id: ${{ steps.fc.outputs.comment-id }}
|
||||||
|
@ -69,8 +70,18 @@ jobs:
|
||||||
body: |
|
body: |
|
||||||
### Ktlint Results
|
### Ktlint Results
|
||||||
|
|
||||||
${{ steps.get-comment-body.outputs.body }}
|
${{ steps.ktlint-results.outputs.body }}
|
||||||
edit-mode: replace
|
edit-mode: replace
|
||||||
|
- name: Delete comment if needed
|
||||||
|
if: always() && steps.fc.outputs.comment-id != '' && steps.ktlint-results.outputs.add_comment == 'false'
|
||||||
|
uses: actions/github-script@v3
|
||||||
|
with:
|
||||||
|
script: |
|
||||||
|
github.issues.deleteComment({
|
||||||
|
owner: context.repo.owner,
|
||||||
|
repo: context.repo.repo,
|
||||||
|
comment_id: ${{ steps.fc.outputs.comment-id }}
|
||||||
|
})
|
||||||
|
|
||||||
# Lint for main module
|
# Lint for main module
|
||||||
android-lint:
|
android-lint:
|
||||||
|
|
1
changelog.d/4888.misc
Normal file
1
changelog.d/4888.misc
Normal file
|
@ -0,0 +1 @@
|
||||||
|
Add ktlint results on github as a comment only on fail
|
Loading…
Reference in a new issue