diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ecb0a55b4..6667bfea4 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -98,6 +98,50 @@ jobs: path: cassandra-tarballs/ retention-days: 30 + # Run checkstyle checks for code style validation + checkstyle: + name: Checkstyle + runs-on: ubuntu-latest + needs: build-dtest-jars + 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: 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 checkstyle + run: | + ./gradlew checkstyle --stacktrace + env: + CASSANDRA_DEP_DIR: ${{ github.workspace }}/dtest-jars + + - name: Upload checkstyle reports + if: always() + uses: actions/upload-artifact@v5 + with: + name: checkstyle-reports + path: "**/build/reports/checkstyle/" + retention-days: 30 + # Run unit tests with static analysis on all Java versions unit-tests: name: Unit tests (Java ${{ matrix.java }}) @@ -347,3 +391,187 @@ jobs: **/build/test-results/integrationTest*/** **/build/reports/tests/integrationTest*/ retention-days: 30 + + # Run Java 8 client unit tests for client compatibility + unit-tests-java8: + name: Unit tests (Java 8 - Client only) + runs-on: ubuntu-latest + permissions: + contents: read + checks: write + + steps: + - name: Checkout repository + uses: actions/checkout@v5 + + - name: Setup Java 8 + uses: actions/setup-java@v5 + with: + java-version: "8" + distribution: "temurin" + cache: "gradle" + + - name: Setup Gradle + uses: gradle/actions/setup-gradle@v5 + with: + cache-read-only: ${{ github.ref != 'refs/heads/trunk' }} + + - name: Run build + run: | + ./gradlew build --stacktrace + + - name: Upload test results + if: always() + uses: actions/upload-artifact@v5 + with: + name: unit-test-results-java-8 + path: | + **/build/test-results/test/** + **/build/reports/tests/ + retention-days: 30 + + # Build and verify Debian package + deb-build-install: + name: Deb package build and install + runs-on: ubuntu-latest + needs: [unit-tests, checkstyle] + 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: Setup Gradle + uses: gradle/actions/setup-gradle@v5 + with: + cache-read-only: ${{ github.ref != 'refs/heads/trunk' }} + + - name: Build Debian package + run: | + ./gradlew --info clean buildDeb + + - name: Install Debian package + run: | + sudo apt-get update && sudo apt --fix-broken install + DEBIAN_FRONTEND=noninteractive sudo apt install -y ./build/distributions/apache-cassandra-sidecar*.deb + + - name: Verify installation + run: | + test -f /opt/apache-cassandra-sidecar/bin/cassandra-sidecar + test -f /opt/apache-cassandra-sidecar/conf/sidecar.yaml + test -f /opt/apache-cassandra-sidecar/conf/logback.xml + test -f /opt/apache-cassandra-sidecar/LICENSE.txt + test -f /opt/apache-cassandra-sidecar/lib/cassandra-sidecar-*.jar + + # Build and verify RPM package + rpm-build-install: + name: RPM package build and install + runs-on: ubuntu-latest + needs: [unit-tests, checkstyle] + 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: Setup Gradle + uses: gradle/actions/setup-gradle@v5 + with: + cache-read-only: ${{ github.ref != 'refs/heads/trunk' }} + + - name: Install dnf + run: | + sudo apt-get update && sudo apt-get install -y dnf + + - name: Build RPM package + run: | + ./gradlew -i buildRpm + + - name: Install RPM package + run: | + sudo dnf install -y ./build/distributions/apache-cassandra-sidecar*.rpm + + - name: Verify installation + run: | + test -f /opt/apache-cassandra-sidecar/bin/cassandra-sidecar + test -f /opt/apache-cassandra-sidecar/conf/sidecar.yaml + test -f /opt/apache-cassandra-sidecar/conf/logback.xml + test -f /opt/apache-cassandra-sidecar/LICENSE.txt + test -f /opt/apache-cassandra-sidecar/lib/cassandra-sidecar-*.jar + + # Build Docker image + docker-build: + name: Docker build + runs-on: ubuntu-latest + needs: [unit-tests, checkstyle] + 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: Setup Gradle + uses: gradle/actions/setup-gradle@v5 + with: + cache-read-only: ${{ github.ref != 'refs/heads/trunk' }} + + - name: Build Docker image with Jib + run: | + ./gradlew --info clean :server:jibDockerBuild + + # Build documentation + docs-build: + name: Documentation build + runs-on: ubuntu-latest + needs: [unit-tests, checkstyle] + 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: Setup Gradle + uses: gradle/actions/setup-gradle@v5 + with: + cache-read-only: ${{ github.ref != 'refs/heads/trunk' }} + + - name: Build documentation + run: | + ./gradlew docs:asciidoctor + + - name: Verify documentation + run: | + test -f docs/build/user.html + test -f docs/build/development.html diff --git a/build.gradle b/build.gradle index 8943007c6..372869eb3 100644 --- a/build.gradle +++ b/build.gradle @@ -111,6 +111,12 @@ ext { // Force checkstyle, rat, and spotBugs to run before test tasks for faster feedback def codeCheckTasks = task("codeCheckTasks") +tasks.register('checkstyle') { + description = 'Runs all checkstyle tasks' + group = 'verification' + dependsOn(allprojects.collect { it.tasks.withType(Checkstyle) }) +} + allprojects { apply plugin: 'jacoco' apply plugin: 'checkstyle'