2021-03-25 19:26:26 +08:00
|
|
|
name: Code Quality Checks
|
|
|
|
|
|
|
|
on:
|
2021-03-27 04:19:48 +08:00
|
|
|
pull_request: { }
|
2021-03-25 19:26:26 +08:00
|
|
|
push:
|
2021-05-07 00:25:34 +08:00
|
|
|
branches: [ main, develop ]
|
2021-03-25 19:26:26 +08:00
|
|
|
|
|
|
|
jobs:
|
|
|
|
check:
|
|
|
|
name: Project Check Suite
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
2022-03-08 07:05:24 +08:00
|
|
|
- uses: actions/checkout@v3
|
2021-03-25 19:26:26 +08:00
|
|
|
- name: Run code quality check suite
|
|
|
|
run: ./tools/check/check_code_quality.sh
|
|
|
|
|
2022-01-05 22:30:20 +08:00
|
|
|
# ktlint for all the modules
|
2021-10-07 16:36:38 +08:00
|
|
|
ktlint:
|
2021-03-25 19:26:26 +08:00
|
|
|
name: Kotlin Linter
|
|
|
|
runs-on: ubuntu-latest
|
2022-02-24 07:13:30 +08:00
|
|
|
# Allow all jobs on main and develop. Just one per PR.
|
2022-02-24 02:11:46 +08:00
|
|
|
concurrency:
|
2022-02-25 00:26:22 +08:00
|
|
|
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) }}
|
2022-02-24 02:11:46 +08:00
|
|
|
cancel-in-progress: true
|
2021-03-25 19:26:26 +08:00
|
|
|
steps:
|
2022-03-08 07:05:24 +08:00
|
|
|
- uses: actions/checkout@v3
|
2021-10-07 16:36:38 +08:00
|
|
|
- name: Run ktlint
|
2021-03-25 19:26:26 +08:00
|
|
|
run: |
|
2021-10-01 19:28:47 +08:00
|
|
|
./gradlew ktlintCheck --continue
|
|
|
|
- name: Upload reports
|
2022-01-05 22:30:20 +08:00
|
|
|
if: always()
|
2022-04-12 07:08:54 +08:00
|
|
|
uses: actions/upload-artifact@v3
|
2021-10-01 19:28:47 +08:00
|
|
|
with:
|
|
|
|
name: ktlinting-report
|
2022-01-05 22:30:20 +08:00
|
|
|
path: |
|
|
|
|
*/build/reports/ktlint/ktlint*/ktlint*.txt
|
|
|
|
- name: Handle Results
|
|
|
|
if: always()
|
2022-01-10 17:38:08 +08:00
|
|
|
id: ktlint-results
|
2022-01-05 22:30:20 +08:00
|
|
|
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
|
2022-01-10 17:38:08 +08:00
|
|
|
echo "::set-output name=add_comment::false"
|
2022-01-05 22:30:20 +08:00
|
|
|
else
|
2022-01-10 17:38:08 +08:00
|
|
|
body="👎\`Failed${results}\`"
|
2022-01-05 22:30:20 +08:00
|
|
|
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')"
|
2022-01-10 17:38:08 +08:00
|
|
|
echo "::set-output name=add_comment::true"
|
|
|
|
echo "::set-output name=body::$body"
|
2022-01-05 22:30:20 +08:00
|
|
|
fi
|
|
|
|
- name: Find Comment
|
2022-02-01 23:37:05 +08:00
|
|
|
if: always() && github.event_name == 'pull_request'
|
2022-03-29 07:04:35 +08:00
|
|
|
uses: peter-evans/find-comment@v2
|
2022-01-05 22:30:20 +08:00
|
|
|
id: fc
|
|
|
|
with:
|
|
|
|
issue-number: ${{ github.event.pull_request.number }}
|
|
|
|
comment-author: 'github-actions[bot]'
|
|
|
|
body-includes: Ktlint Results
|
2022-01-10 17:38:08 +08:00
|
|
|
- name: Add comment if needed
|
2022-02-01 23:37:05 +08:00
|
|
|
if: always() && github.event_name == 'pull_request' && steps.ktlint-results.outputs.add_comment == 'true'
|
2022-03-29 07:04:38 +08:00
|
|
|
uses: peter-evans/create-or-update-comment@v2
|
2022-01-05 22:30:20 +08:00
|
|
|
with:
|
|
|
|
comment-id: ${{ steps.fc.outputs.comment-id }}
|
|
|
|
issue-number: ${{ github.event.pull_request.number }}
|
|
|
|
body: |
|
|
|
|
### Ktlint Results
|
2021-03-25 19:26:26 +08:00
|
|
|
|
2022-01-10 17:38:08 +08:00
|
|
|
${{ steps.ktlint-results.outputs.body }}
|
2022-01-05 22:30:20 +08:00
|
|
|
edit-mode: replace
|
2022-01-10 17:38:08 +08:00
|
|
|
- name: Delete comment if needed
|
2022-02-01 23:37:05 +08:00
|
|
|
if: always() && github.event_name == 'pull_request' && steps.fc.outputs.comment-id != '' && steps.ktlint-results.outputs.add_comment == 'false'
|
2022-01-11 22:31:24 +08:00
|
|
|
uses: actions/github-script@v3
|
2022-01-10 17:38:08 +08:00
|
|
|
with:
|
|
|
|
script: |
|
|
|
|
github.issues.deleteComment({
|
|
|
|
owner: context.repo.owner,
|
|
|
|
repo: context.repo.repo,
|
|
|
|
comment_id: ${{ steps.fc.outputs.comment-id }}
|
|
|
|
})
|
2022-01-05 22:30:20 +08:00
|
|
|
|
|
|
|
# Lint for main module
|
2021-03-25 19:26:26 +08:00
|
|
|
android-lint:
|
|
|
|
name: Android Linter
|
|
|
|
runs-on: ubuntu-latest
|
2022-02-24 07:13:30 +08:00
|
|
|
# Allow all jobs on main and develop. Just one per PR.
|
2022-02-24 02:11:46 +08:00
|
|
|
concurrency:
|
2022-02-24 06:58:51 +08:00
|
|
|
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) }}
|
2022-02-24 02:11:46 +08:00
|
|
|
cancel-in-progress: true
|
2021-03-25 19:26:26 +08:00
|
|
|
steps:
|
2022-03-08 07:05:24 +08:00
|
|
|
- uses: actions/checkout@v3
|
2022-03-22 07:03:30 +08:00
|
|
|
- uses: actions/cache@v3
|
2021-03-25 19:26:26 +08:00
|
|
|
with:
|
|
|
|
path: |
|
|
|
|
~/.gradle/caches
|
|
|
|
~/.gradle/wrapper
|
|
|
|
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
|
|
|
|
restore-keys: |
|
|
|
|
${{ runner.os }}-gradle-
|
2021-09-02 16:42:56 +08:00
|
|
|
- name: Lint analysis
|
|
|
|
run: ./gradlew clean :vector:lint --stacktrace
|
2021-03-25 19:26:26 +08:00
|
|
|
- name: Upload reports
|
2022-01-07 22:32:18 +08:00
|
|
|
if: always()
|
2022-04-12 07:08:54 +08:00
|
|
|
uses: actions/upload-artifact@v3
|
2021-03-25 19:26:26 +08:00
|
|
|
with:
|
2021-09-02 16:42:56 +08:00
|
|
|
name: lint-report
|
2021-03-27 04:19:48 +08:00
|
|
|
path: |
|
|
|
|
vector/build/reports/*.*
|
2021-09-03 15:42:53 +08:00
|
|
|
|
|
|
|
# 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 ]
|
2022-02-24 07:13:30 +08:00
|
|
|
# Allow all jobs on develop. Just one per PR.
|
2022-02-24 06:58:51 +08:00
|
|
|
concurrency:
|
2022-02-25 00:28:14 +08:00
|
|
|
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) }}
|
2022-02-24 06:58:51 +08:00
|
|
|
cancel-in-progress: true
|
2021-09-03 15:42:53 +08:00
|
|
|
steps:
|
2022-03-08 07:05:24 +08:00
|
|
|
- uses: actions/checkout@v3
|
2022-03-22 07:03:30 +08:00
|
|
|
- uses: actions/cache@v3
|
2021-09-03 15:42:53 +08:00
|
|
|
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
|
|
|
|
- name: Upload ${{ matrix.target }} linting report
|
2022-01-07 22:32:18 +08:00
|
|
|
if: always()
|
2022-04-12 07:08:54 +08:00
|
|
|
uses: actions/upload-artifact@v3
|
2021-09-03 15:42:53 +08:00
|
|
|
with:
|
|
|
|
name: release-lint-report-${{ matrix.target }}
|
|
|
|
path: |
|
|
|
|
vector/build/reports/*.*
|
2022-05-12 23:02:22 +08:00
|
|
|
|
|
|
|
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
|
|
|
|
- name: Upload reports
|
|
|
|
if: always()
|
|
|
|
uses: actions/upload-artifact@v3
|
|
|
|
with:
|
|
|
|
name: detekt-report
|
|
|
|
path: |
|
|
|
|
*/build/reports/detekt/detekt.html
|