| # 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: Check and Test |
| |
| on: |
| workflow_call: |
| inputs: |
| gradle-cache-read-only: |
| description: "Should the Gradle cache be read-only?" |
| default: "true" |
| type: string |
| github-actions-opt-in: |
| description: "Should we run the opt-in steps?" |
| default: "false" |
| type: string |
| |
| jobs: |
| validate: |
| runs-on: ubuntu-latest |
| strategy: |
| fail-fast: false |
| matrix: |
| java: [ 21, 17, 11, 8 ] |
| name: Compile and Check Java ${{ matrix.java }} |
| steps: |
| - name: Env |
| run: printenv |
| env: |
| GITHUB_CONTEXT: ${{ toJson(github) }} |
| - name: Checkout code |
| uses: actions/checkout@v4 |
| with: |
| persist-credentials: false |
| - uses: actions/setup-python@v5 |
| with: |
| python-version: '3.12' |
| - name: Setup Gradle |
| uses: ./.github/actions/setup-gradle |
| with: |
| java-version: ${{ matrix.java }} |
| gradle-cache-read-only: ${{ inputs.gradle-cache-read-only }} |
| develocity-access-key: ${{ secrets.GE_ACCESS_TOKEN }} |
| - name: Compile and validate |
| # Gradle flags |
| # --build-cache: Let Gradle restore the build cache |
| # --info: For now, we'll generate lots of logs while setting up the GH Actions |
| # --scan: Attempt to publish build scans in PRs. This will only work on PRs from apache/kafka, not public forks. |
| run: ./gradlew --build-cache --info --scan check -x test |
| - name: Archive check reports |
| if: always() |
| uses: actions/upload-artifact@v4 |
| with: |
| name: check-reports-${{ matrix.java }} |
| path: | |
| **/build/**/*.html |
| if-no-files-found: ignore |
| - name: Annotate checkstyle errors |
| # Avoid duplicate annotations, only run on java 21 |
| # For now, limit to "gh-" PRs |
| if: ${{ inputs.github-actions-opt-in && failure() && matrix.java == '21' }} |
| run: python .github/scripts/checkstyle.py |
| env: |
| GITHUB_WORKSPACE: ${{ github.workspace }} |
| |
| test: |
| needs: validate |
| runs-on: ubuntu-latest |
| strategy: |
| fail-fast: false |
| matrix: |
| java: [ 17, 11 ] |
| if: ${{ inputs.github-actions-opt-in }} |
| name: JUnit tests Java ${{ matrix.java }} |
| steps: |
| - name: Checkout code |
| uses: actions/checkout@v4 |
| with: |
| persist-credentials: false |
| - name: Setup Gradle |
| uses: ./.github/actions/setup-gradle |
| with: |
| java-version: ${{ matrix.java }} |
| gradle-cache-read-only: ${{ inputs.gradle-cache-read-only }} |
| develocity-access-key: ${{ secrets.GE_ACCESS_TOKEN }} |
| - name: Test |
| # Gradle flags |
| # --build-cache: Let Gradle restore the build cache |
| # --scan: Attempt to publish build scans in PRs. This will only work on PRs from apache/kafka, not public forks. |
| # --continue: Keep running even if a test fails |
| timeout-minutes: 180 # 3 hours |
| run: | |
| ./gradlew --build-cache --scan --continue \ |
| -PtestLoggingEvents=started,passed,skipped,failed \ |
| -PignoreFailures=true -PmaxParallelForks=2 \ |
| -PmaxTestRetries=1 -PmaxTestRetryFailures=10 \ |
| test |
| - name: Archive JUnit reports |
| if: always() |
| uses: actions/upload-artifact@v4 |
| id: junit-upload-artifact |
| with: |
| name: junit-reports-${{ matrix.java }} |
| path: | |
| **/build/reports/tests/test/* |
| if-no-files-found: ignore |
| - name: Parse JUnit tests |
| if: always() |
| run: python .github/scripts/junit.py >> $GITHUB_STEP_SUMMARY |
| env: |
| GITHUB_WORKSPACE: ${{ github.workspace }} |
| REPORT_URL: ${{ steps.junit-upload-artifact.outputs.artifact-url }} |