|
| 1 | +name: Java CI |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - master |
| 7 | + paths: |
| 8 | + - "**/*.java" |
| 9 | + - "**/*.gradle" |
| 10 | + - "**/*.gradle.kts" |
| 11 | + - "gradle.properties" |
| 12 | + - "settings.gradle" |
| 13 | + - "settings.gradle.kts" |
| 14 | + - "gradle/**" |
| 15 | + - "gradlew" |
| 16 | + - "gradlew.bat" |
| 17 | + pull_request: |
| 18 | + |
| 19 | +permissions: |
| 20 | + contents: read |
| 21 | + |
| 22 | +concurrency: |
| 23 | + group: java-ci-${{ github.ref }} |
| 24 | + cancel-in-progress: true |
| 25 | + |
| 26 | +env: |
| 27 | + REDIS_RUNNING: "true" |
| 28 | + USER_NAME: rqueue |
| 29 | + TERM: dumb |
| 30 | + JVM_OPTS: -Xmx8g |
| 31 | + |
| 32 | +jobs: |
| 33 | + build: |
| 34 | + runs-on: ubuntu-latest |
| 35 | + steps: |
| 36 | + - name: Checkout |
| 37 | + uses: actions/checkout@v4 |
| 38 | + |
| 39 | + - name: Set up Java 17 |
| 40 | + uses: actions/setup-java@v4 |
| 41 | + with: |
| 42 | + distribution: temurin |
| 43 | + java-version: "17" |
| 44 | + cache: gradle |
| 45 | + |
| 46 | + - name: Expose Java 17 to Gradle toolchains |
| 47 | + run: | |
| 48 | + echo "JAVA_HOME=$JAVA_HOME" >> "$GITHUB_ENV" |
| 49 | + echo "ORG_GRADLE_JAVA_INSTALLATIONS_PATHS=$JAVA_HOME" >> "$GITHUB_ENV" |
| 50 | + java -version |
| 51 | + javac -version |
| 52 | +
|
| 53 | + - name: Set up Gradle |
| 54 | + uses: gradle/actions/setup-gradle@v4 |
| 55 | + |
| 56 | + - name: Resolve dependencies |
| 57 | + run: ./gradlew dependencies |
| 58 | + |
| 59 | + - name: Compile main sources |
| 60 | + run: ./gradlew compileJava |
| 61 | + |
| 62 | + - name: Compile test sources |
| 63 | + run: ./gradlew compileTestJava |
| 64 | + |
| 65 | + unit_test: |
| 66 | + needs: build |
| 67 | + runs-on: ubuntu-latest |
| 68 | + steps: |
| 69 | + - name: Checkout |
| 70 | + uses: actions/checkout@v4 |
| 71 | + |
| 72 | + - name: Set up Java 17 |
| 73 | + uses: actions/setup-java@v4 |
| 74 | + with: |
| 75 | + distribution: temurin |
| 76 | + java-version: "17" |
| 77 | + cache: gradle |
| 78 | + |
| 79 | + - name: Expose Java 17 to Gradle toolchains |
| 80 | + run: | |
| 81 | + echo "JAVA_HOME=$JAVA_HOME" >> "$GITHUB_ENV" |
| 82 | + echo "ORG_GRADLE_JAVA_INSTALLATIONS_PATHS=$JAVA_HOME" >> "$GITHUB_ENV" |
| 83 | + java -version |
| 84 | + javac -version |
| 85 | +
|
| 86 | + - name: Set up Gradle |
| 87 | + uses: gradle/actions/setup-gradle@v4 |
| 88 | + |
| 89 | + - name: Run unit tests |
| 90 | + run: ./gradlew test -DincludeTags=unit |
| 91 | + |
| 92 | + - name: Upload JaCoCo exec data |
| 93 | + if: always() |
| 94 | + uses: actions/upload-artifact@v4 |
| 95 | + with: |
| 96 | + name: coverage-unit |
| 97 | + path: "**/build/reports/jacoco/*.exec" |
| 98 | + if-no-files-found: error |
| 99 | + |
| 100 | + - name: Upload JUnit reports |
| 101 | + if: always() |
| 102 | + uses: actions/upload-artifact@v4 |
| 103 | + with: |
| 104 | + name: unit-test-results |
| 105 | + path: | |
| 106 | + rqueue-spring-boot-starter/build/reports/junit/xml |
| 107 | + rqueue-spring/build/reports/junit/xml |
| 108 | + rqueue-core/build/reports/junit/xml |
| 109 | + if-no-files-found: ignore |
| 110 | + |
| 111 | + producer_only_test: |
| 112 | + needs: build |
| 113 | + runs-on: ubuntu-latest |
| 114 | + steps: |
| 115 | + - name: Checkout |
| 116 | + uses: actions/checkout@v4 |
| 117 | + |
| 118 | + - name: Set up Java 17 |
| 119 | + uses: actions/setup-java@v4 |
| 120 | + with: |
| 121 | + distribution: temurin |
| 122 | + java-version: "17" |
| 123 | + cache: gradle |
| 124 | + |
| 125 | + - name: Expose Java 17 to Gradle toolchains |
| 126 | + run: | |
| 127 | + echo "JAVA_HOME=$JAVA_HOME" >> "$GITHUB_ENV" |
| 128 | + echo "ORG_GRADLE_JAVA_INSTALLATIONS_PATHS=$JAVA_HOME" >> "$GITHUB_ENV" |
| 129 | + java -version |
| 130 | + javac -version |
| 131 | +
|
| 132 | + - name: Set up Gradle |
| 133 | + uses: gradle/actions/setup-gradle@v4 |
| 134 | + |
| 135 | + - name: Install Redis |
| 136 | + run: | |
| 137 | + sudo apt-get update |
| 138 | + sudo apt-get install -y redis-server |
| 139 | + redis-cli --version |
| 140 | +
|
| 141 | + - name: Run producer-only tests |
| 142 | + run: ./gradlew test -DincludeTags=producerOnly |
| 143 | + |
| 144 | + - name: Upload JaCoCo exec data |
| 145 | + if: always() |
| 146 | + uses: actions/upload-artifact@v4 |
| 147 | + with: |
| 148 | + name: coverage-producer |
| 149 | + path: "**/build/reports/jacoco/*.exec" |
| 150 | + if-no-files-found: error |
| 151 | + |
| 152 | + - name: Upload JUnit reports |
| 153 | + if: always() |
| 154 | + uses: actions/upload-artifact@v4 |
| 155 | + with: |
| 156 | + name: producer-test-results |
| 157 | + path: | |
| 158 | + rqueue-spring-boot-starter/build/reports/junit/xml |
| 159 | + rqueue-spring/build/reports/junit/xml |
| 160 | + rqueue-core/build/reports/junit/xml |
| 161 | + if-no-files-found: ignore |
| 162 | + |
| 163 | + integration_test: |
| 164 | + needs: build |
| 165 | + runs-on: ubuntu-latest |
| 166 | + steps: |
| 167 | + - name: Checkout |
| 168 | + uses: actions/checkout@v4 |
| 169 | + |
| 170 | + - name: Set up Java 17 |
| 171 | + uses: actions/setup-java@v4 |
| 172 | + with: |
| 173 | + distribution: temurin |
| 174 | + java-version: "17" |
| 175 | + cache: gradle |
| 176 | + |
| 177 | + - name: Expose Java 17 to Gradle toolchains |
| 178 | + run: | |
| 179 | + echo "JAVA_HOME=$JAVA_HOME" >> "$GITHUB_ENV" |
| 180 | + echo "ORG_GRADLE_JAVA_INSTALLATIONS_PATHS=$JAVA_HOME" >> "$GITHUB_ENV" |
| 181 | + java -version |
| 182 | + javac -version |
| 183 | +
|
| 184 | + - name: Set up Gradle |
| 185 | + uses: gradle/actions/setup-gradle@v4 |
| 186 | + |
| 187 | + - name: Install Redis |
| 188 | + run: | |
| 189 | + sudo apt-get update |
| 190 | + sudo apt-get install -y redis-server |
| 191 | + redis-cli --version |
| 192 | +
|
| 193 | + - name: Run integration tests |
| 194 | + run: ./gradlew test -DincludeTags=integration -DexcludeTags=redisCluster,producerOnly,local |
| 195 | + |
| 196 | + - name: Upload JaCoCo exec data |
| 197 | + if: always() |
| 198 | + uses: actions/upload-artifact@v4 |
| 199 | + with: |
| 200 | + name: coverage-integration |
| 201 | + path: "**/build/reports/jacoco/*.exec" |
| 202 | + if-no-files-found: error |
| 203 | + |
| 204 | + - name: Upload JUnit reports |
| 205 | + if: always() |
| 206 | + uses: actions/upload-artifact@v4 |
| 207 | + with: |
| 208 | + name: integration-test-results |
| 209 | + path: | |
| 210 | + rqueue-spring-boot-starter/build/reports/junit/xml |
| 211 | + rqueue-spring/build/reports/junit/xml |
| 212 | + rqueue-core/build/reports/junit/xml |
| 213 | + if-no-files-found: ignore |
| 214 | + |
| 215 | + redis_cluster_test: |
| 216 | + needs: build |
| 217 | + runs-on: ubuntu-latest |
| 218 | + steps: |
| 219 | + - name: Checkout |
| 220 | + uses: actions/checkout@v4 |
| 221 | + |
| 222 | + - name: Set up Java 17 |
| 223 | + uses: actions/setup-java@v4 |
| 224 | + with: |
| 225 | + distribution: temurin |
| 226 | + java-version: "17" |
| 227 | + cache: gradle |
| 228 | + |
| 229 | + - name: Expose Java 17 to Gradle toolchains |
| 230 | + run: | |
| 231 | + echo "JAVA_HOME=$JAVA_HOME" >> "$GITHUB_ENV" |
| 232 | + echo "ORG_GRADLE_JAVA_INSTALLATIONS_PATHS=$JAVA_HOME" >> "$GITHUB_ENV" |
| 233 | + java -version |
| 234 | + javac -version |
| 235 | +
|
| 236 | + - name: Set up Gradle |
| 237 | + uses: gradle/actions/setup-gradle@v4 |
| 238 | + |
| 239 | + - name: Install Redis |
| 240 | + run: | |
| 241 | + sudo apt-get update |
| 242 | + sudo apt-get install -y redis-server |
| 243 | + redis-cli --version |
| 244 | +
|
| 245 | + - name: Setup Redis Cluster |
| 246 | + run: | |
| 247 | + mkdir 9000 9001 9002 9003 9004 9005 |
| 248 | + printf "port 9000 \ncluster-enabled yes \ncluster-config-file nodes.conf \ncluster-node-timeout 5000 \nappendonly yes" >> 9000/redis.conf |
| 249 | + printf "port 9001 \ncluster-enabled yes \ncluster-config-file nodes.conf \ncluster-node-timeout 5000 \nappendonly yes" >> 9001/redis.conf |
| 250 | + printf "port 9002 \ncluster-enabled yes \ncluster-config-file nodes.conf \ncluster-node-timeout 5000 \nappendonly yes" >> 9002/redis.conf |
| 251 | + printf "port 9003 \ncluster-enabled yes \ncluster-config-file nodes.conf \ncluster-node-timeout 5000 \nappendonly yes" >> 9003/redis.conf |
| 252 | + printf "port 9004 \ncluster-enabled yes \ncluster-config-file nodes.conf \ncluster-node-timeout 5000 \nappendonly yes" >> 9004/redis.conf |
| 253 | + printf "port 9005 \ncluster-enabled yes \ncluster-config-file nodes.conf \ncluster-node-timeout 5000 \nappendonly yes" >> 9005/redis.conf |
| 254 | + (cd 9000 && redis-server ./redis.conf) & |
| 255 | + (cd 9001 && redis-server ./redis.conf) & |
| 256 | + (cd 9002 && redis-server ./redis.conf) & |
| 257 | + (cd 9003 && redis-server ./redis.conf) & |
| 258 | + (cd 9004 && redis-server ./redis.conf) & |
| 259 | + (cd 9005 && redis-server ./redis.conf) & |
| 260 | + sleep 30 |
| 261 | + yes yes | redis-cli --cluster create 127.0.0.1:9000 127.0.0.1:9001 127.0.0.1:9002 127.0.0.1:9003 127.0.0.1:9004 127.0.0.1:9005 --cluster-replicas 1 |
| 262 | +
|
| 263 | + - name: Run Redis cluster tests |
| 264 | + run: ./gradlew test -DincludeTags=redisCluster |
| 265 | + |
| 266 | + - name: Upload JaCoCo exec data |
| 267 | + if: always() |
| 268 | + uses: actions/upload-artifact@v4 |
| 269 | + with: |
| 270 | + name: coverage-redis-cluster |
| 271 | + path: "**/build/reports/jacoco/*.exec" |
| 272 | + if-no-files-found: error |
| 273 | + |
| 274 | + - name: Upload JUnit reports |
| 275 | + if: always() |
| 276 | + uses: actions/upload-artifact@v4 |
| 277 | + with: |
| 278 | + name: redis-cluster-test-results |
| 279 | + path: | |
| 280 | + rqueue-spring-boot-starter/build/reports/junit/xml |
| 281 | + rqueue-spring/build/reports/junit/xml |
| 282 | + rqueue-core/build/reports/junit/xml |
| 283 | + if-no-files-found: ignore |
| 284 | + |
| 285 | + reactive_integration_test: |
| 286 | + needs: build |
| 287 | + runs-on: ubuntu-latest |
| 288 | + env: |
| 289 | + RQUEUE_REACTIVE_ENABLED: "true" |
| 290 | + steps: |
| 291 | + - name: Checkout |
| 292 | + uses: actions/checkout@v4 |
| 293 | + |
| 294 | + - name: Set up Java 17 |
| 295 | + uses: actions/setup-java@v4 |
| 296 | + with: |
| 297 | + distribution: temurin |
| 298 | + java-version: "17" |
| 299 | + cache: gradle |
| 300 | + |
| 301 | + - name: Expose Java 17 to Gradle toolchains |
| 302 | + run: | |
| 303 | + echo "JAVA_HOME=$JAVA_HOME" >> "$GITHUB_ENV" |
| 304 | + echo "ORG_GRADLE_JAVA_INSTALLATIONS_PATHS=$JAVA_HOME" >> "$GITHUB_ENV" |
| 305 | + java -version |
| 306 | + javac -version |
| 307 | +
|
| 308 | + - name: Set up Gradle |
| 309 | + uses: gradle/actions/setup-gradle@v4 |
| 310 | + |
| 311 | + - name: Install Redis |
| 312 | + run: | |
| 313 | + sudo apt-get update |
| 314 | + sudo apt-get install -y redis-server |
| 315 | + redis-cli --version |
| 316 | +
|
| 317 | + - name: Run reactive integration tests |
| 318 | + run: ./gradlew test -DincludeTags=integration -DexcludeTags=redisCluster,producerOnly,local |
| 319 | + |
| 320 | + - name: Upload JaCoCo exec data |
| 321 | + if: always() |
| 322 | + uses: actions/upload-artifact@v4 |
| 323 | + with: |
| 324 | + name: coverage-reactive |
| 325 | + path: "**/build/reports/jacoco/*.exec" |
| 326 | + if-no-files-found: error |
| 327 | + |
| 328 | + - name: Upload JUnit reports |
| 329 | + if: always() |
| 330 | + uses: actions/upload-artifact@v4 |
| 331 | + with: |
| 332 | + name: reactive-integration-test-results |
| 333 | + path: | |
| 334 | + rqueue-spring-boot-starter/build/reports/junit/xml |
| 335 | + rqueue-spring/build/reports/junit/xml |
| 336 | + rqueue-core/build/reports/junit/xml |
| 337 | + if-no-files-found: ignore |
| 338 | + |
| 339 | + coverage_report: |
| 340 | + needs: |
| 341 | + - unit_test |
| 342 | + - producer_only_test |
| 343 | + - integration_test |
| 344 | + - redis_cluster_test |
| 345 | + - reactive_integration_test |
| 346 | + runs-on: ubuntu-latest |
| 347 | + steps: |
| 348 | + - name: Checkout |
| 349 | + uses: actions/checkout@v4 |
| 350 | + |
| 351 | + - name: Set up Java 17 |
| 352 | + uses: actions/setup-java@v4 |
| 353 | + with: |
| 354 | + distribution: temurin |
| 355 | + java-version: "17" |
| 356 | + cache: gradle |
| 357 | + |
| 358 | + - name: Expose Java 17 to Gradle toolchains |
| 359 | + run: | |
| 360 | + echo "JAVA_HOME=$JAVA_HOME" >> "$GITHUB_ENV" |
| 361 | + echo "ORG_GRADLE_JAVA_INSTALLATIONS_PATHS=$JAVA_HOME" >> "$GITHUB_ENV" |
| 362 | + java -version |
| 363 | + javac -version |
| 364 | +
|
| 365 | + - name: Set up Gradle |
| 366 | + uses: gradle/actions/setup-gradle@v4 |
| 367 | + |
| 368 | + - name: Download coverage artifacts |
| 369 | + uses: actions/download-artifact@v4 |
| 370 | + with: |
| 371 | + pattern: coverage-* |
| 372 | + path: coverage-artifacts |
| 373 | + merge-multiple: false |
| 374 | + |
| 375 | + - name: Generate merged coverage report |
| 376 | + run: ./gradlew coverageReportOnly |
| 377 | + |
| 378 | + - name: Upload coverage report |
| 379 | + uses: actions/upload-artifact@v4 |
| 380 | + with: |
| 381 | + name: coverage-report |
| 382 | + path: | |
| 383 | + build/reports/jacoco/test/jacocoTestReport.xml |
| 384 | + build/reports/jacoco/coverageReportOnly/html |
| 385 | + if-no-files-found: ignore |
0 commit comments