|
| 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 | + needs: pr-lint |
| 72 | + runs-on: ${{ matrix.runner }} |
| 73 | + strategy: |
| 74 | + fail-fast: false |
| 75 | + matrix: |
| 76 | + include: |
| 77 | + - java: '8' |
| 78 | + runner: ubuntu-latest |
| 79 | + arch: x86_64 |
| 80 | + - java: '17' |
| 81 | + runner: ubuntu-24.04-arm |
| 82 | + arch: aarch64 |
| 83 | + |
| 84 | + steps: |
| 85 | + - uses: actions/checkout@v4 |
| 86 | + |
| 87 | + - name: Set up JDK ${{ matrix.java }} |
| 88 | + uses: actions/setup-java@v4 |
| 89 | + with: |
| 90 | + java-version: ${{ matrix.java }} |
| 91 | + distribution: 'temurin' |
| 92 | + |
| 93 | + - name: Cache Gradle packages |
| 94 | + uses: actions/cache@v4 |
| 95 | + with: |
| 96 | + path: | |
| 97 | + ~/.gradle/caches |
| 98 | + ~/.gradle/wrapper |
| 99 | + key: ${{ runner.os }}-${{ matrix.arch }}-gradle-${{ hashFiles('**/*.gradle', '**/gradle-wrapper.properties') }} |
| 100 | + restore-keys: ${{ runner.os }}-${{ matrix.arch }}-gradle- |
| 101 | + |
| 102 | + - name: Build |
| 103 | + run: ./gradlew clean build -x test |
| 104 | + |
| 105 | + checkstyle: |
| 106 | + name: Checkstyle |
| 107 | + runs-on: ubuntu-latest |
| 108 | + |
| 109 | + steps: |
| 110 | + - uses: actions/checkout@v4 |
| 111 | + |
| 112 | + - name: Set up JDK 8 |
| 113 | + uses: actions/setup-java@v4 |
| 114 | + with: |
| 115 | + java-version: '8' |
| 116 | + distribution: 'temurin' |
| 117 | + |
| 118 | + - name: Cache Gradle packages |
| 119 | + uses: actions/cache@v4 |
| 120 | + with: |
| 121 | + path: | |
| 122 | + ~/.gradle/caches |
| 123 | + ~/.gradle/wrapper |
| 124 | + key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle', '**/gradle-wrapper.properties') }} |
| 125 | + restore-keys: ${{ runner.os }}-gradle- |
| 126 | + |
| 127 | + - name: Run Checkstyle |
| 128 | + run: ./gradlew :framework:checkstyleMain :framework:checkstyleTest :plugins:checkstyleMain |
| 129 | + |
| 130 | + - name: Upload Checkstyle reports |
| 131 | + if: failure() |
| 132 | + uses: actions/upload-artifact@v4 |
| 133 | + with: |
| 134 | + name: checkstyle-reports |
| 135 | + path: | |
| 136 | + framework/build/reports/checkstyle/ |
| 137 | + plugins/build/reports/checkstyle/ |
| 138 | +
|
| 139 | + test: |
| 140 | + name: Unit Tests (JDK ${{ matrix.java }} / ${{ matrix.arch }}) |
| 141 | + runs-on: ${{ matrix.runner }} |
| 142 | + needs: build |
| 143 | + timeout-minutes: 60 |
| 144 | + strategy: |
| 145 | + fail-fast: false |
| 146 | + matrix: |
| 147 | + include: |
| 148 | + - java: '8' |
| 149 | + runner: ubuntu-latest |
| 150 | + arch: x86_64 |
| 151 | + - java: '17' |
| 152 | + runner: ubuntu-24.04-arm |
| 153 | + arch: aarch64 |
| 154 | + |
| 155 | + steps: |
| 156 | + - uses: actions/checkout@v4 |
| 157 | + |
| 158 | + - name: Set up JDK ${{ matrix.java }} |
| 159 | + uses: actions/setup-java@v4 |
| 160 | + with: |
| 161 | + java-version: ${{ matrix.java }} |
| 162 | + distribution: 'temurin' |
| 163 | + |
| 164 | + - name: Cache Gradle packages |
| 165 | + uses: actions/cache@v4 |
| 166 | + with: |
| 167 | + path: | |
| 168 | + ~/.gradle/caches |
| 169 | + ~/.gradle/wrapper |
| 170 | + key: ${{ runner.os }}-${{ matrix.arch }}-gradle-${{ hashFiles('**/*.gradle', '**/gradle-wrapper.properties') }} |
| 171 | + restore-keys: ${{ runner.os }}-${{ matrix.arch }}-gradle- |
| 172 | + |
| 173 | + - name: Run tests |
| 174 | + run: ./gradlew test |
| 175 | + |
| 176 | + - name: Upload test reports |
| 177 | + if: failure() |
| 178 | + uses: actions/upload-artifact@v4 |
| 179 | + with: |
| 180 | + name: test-reports-${{ matrix.arch }} |
| 181 | + path: | |
| 182 | + **/build/reports/tests/ |
0 commit comments