yifan-c commented on code in PR #278:
URL: https://github.com/apache/cassandra-sidecar/pull/278#discussion_r2515976242


##########
.github/workflows/ci.yml:
##########
@@ -0,0 +1,320 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+name: CI
+
+on:
+  pull_request:
+    branches: [trunk]
+  push:
+    branches: [trunk]
+
+# Cancel in-progress runs for PRs when new commits are pushed
+concurrency:
+  group: ${{ github.workflow }}-${{ github.ref }}
+  cancel-in-progress: ${{ github.event_name == 'pull_request' }}
+
+permissions:
+  contents: read
+
+jobs:
+  # Build Cassandra dtest jars once for all test jobs to reuse
+  build-dtest-jars:
+    name: Build dtest jars
+    runs-on: ubuntu-latest
+    permissions:
+      contents: read
+
+    steps:
+      - name: Checkout repository
+        uses: actions/checkout@v5
+
+      - name: Setup Java 11
+        uses: actions/setup-java@v5
+        with:
+          java-version: "11"
+          distribution: "temurin"
+          cache: "gradle"
+
+      - name: Install prerequisites
+        run: |
+          sudo apt-get update
+          sudo apt-get install -y ant
+
+      - name: Setup network aliases for multi-node tests
+        run: |
+          for i in {2..20}; do
+            sudo ip addr add 127.0.0.$i/8 dev lo
+          done
+
+      - name: Cache dtest jars
+        id: cache-dtest-jars
+        uses: actions/cache@v4
+        with:
+          path: dtest-jars/
+          key: dtest-jars-${{ hashFiles('scripts/build-dtest-jars.sh', 
'gradle/wrapper/gradle-wrapper.properties') }}
+
+      - name: Dtest jars cache status
+        run: |
+          if [ "${{ steps.cache-dtest-jars.outputs.cache-hit }}" == "true" ]; 
then
+            echo "✅ Dtest jars restored from cache (saves ~25 minutes)"
+          else
+            echo "⚠️ Cache miss - will build dtest jars (~25 minutes)"
+          fi
+
+      - name: Build dtest jars
+        if: steps.cache-dtest-jars.outputs.cache-hit != 'true'
+        run: |
+          ./scripts/build-dtest-jars.sh
+
+      - name: Upload dtest jars artifact
+        uses: actions/upload-artifact@v5
+        with:
+          name: dtest-jars
+          path: dtest-jars/
+          retention-days: 90
+
+  # Run unit tests with static analysis on all Java versions
+  unit-tests:
+    name: Unit tests (Java ${{ matrix.java }})
+    runs-on: ubuntu-latest
+    needs: build-dtest-jars
+    permissions:
+      contents: read
+      checks: write
+    strategy:
+      fail-fast: false
+      matrix:
+        java: ["11", "17", "21"]
+
+    steps:
+      - name: Checkout repository
+        uses: actions/checkout@v5
+
+      - name: Setup Java ${{ matrix.java }}
+        uses: actions/setup-java@v5
+        with:
+          java-version: ${{ matrix.java }}
+          distribution: "temurin"
+          cache: "gradle"
+
+      - name: Setup Gradle
+        uses: gradle/actions/setup-gradle@v5
+        with:
+          cache-read-only: ${{ github.ref != 'refs/heads/trunk' }}
+
+      - name: Download dtest jars
+        uses: actions/download-artifact@v5
+        with:
+          name: dtest-jars
+          path: dtest-jars/
+
+      - name: Run build with static analysis
+        run: |
+          ./gradlew build -x integrationTest -x checkstyleMain -x 
checkstyleTest -x checkstyleTestFixtures -x javadoc --stacktrace
+        env:
+          CASSANDRA_DEP_DIR: ${{ github.workspace }}/dtest-jars
+
+      - name: Upload test results
+        if: always()
+        uses: actions/upload-artifact@v5
+        with:
+          name: unit-test-results-java-${{ matrix.java }}
+          path: |
+            **/build/test-results/test/*.xml
+            **/build/reports/tests/

Review Comment:
   test reports, `index.html` files are also placed in 
`**/build/test-results/test/`
   
   In build.gradle
   ```
       reports {
           junitXml.setRequired(true)
           def destDir = Paths.get(rootProject.rootDir.absolutePath, "build", 
"test-results", "test").toFile()
           println("Destination directory for unit tests: ${destDir}")
           junitXml.getOutputLocation().set(destDir)
           html.setRequired(true)
           html.getOutputLocation().set(destDir)
       }
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to