1- name : Build cwms-data-api-client
1+ name : " Build and Static Code Analysis "
22on :
3+ push :
4+ branches : [ main ]
35 pull_request :
4- branches :
5- - main
6+ branches : [ main ]
7+ schedule :
8+ - cron : ' 0 0 * * 0'
9+
610
711jobs :
8- build :
9- name : build and test
12+ analyze :
13+ name : Analyze
1014 runs-on : ubuntu-latest
1115 steps :
12- - name : checkout code
16+ - name : Checkout repository
1317 uses : actions/checkout@v4
18+ with :
19+ # Disabling shallow clone is needed for Sonar reporting
20+ fetch-depth : 0
21+
22+ - name : Initialize CodeQL
23+ uses : github/codeql-action/init@v3
24+ with :
25+ languages : ' java'
1426 - name : setup java
1527 uses : actions/setup-java@v4
1628 with :
1729 java-version : ' 21'
1830 java-package : jdk
1931 distribution : ' temurin'
32+ - name : Setup Gradle
33+ uses : gradle/actions/setup-gradle@v3.4.2
34+ with :
35+ dependency-graph : generate-and-submit
2036 - name : Cache SonarCloud packages
2137 uses : actions/cache@v4.0.0
2238 with :
2339 path : ~/.sonar/cache
2440 key : ${{ runner.os }}-sonar
2541 restore-keys : ${{ runner.os }}-sonar
2642 - name : build and test
27- id : thebuild
43+ id : build
2844 run : ./gradlew build --info --init-script init.gradle
29- - name : Setup .NET Core # Required to execute ReportGenerator
30- uses : actions/setup-dotnet@v4
31- with :
32- dotnet-version : 6.x
33- dotnet-quality : ' ga'
34- - name : Analyze
45+ - name : CodeQL Analysis
46+ uses : github/codeql-action/analyze@v3
47+ - name : SonarCloud Analysis
3548 env :
3649 GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
3750 SONAR_TOKEN : ${{ secrets.SONAR_TOKEN }}
3851 run : ./gradlew sonar
39- - name : ReportGenerator
40- uses : danielpalme/ReportGenerator-GitHub-Action@5.3.6
41- with :
42- reports : cwms-aaa-client/build/reports/jacoco/test/jacocoTestReport.xml;cwms-http-client/build/reports/jacoco/test/jacocoTestReport.xml;cwms-radar-client/build/reports/jacoco/test/jacocoTestReport.xml
43- targetdir : .github/coveragereport
44- reporttypes : Html;MarkdownSummaryGithub;Badges
45- - name : Upload coverage report artifact
46- uses : actions/upload-artifact@v4.3.3
47- with :
48- name : CoverageReport # Artifact name
49- path : .github/coveragereport # Directory containing files to upload
50- - name : Commit and push Badges
51- if : github.event_name != 'pull_request' && github.ref != 'refs/heads/main'
52- run : |
53- cd .github/coveragereport
54- if [[ `git status --porcelain badge_*coverage.svg` ]]; then
55- git config --global user.name 'builduser'
56- git config --global user.email 'builduser@rmanet.com'
57- git add badge_*coverage.svg
58- git commit -m "Autogenerated JaCoCo coverage badge" badge_*coverage.svg
59- git push
60- fi
0 commit comments