Skip to content

Commit 2365d2e

Browse files
author
vividcoder
committed
ci: add PR check workflow for build, checkstyle, tests and PR lint
Add GitHub Actions workflow that runs on PRs to develop and release branches with four jobs: PR title/description lint, multi-platform build (JDK 8/x86_64 + JDK 17/aarch64), checkstyle validation for framework and plugins modules, and unit tests with artifact upload on failure.
1 parent dd46d22 commit 2365d2e

1 file changed

Lines changed: 171 additions & 0 deletions

File tree

.github/workflows/pr-check.yml

Lines changed: 171 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,171 @@
1+
name: PR Check
2+
3+
on:
4+
pull_request:
5+
branches: [ 'develop', 'release_**' ]
6+
types: [ opened, edited, synchronize, reopened ]
7+
8+
concurrency:
9+
group: ${{ github.workflow }}-${{ github.head_ref || github.ref }}
10+
cancel-in-progress: true
11+
12+
jobs:
13+
pr-lint:
14+
name: PR Lint
15+
runs-on: ubuntu-latest
16+
17+
steps:
18+
- name: Check PR title format
19+
uses: actions/github-script@v7
20+
with:
21+
script: |
22+
const title = context.payload.pull_request.title;
23+
24+
const errors = [];
25+
26+
// Title should not be empty or too short
27+
if (!title || title.trim().length < 10) {
28+
errors.push('PR title is too short (minimum 10 characters).');
29+
}
30+
31+
// Title should not exceed 72 characters
32+
if (title.length > 72) {
33+
errors.push(`PR title is too long (${title.length}/72 characters).`);
34+
}
35+
36+
// Title should follow conventional format: type: description
37+
// Allowed types: feat, fix, refactor, docs, style, test, chore, ci, perf, build, revert
38+
const conventionalRegex = /^(feat|fix|refactor|docs|style|test|chore|ci|perf|build|revert)(\(.+\))?:\s.+/;
39+
if (!conventionalRegex.test(title)) {
40+
errors.push(
41+
'PR title must follow conventional format: `type: description`\n' +
42+
'Allowed types: feat, fix, refactor, docs, style, test, chore, ci, perf, build, revert\n' +
43+
'Example: `feat: add new transaction validation`'
44+
);
45+
}
46+
47+
if (errors.length > 0) {
48+
const message = '### PR Title Check Failed\n\n' + errors.map(e => `- ${e}`).join('\n');
49+
core.setFailed(message);
50+
} else {
51+
core.info('PR title format is valid.');
52+
}
53+
54+
- name: Check PR description
55+
uses: actions/github-script@v7
56+
with:
57+
script: |
58+
const body = context.payload.pull_request.body;
59+
60+
if (!body || body.trim().length < 20) {
61+
core.setFailed(
62+
'### PR Description Check Failed\n\n' +
63+
'PR description is too short or empty. Please describe what this PR does and why.'
64+
);
65+
} else {
66+
core.info('PR description is valid.');
67+
}
68+
69+
build:
70+
name: Build (JDK ${{ matrix.java }} / ${{ matrix.arch }})
71+
runs-on: ${{ matrix.runner }}
72+
strategy:
73+
fail-fast: false
74+
matrix:
75+
include:
76+
- java: '8'
77+
runner: ubuntu-latest
78+
arch: x86_64
79+
- java: '17'
80+
runner: ubuntu-24.04-arm
81+
arch: aarch64
82+
83+
steps:
84+
- uses: actions/checkout@v4
85+
86+
- name: Set up JDK ${{ matrix.java }}
87+
uses: actions/setup-java@v4
88+
with:
89+
java-version: ${{ matrix.java }}
90+
distribution: 'temurin'
91+
92+
- name: Cache Gradle packages
93+
uses: actions/cache@v4
94+
with:
95+
path: |
96+
~/.gradle/caches
97+
~/.gradle/wrapper
98+
key: ${{ runner.os }}-${{ matrix.arch }}-gradle-${{ hashFiles('**/*.gradle', '**/gradle-wrapper.properties') }}
99+
restore-keys: ${{ runner.os }}-${{ matrix.arch }}-gradle-
100+
101+
- name: Build
102+
run: ./gradlew clean build -x test
103+
104+
checkstyle:
105+
name: Checkstyle
106+
runs-on: ubuntu-latest
107+
108+
steps:
109+
- uses: actions/checkout@v4
110+
111+
- name: Set up JDK 8
112+
uses: actions/setup-java@v4
113+
with:
114+
java-version: '8'
115+
distribution: 'temurin'
116+
117+
- name: Cache Gradle packages
118+
uses: actions/cache@v4
119+
with:
120+
path: |
121+
~/.gradle/caches
122+
~/.gradle/wrapper
123+
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle', '**/gradle-wrapper.properties') }}
124+
restore-keys: ${{ runner.os }}-gradle-
125+
126+
- name: Run Checkstyle
127+
run: ./gradlew :framework:checkstyleMain :framework:checkstyleTest :plugins:checkstyleMain
128+
129+
- name: Upload Checkstyle reports
130+
if: failure()
131+
uses: actions/upload-artifact@v4
132+
with:
133+
name: checkstyle-reports
134+
path: |
135+
framework/build/reports/checkstyle/
136+
plugins/build/reports/checkstyle/
137+
138+
test:
139+
name: Unit Tests
140+
runs-on: ubuntu-latest
141+
needs: build
142+
timeout-minutes: 60
143+
144+
steps:
145+
- uses: actions/checkout@v4
146+
147+
- name: Set up JDK 8
148+
uses: actions/setup-java@v4
149+
with:
150+
java-version: '8'
151+
distribution: 'temurin'
152+
153+
- name: Cache Gradle packages
154+
uses: actions/cache@v4
155+
with:
156+
path: |
157+
~/.gradle/caches
158+
~/.gradle/wrapper
159+
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle', '**/gradle-wrapper.properties') }}
160+
restore-keys: ${{ runner.os }}-gradle-
161+
162+
- name: Run tests
163+
run: ./gradlew test
164+
165+
- name: Upload test reports
166+
if: failure()
167+
uses: actions/upload-artifact@v4
168+
with:
169+
name: test-reports
170+
path: |
171+
**/build/reports/tests/

0 commit comments

Comments
 (0)