Skip to content

Commit

Permalink
Allow Static Analysis on Pull Requests from Forks (#49)
Browse files Browse the repository at this point in the history
* Add two-stage analysis process

* REVERTME: Set to my repo for testing

* Revert "REVERTME: Set to my repo for testing"

This reverts commit b2ed4f9.
  • Loading branch information
wsciaroni authored Oct 23, 2024
1 parent a49a82e commit 6b42ee7
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Android Build And SonarCloud Analysis
name: Android Build
on:
push:
branches:
Expand All @@ -11,6 +11,9 @@ jobs:
build:
name: Build and analyze
runs-on: ubuntu-latest
defaults:
run:
working-directory: android-src/KV4PHT
steps:
- uses: actions/checkout@v4
with:
Expand All @@ -33,13 +36,14 @@ jobs:
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }}
restore-keys: ${{ runner.os }}-gradle
- name: Grant execute permission for gradlew
run: chmod +x ./android-src/KV4PHT/gradlew
run: chmod +x ./gradlew
- name: Build and analyze
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
run: ./gradlew build sonar --info
working-directory: android-src/KV4PHT
run: ./gradlew check --stacktrace
- name: 'Prepare Sonar analysis'
uses: evaristegalois11/sonar-fork-analysis@v1.2.0
- name: Upload APK
if: startsWith(github.ref, 'refs/tags')
uses: AButler/upload-release-assets@v3.0
Expand Down
26 changes: 26 additions & 0 deletions .github/workflows/sonarcloud-android.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: 'Sonar'
on:
workflow_run:
workflows: [ 'Android Build' ]
types:
- completed
jobs:
sonar:
name: 'Sonar analysis'
runs-on: ubuntu-latest
defaults:
run:
working-directory: android-src/KV4PHT
if: ${{ github.event.workflow_run.conclusion == 'success' }}
permissions:
actions: read # Required to download artifacts
steps:
- name: 'Sonar analysis'
uses: wsciaroni/sonar-fork-analysis@v1.2.1-rc
with:
distribution: 'zulu'
java-version: 17
github-token: ${{ secrets.GITHUB_TOKEN }}
sonar-token: ${{ secrets.SONAR_TOKEN }}
project-key: VanceVagell_kv4p-ht
working-directory: ./android-src/KV4PHT/

0 comments on commit 6b42ee7

Please sign in to comment.