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