Skip to content

Commit e19b27b

Browse files
authored
De-duplicate sonar job in the CI (#1238)
* De-duplicate sonar job in the CI * Remove workaround for `src/*/kotlin` folders * Downgrade the sonarqube plugin version * Try increasing workers for this job, since it's quite slow * Warn about regression in latest sonarqube release * Forbid backups to prevent cryptographic issues
1 parent 7a4a8f2 commit e19b27b

File tree

7 files changed

+14
-54
lines changed

7 files changed

+14
-54
lines changed

.github/workflows/quality.yml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -52,12 +52,6 @@ jobs:
5252
name: linting-report
5353
path: |
5454
*/build/reports/**/*.*
55-
- name: 🔊 Publish results to Sonar
56-
env:
57-
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
58-
ORG_GRADLE_PROJECT_SONAR_LOGIN: ${{ secrets.SONAR_TOKEN }}
59-
if: ${{ always() && env.SONAR_TOKEN != '' && env.ORG_GRADLE_PROJECT_SONAR_LOGIN != '' }}
60-
run: ./gradlew sonar $CI_GRADLE_ARG_PROPERTIES
6155
- name: Prepare Danger
6256
if: always()
6357
run: |

.github/workflows/sonar.yml

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Code Quality Checks
1+
name: Sonar
22

33
on:
44
workflow_dispatch:
@@ -10,11 +10,11 @@ on:
1010
# Enrich gradle.properties for CI/CD
1111
env:
1212
GRADLE_OPTS: -Dorg.gradle.jvmargs="-Xmx3072m -Dfile.encoding=UTF-8 -XX:+HeapDumpOnOutOfMemoryError" -XX:MaxMetaspaceSize=512m -Dkotlin.daemon.jvm.options="-Xmx2g" -Dkotlin.incremental=false
13-
CI_GRADLE_ARG_PROPERTIES: --stacktrace -PpreDexEnable=false --max-workers 2 --no-daemon --warn
13+
CI_GRADLE_ARG_PROPERTIES: --stacktrace -PpreDexEnable=false --max-workers 4 --no-daemon --warn
1414

1515
jobs:
1616
sonar:
17-
name: Project Check Suite
17+
name: Sonar Quality Checks
1818
runs-on: ubuntu-latest
1919
# Allow all jobs on main and develop. Just one per PR.
2020
concurrency:
@@ -41,9 +41,3 @@ jobs:
4141
ORG_GRADLE_PROJECT_SONAR_LOGIN: ${{ secrets.SONAR_TOKEN }}
4242
if: ${{ always() && env.SONAR_TOKEN != '' && env.ORG_GRADLE_PROJECT_SONAR_LOGIN != '' }}
4343
run: ./gradlew sonar $CI_GRADLE_ARG_PROPERTIES
44-
- name: Prepare Danger
45-
if: always()
46-
run: |
47-
npm install --save-dev @babel/core
48-
npm install --save-dev @babel/plugin-transform-flow-strip-types
49-
yarn add danger-plugin-lint-report --dev

app/src/main/AndroidManifest.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222

2323
<application
2424
android:name=".ElementXApplication"
25-
android:allowBackup="true"
25+
android:allowBackup="false"
2626
android:dataExtractionRules="@xml/data_extraction_rules"
2727
android:fullBackupContent="@xml/backup_rules"
2828
android:icon="@mipmap/ic_launcher"

app/src/main/res/xml/backup_rules.xml

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,8 @@
1515
-->
1616

1717
<!--
18-
Sample backup rules file; uncomment and customize as necessary.
19-
See https://developer.android.com/guide/topics/data/autobackup
20-
for details.
21-
Note: This file is ignored for devices older that API 31
22-
See https://developer.android.com/about/versions/12/backup-restore
18+
All backup is disabled since it would clash with encryption.
2319
-->
2420
<full-backup-content>
25-
<!--
26-
<include domain="sharedpref" path="."/>
27-
<exclude domain="sharedpref" path="device.xml"/>
28-
-->
21+
<exclude domain="root" path="." />
2922
</full-backup-content>
Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?xml version="1.0" encoding="utf-8"?><!--
2-
~ Copyright (c) 2022 New Vector Ltd
2+
~ Copyright (c) 2023 New Vector Ltd
33
~
44
~ Licensed under the Apache License, Version 2.0 (the "License");
55
~ you may not use this file except in compliance with the License.
@@ -15,21 +15,13 @@
1515
-->
1616

1717
<!--
18-
Sample data extraction rules file; uncomment and customize as necessary.
19-
See https://developer.android.com/about/versions/12/backup-restore#xml-changes
20-
for details.
18+
All backup is disabled since it would clash with encryption.
2119
-->
2220
<data-extraction-rules>
2321
<cloud-backup>
24-
<!-- TODO: Use <include> and <exclude> to control what is backed up.
25-
<include .../>
26-
<exclude .../>
27-
-->
22+
<exclude domain="root" path="." />
2823
</cloud-backup>
29-
<!--
3024
<device-transfer>
31-
<include .../>
32-
<exclude .../>
25+
<exclude domain="root" path="." />
3326
</device-transfer>
34-
-->
3527
</data-extraction-rules>

build.gradle.kts

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -143,22 +143,6 @@ sonar {
143143
}
144144
}
145145

146-
allprojects {
147-
val projectDir = projectDir.toString()
148-
sonar {
149-
properties {
150-
// Note: folders `kotlin` are not supported (yet), I asked on their side: https://community.sonarsource.com/t/82824
151-
// As a workaround provide the path in `sonar.sources` property.
152-
if (File("$projectDir/src/main/kotlin").exists()) {
153-
property("sonar.sources", "src/main/kotlin")
154-
}
155-
if (File("$projectDir/src/test/kotlin").exists()) {
156-
property("sonar.tests", "src/test/kotlin")
157-
}
158-
}
159-
}
160-
}
161-
162146
allprojects {
163147
tasks.withType<Test> {
164148
maxParallelForks = (Runtime.getRuntime().availableProcessors() / 2).coerceAtLeast(1)

gradle/libs.versions.toml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,9 @@ dependencygraph = { id = "com.savvasdalkitsis.module-dependency-graph", version.
203203
dependencycheck = { id = "org.owasp.dependencycheck", version.ref = "dependencycheck" }
204204
dependencyanalysis = { id = "com.autonomousapps.dependency-analysis", version.ref = "dependencyanalysis" }
205205
paparazzi = "app.cash.paparazzi:1.3.1"
206-
sonarqube = "org.sonarqube:4.3.1.3277"
207206
kover = "org.jetbrains.kotlinx.kover:0.6.1"
208207
sqldelight = { id = "com.squareup.sqldelight", version.ref = "sqldelight" }
208+
209+
# Version '4.3.1.3277' introduced some regressions in CI time (more than 2x slower), so make sure
210+
# this is no longer the case before upgrading.
211+
sonarqube = "org.sonarqube:4.2.1.3168"

0 commit comments

Comments
 (0)