Skip to content

Commit d779531

Browse files
authored
Merge pull request #2 from vikasvk1/feature-github-ci
Add GitHub Actions pipelines
2 parents 3d80cf5 + 5926f5b commit d779531

3 files changed

Lines changed: 97 additions & 0 deletions

File tree

.github/linters/checkstyle.xml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?xml version="1.0"?>
2+
<!DOCTYPE module PUBLIC
3+
"-//Checkstyle//DTD Checkstyle Configuration 1.3//EN"
4+
"https://checkstyle.org/dtds/configuration_1_3.dtd">
5+
<module name="Checker">
6+
<module name="LineLength">
7+
<property name="max" value="120"/>
8+
<property name="ignorePattern" value="^package|^import"/>
9+
</module>
10+
<module name="FileTabCharacter"/>
11+
<module name="TreeWalker">
12+
<module name="AvoidStarImport"/>
13+
<module name="EmptyBlock"/>
14+
<module name="NeedBraces"/>
15+
</module>
16+
</module>

.github/workflows/pr-review.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: PR Review (Checkstyle)
2+
3+
on:
4+
pull_request:
5+
types: [opened, synchronize, reopened]
6+
7+
permissions:
8+
contents: read
9+
pull-requests: write
10+
11+
jobs:
12+
checkstyle:
13+
name: Checkstyle Review
14+
runs-on: ubuntu-latest
15+
steps:
16+
- name: Checkout
17+
uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd
18+
19+
- name: Checkstyle (reviewdog)
20+
uses: dbelyaev/action-checkstyle@0babcc5b0e55e5a8ab6f8a17134f2d613e2bcdda
21+
with:
22+
github_token: ${{ secrets.GITHUB_TOKEN }}
23+
reporter: github-pr-review
24+
level: warning
25+
checkstyle_config: .github/linters/checkstyle.xml

.github/workflows/sonarcloud.yml

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
name: SonarCloud
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
- master
8+
pull_request:
9+
types: [opened, synchronize, reopened]
10+
11+
jobs:
12+
sonarcloud:
13+
name: SonarCloud Scan
14+
runs-on: ubuntu-latest
15+
steps:
16+
- name: Checkout
17+
uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd
18+
with:
19+
fetch-depth: 0
20+
21+
- name: Compile Java (for Sonar)
22+
run: |
23+
set -e
24+
mkdir -p .sonar_classes
25+
find . -name "*.java" \
26+
-not -path "./out/*" \
27+
-not -path "./.idea/*" \
28+
-not -path "./.git/*" \
29+
-not -path "./skills/*" > .sonar_java_files.txt
30+
31+
if [ -s .sonar_java_files.txt ]; then
32+
javac -d .sonar_classes @.sonar_java_files.txt
33+
else
34+
echo "No Java files found to compile."
35+
fi
36+
37+
- name: Validate SonarCloud settings
38+
run: |
39+
if [ -z "${{ vars.SONAR_ORGANIZATION }}" ] || [ -z "${{ vars.SONAR_PROJECT_KEY }}" ]; then
40+
echo "Missing SONAR_ORGANIZATION or SONAR_PROJECT_KEY repo variables."
41+
echo "Set them in GitHub: Settings > Secrets and variables > Actions > Variables."
42+
exit 1
43+
fi
44+
45+
- name: SonarQube Cloud Scan
46+
uses: SonarSource/sonarqube-scan-action@a31c9398be7ace6bbfaf30c0bd5d415f843d45e9
47+
env:
48+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
49+
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
50+
with:
51+
args: >
52+
-Dsonar.organization=${{ vars.SONAR_ORGANIZATION }}
53+
-Dsonar.projectKey=${{ vars.SONAR_PROJECT_KEY }}
54+
-Dsonar.sources=.
55+
-Dsonar.exclusions=**/out/**,**/.idea/**,**/.git/**,**/skills/**
56+
-Dsonar.java.binaries=.sonar_classes

0 commit comments

Comments
 (0)