|
| 1 | +name: Check Build |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + push: |
| 6 | + branches: [ develop ] |
| 7 | + paths-ignore: |
| 8 | + - '**.md' |
| 9 | + - '.config/**' |
| 10 | + - '.github/**' |
| 11 | + - '.idea/**' |
| 12 | + - 'assets/**' |
| 13 | + pull_request: |
| 14 | + branches: [ develop ] |
| 15 | + paths-ignore: |
| 16 | + - '**.md' |
| 17 | + - '.config/**' |
| 18 | + - '.github/**' |
| 19 | + - '.idea/**' |
| 20 | + - 'assets/**' |
| 21 | + |
| 22 | +jobs: |
| 23 | + build: |
| 24 | + runs-on: ubuntu-latest |
| 25 | + timeout-minutes: 30 |
| 26 | + strategy: |
| 27 | + matrix: |
| 28 | + java: [21] |
| 29 | + distribution: [temurin] |
| 30 | + steps: |
| 31 | + - uses: actions/checkout@v5 |
| 32 | + |
| 33 | + - name: Set up JDK |
| 34 | + uses: actions/setup-java@v5 |
| 35 | + with: |
| 36 | + distribution: ${{ matrix.distribution }} |
| 37 | + java-version: ${{ matrix.java }} |
| 38 | + |
| 39 | + - name: Cache Gradle |
| 40 | + uses: actions/cache@v4 |
| 41 | + with: |
| 42 | + path: | |
| 43 | + ~/.gradle/caches |
| 44 | + ~/.gradle/wrapper |
| 45 | + key: ${{ runner.os }}-gradle-build-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} |
| 46 | + restore-keys: | |
| 47 | + ${{ runner.os }}-gradle-build- |
| 48 | +
|
| 49 | + - name: Build |
| 50 | + run: ./gradlew build buildPlugin --info --stacktrace |
| 51 | + |
| 52 | + - name: Try upload test reports when failure occurs |
| 53 | + uses: actions/upload-artifact@v5 |
| 54 | + if: failure() |
| 55 | + with: |
| 56 | + name: test-reports-${{ matrix.java }} |
| 57 | + path: build/reports/tests/test/** |
| 58 | + |
| 59 | + - name: Check for uncommited changes |
| 60 | + run: | |
| 61 | + if [[ "$(git status --porcelain)" != "" ]]; then |
| 62 | + echo ---------------------------------------- |
| 63 | + echo git status |
| 64 | + echo ---------------------------------------- |
| 65 | + git status |
| 66 | + echo ---------------------------------------- |
| 67 | + echo git diff |
| 68 | + echo ---------------------------------------- |
| 69 | + git diff |
| 70 | + echo ---------------------------------------- |
| 71 | + echo Troubleshooting |
| 72 | + echo ---------------------------------------- |
| 73 | + echo "::error::Unstaged changes detected. Locally try running: git clean -ffdx && mvn -B clean package" |
| 74 | + exit 1 |
| 75 | + fi |
| 76 | +
|
| 77 | + - name: Upload plugin files |
| 78 | + uses: actions/upload-artifact@v5 |
| 79 | + with: |
| 80 | + name: plugin-files-java-${{ matrix.java }} |
| 81 | + path: build/libs/template-placeholder-*.jar |
| 82 | + if-no-files-found: error |
| 83 | + |
| 84 | + checkstyle: |
| 85 | + runs-on: ubuntu-latest |
| 86 | + if: ${{ github.event_name != 'pull_request' || !startsWith(github.head_ref, 'renovate/') }} |
| 87 | + timeout-minutes: 15 |
| 88 | + strategy: |
| 89 | + matrix: |
| 90 | + java: [21] |
| 91 | + distribution: [temurin] |
| 92 | + steps: |
| 93 | + - uses: actions/checkout@v5 |
| 94 | + |
| 95 | + - name: Set up JDK |
| 96 | + uses: actions/setup-java@v5 |
| 97 | + with: |
| 98 | + distribution: ${{ matrix.distribution }} |
| 99 | + java-version: ${{ matrix.java }} |
| 100 | + |
| 101 | + - name: Cache Gradle |
| 102 | + uses: actions/cache@v4 |
| 103 | + with: |
| 104 | + path: | |
| 105 | + ~/.gradle/caches |
| 106 | + ~/.gradle/wrapper |
| 107 | + key: ${{ runner.os }}-gradle-checkstyle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} |
| 108 | + restore-keys: | |
| 109 | + ${{ runner.os }}-gradle-checkstyle- |
| 110 | +
|
| 111 | + - name: Run Checkstyle |
| 112 | + run: ./gradlew checkstyleMain checkstyleTest -PcheckstyleEnabled --stacktrace |
| 113 | + |
| 114 | + pmd: |
| 115 | + runs-on: ubuntu-latest |
| 116 | + if: ${{ github.event_name != 'pull_request' || !startsWith(github.head_ref, 'renovate/') }} |
| 117 | + timeout-minutes: 15 |
| 118 | + strategy: |
| 119 | + matrix: |
| 120 | + java: [21] |
| 121 | + distribution: [temurin] |
| 122 | + steps: |
| 123 | + - uses: actions/checkout@v5 |
| 124 | + |
| 125 | + - name: Set up JDK |
| 126 | + uses: actions/setup-java@v5 |
| 127 | + with: |
| 128 | + distribution: ${{ matrix.distribution }} |
| 129 | + java-version: ${{ matrix.java }} |
| 130 | + |
| 131 | + - name: Run PMD |
| 132 | + run: ./gradlew pmdMain pmdTest -PpmdEnabled --stacktrace -x test |
| 133 | + |
| 134 | + - name: Cache Gradle |
| 135 | + uses: actions/cache@v4 |
| 136 | + with: |
| 137 | + path: | |
| 138 | + ~/.gradle/caches |
| 139 | + ~/.gradle/wrapper |
| 140 | + key: ${{ runner.os }}-gradle-pmd-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} |
| 141 | + restore-keys: | |
| 142 | + ${{ runner.os }}-gradle-pmd- |
| 143 | +
|
| 144 | + - name: Upload report |
| 145 | + if: always() |
| 146 | + uses: actions/upload-artifact@v5 |
| 147 | + with: |
| 148 | + name: pmd-report |
| 149 | + if-no-files-found: ignore |
| 150 | + path: | |
| 151 | + build/reports/pmd/*.html |
0 commit comments