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: add sonar scan for pull requests #197

Merged
merged 3 commits into from
Oct 22, 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
25 changes: 16 additions & 9 deletions .github/workflows/maven-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ name: maven-build
on:
push:
branches: ['**/**']
pull_request:
branches: [main]
types: [opened, synchronize, reopened, ready_for_review]
jobs:
build:
runs-on: ubuntu-latest
Expand All @@ -17,11 +20,11 @@ jobs:
MARKDOWN2HTML_MAVEN_PLUGIN_FAIL_ON_ERROR: true
steps:
- name: 📄 Checkout
uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4
uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4
with:
fetch-depth: 0
- name: 🧱 Set up JDK and Maven
uses: actions/setup-java@b36c23c0d998641eff861008f374ee103c25ac73 # v4
uses: actions/setup-java@b36c23c0d998641eff861008f374ee103c25ac73 # v4
with:
distribution: adopt
java-version: 17
Expand All @@ -34,7 +37,7 @@ jobs:
run: echo "cache_key=${{ runner.os }}-mvn-${{ hashFiles('**/pom.xml') }}-${{ github.sha }}" >> $GITHUB_OUTPUT
- name: 💾 Prepare Cache
id: prepare-cache
uses: actions/cache@3624ceb22c1c5a301c8db4169662070a689d9ea8 # v4
uses: actions/cache@3624ceb22c1c5a301c8db4169662070a689d9ea8 # v4
with:
path: |
/home/runner/.m2
Expand Down Expand Up @@ -89,8 +92,12 @@ jobs:
]
- name: 🔘 Print settings.xml
run: cat /home/runner/.m2/settings.xml
- name: 📦 Build with Maven
run: mvn --batch-mode clean package sonar:sonar
- name: 📦 Build with Maven for Pushes
if: github.event_name == 'push'
run: mvn --batch-mode clean package sonar:sonar -Dsonar.branch.name=${{ github.head_ref }}
- name: 📦 Build with Maven for PRs
if: github.event_name == 'pull_request'
run: mvn --batch-mode clean package sonar:sonar -Dsonar.pullrequest.base=${{ github.base_ref }} -Dsonar.pullrequest.branch=${{ github.head_ref }} -Dsonar.pullrequest.key=${{ github.event.pull_request.number }}
outputs:
project_version: ${{ steps.project_version.outputs.project_version }}
cache_key: ${{ steps.cache_key.outputs.cache_key }}
Expand All @@ -108,14 +115,14 @@ jobs:
COM_SONATYPE_CENTRAL_POLARION_OPENSOURCE_GPG_PASSPHRASE: ${{ secrets.COM_SONATYPE_CENTRAL_POLARION_OPENSOURCE_GPG_PASSPHRASE }}
steps:
- name: 🧱 Set up JDK and Maven
uses: actions/setup-java@b36c23c0d998641eff861008f374ee103c25ac73 # v4
uses: actions/setup-java@b36c23c0d998641eff861008f374ee103c25ac73 # v4
with:
distribution: adopt
java-version: 17
gpg-private-key: ${{ secrets.COM_SONATYPE_CENTRAL_POLARION_OPENSOURCE_GPG_PRIVATE_KEY }}
- name: 💾 Restore Cache
id: restore-cache
uses: actions/cache@3624ceb22c1c5a301c8db4169662070a689d9ea8 # v4
uses: actions/cache@3624ceb22c1c5a301c8db4169662070a689d9ea8 # v4
with:
path: |
/home/runner/.m2
Expand All @@ -138,13 +145,13 @@ jobs:
GITHUB_TOKEN: ${{ github.token }}
steps:
- name: 🧱 Set up JDK and Maven
uses: actions/setup-java@b36c23c0d998641eff861008f374ee103c25ac73 # v4
uses: actions/setup-java@b36c23c0d998641eff861008f374ee103c25ac73 # v4
with:
distribution: adopt
java-version: 17
- name: 💾 Restore Cache
id: restore-cache
uses: actions/cache@3624ceb22c1c5a301c8db4169662070a689d9ea8 # v4
uses: actions/cache@3624ceb22c1c5a301c8db4169662070a689d9ea8 # v4
with:
path: |
/home/runner/.m2
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ jobs:
name: Check commit messages
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4
- uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4
with:
ref: ${{ github.event.pull_request.head.ref }}
repository: ${{ github.event.pull_request.head.repo.full_name }}
fetch-depth: 0
- uses: actions/setup-python@f677139bbe7f9c59b41e40162b753c062f5d49a3 # v5
- uses: actions/setup-python@f677139bbe7f9c59b41e40162b753c062f5d49a3 # v5
with:
cache: pip # caching pip dependencies
- run: pip install commitizen
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release-please.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
steps:
- name: release-please
id: release
uses: googleapis/release-please-action@7987652d64b4581673a76e33ad5e98e3dd56832f # v4
uses: googleapis/release-please-action@7987652d64b4581673a76e33ad5e98e3dd56832f # v4
with:
release-type: maven
target-branch: main
2 changes: 2 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v5.0.0
hooks:
- id: check-added-large-files
- id: check-case-conflict
- id: check-merge-conflict
- id: trailing-whitespace
- id: check-xml
Expand Down
2 changes: 1 addition & 1 deletion .yamlfix.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
allow_duplicate_keys = false
line_length = 180
sequence_style = "flow_style"
sequence_style = "flow_style"
9 changes: 0 additions & 9 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -702,15 +702,6 @@
<groupId>org.sonarsource.scanner.maven</groupId>
<artifactId>sonar-maven-plugin</artifactId>
<version>${sonar-maven-plugin.version}</version>
<executions>
<execution>
<id>sonar</id>
<phase>verify</phase>
<goals>
<goal>sonar</goal>
</goals>
</execution>
</executions>
</plugin>

<plugin>
Expand Down
Loading