Skip to content
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

ci: Upload SARIF files with lint results #1060

Merged
merged 7 commits into from
Oct 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 28 additions & 7 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@ jobs:
strategy:
matrix:
color: ["orange"]
store: ["fdroid", "github", "google"]
type: ["debug", "release"]
store: [ "Fdroid", "Github", "Google" ]
type: [ "Debug", "Release" ]
name: Android Lint
runs-on: ubuntu-latest

Expand All @@ -81,16 +81,37 @@ jobs:
with:
gradle-cache-encryption-key: ${{ secrets.GRADLE_ENCRYPTION_KEY }}

# Run lint. Ignore a failing exit code, but save it for later.
- name: Regular lint ${{ matrix.color }}${{ matrix.store }}${{ matrix.type }}
run: ./gradlew lint${{ matrix.color }}${{ matrix.store }}${{ matrix.type }}
id: runlint
run: |
set +e
./gradlew lint${{ matrix.color }}${{ matrix.store }}${{ matrix.type }}
echo "exitcode=$?" >> $GITHUB_OUTPUT

- name: Merge SARIF files
run: |
jq -s '{ "$schema": "https://json.schemastore.org/sarif-2.1.0", "version": "2.1.0", "runs": map(.runs) | add }' */*/build/reports/lint-results-${{ matrix.color }}${{ matrix.store }}${{ matrix.type }}.sarif */build/reports/lint-results-${{ matrix.color }}${{ matrix.store }}${{ matrix.type }}.sarif > merged-${{ matrix.color }}${{ matrix.store }}${{ matrix.type }}.sarif

- name: Upload SARIF file
uses: github/codeql-action/upload-sarif@v3
with:
category: ${{ matrix.color }}${{ matrix.store }}${{ matrix.type }}
sarif_file: merged-${{ matrix.color }}${{ matrix.store }}${{ matrix.type }}.sarif

# Exit with whatever exit code the original lint run exited with, to
# ensure this job fails if lint fails, *but* the lint reports are still
# uploaded.
- name: Fail if lint failed
run: exit ${{ steps.runlint.outputs.exitcode }}

# Android tests are per variant
test:
strategy:
matrix:
color: ["orange"]
store: ["fdroid", "github", "google"]
type: ["debug", "release"]
store: [ "Fdroid", "Github", "Google" ]
type: [ "Debug", "Release" ]
name: Android Test
runs-on: ubuntu-latest

Expand All @@ -110,8 +131,8 @@ jobs:
strategy:
matrix:
color: ["orange"]
store: ["fdroid", "github", "google"]
type: ["debug", "release"]
store: [ "Fdroid", "Github", "Google" ]
type: [ "Debug", "Release" ]
name: Android Assemble
runs-on: ubuntu-latest

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,13 @@
* see <http://www.gnu.org/licenses>.
*/


import com.android.build.api.dsl.ApplicationExtension
import com.android.build.api.dsl.LibraryExtension
import com.android.build.api.dsl.Lint
import java.io.File
import org.gradle.api.Plugin
import org.gradle.api.Project
import org.gradle.kotlin.dsl.configure
import java.io.File

class AndroidLintConventionPlugin : Plugin<Project> {
override fun apply(target: Project) {
Expand All @@ -46,4 +45,5 @@ class AndroidLintConventionPlugin : Plugin<Project> {
private fun Lint.configure(project: Project) {
lintConfig = File(project.findProject(":app")?.projectDir, "lint.xml")
baseline = File("lint-baseline.xml")
sarifReport = true
}