Skip to content

Commit e3120b3

Browse files
authored
Fix: [AEA-0000] - Fix sonar for java. Fix release tagging flow (#9)
## Summary - 🤖 Operational or Infrastructure Change ### Details This should fix java sonar scanning. Also adds an optional input that can disable sonar altogether: - If `run_sonar` is false, `SONAR_TOKEN_EXISTS` will be unset/false - If `run_sonar` is true, and the sonar token is set, then the analysis steps can run - If it's a Java project, the java one runs - If it's not a java project, the normal one runs Also adds a missing package that stopped the release tagging from working.
1 parent 017c8a0 commit e3120b3

File tree

3 files changed

+41
-6
lines changed

3 files changed

+41
-6
lines changed

.github/workflows/quality-checks.yml

Lines changed: 28 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,11 @@ on:
1111
description: "If true, the action will install java into the runner, separately from ASDF."
1212
default: false
1313
required: false
14+
run_sonar:
15+
type: boolean
16+
description: Toggle to run sonar code analyis on this repository.
17+
default: true
18+
required: false
1419

1520
jobs:
1621
quality_checks:
@@ -107,7 +112,22 @@ jobs:
107112
echo "****************"
108113
echo "uses_poetry=false" >> $GITHUB_OUTPUT
109114
fi
110-
115+
116+
- name: Check if project uses Java
117+
id: check_java
118+
run: |
119+
if [ -f pom.xml ]; then
120+
echo "****************"
121+
echo "Detected a Java project"
122+
echo "****************"
123+
echo "uses_java=true" >> $GITHUB_OUTPUT
124+
else
125+
echo "****************"
126+
echo "Project does not use Java"
127+
echo "****************"
128+
echo "uses_java=false" >> $GITHUB_OUTPUT
129+
fi
130+
111131
- name: Check for SAM templates
112132
id: check_sam_templates
113133
run: |
@@ -306,13 +326,16 @@ jobs:
306326
- name: "check is SONAR_TOKEN exists"
307327
env:
308328
super_secret: ${{ secrets.SONAR_TOKEN }}
309-
if: ${{ env.super_secret != '' }}
310-
run: echo "RUN_SONAR=true" >> "$GITHUB_ENV"
329+
if: ${{ env.super_secret != '' && inputs.run_sonar == 'true' }}
330+
run: echo "SONAR_TOKEN_EXISTS=true" >> "$GITHUB_ENV"
331+
332+
- name: Run SonarQube analysis
333+
if: ${{ steps.check_java.outputs.uses_java == 'true' && env.SONAR_TOKEN_EXISTS == 'true' }}
334+
run: mvn sonar:sonar -Dsonar.login=${{ secrets.SONAR_TOKEN }}
311335

312-
313336
- name: SonarCloud Scan
314337
uses: SonarSource/sonarcloud-github-action@master
315-
if: ${{ env.RUN_SONAR == 'true' }}
338+
if: ${{ steps.check_java.outputs.uses_java == 'false' && env.SONAR_TOKEN_EXISTS == 'true' }}
316339
env:
317340
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
318341
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}

package-lock.json

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,9 @@
1414
"license": "MIT",
1515
"devDependencies": {
1616
"@semantic-release/changelog": "^6.0.3",
17-
"@semantic-release/release-notes-generator": "^14.0.1",
1817
"@semantic-release/commit-analyzer": "^13.0.0",
18+
"@semantic-release/release-notes-generator": "^14.0.1",
19+
"conventional-changelog-eslint": "^6.0.0",
1920
"semantic-release": "^24.2.0"
2021
}
2122
}

0 commit comments

Comments
 (0)