|
| 1 | +name: Build Samples |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + pull_request: |
| 6 | + branches: [ main ] |
| 7 | + paths: |
| 8 | + - 'samples/**' |
| 9 | + push: |
| 10 | + branches: [ main ] |
| 11 | +# paths: |
| 12 | +# - 'samples/**' |
| 13 | + |
| 14 | +concurrency: |
| 15 | + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} |
| 16 | + # Cancel only when the run is NOT on `main` branch |
| 17 | + cancel-in-progress: ${{ github.ref != 'refs/heads/main' }} |
| 18 | + |
| 19 | +jobs: |
| 20 | + build: |
| 21 | + runs-on: ubuntu-latest |
| 22 | + strategy: |
| 23 | + matrix: |
| 24 | + sample: |
| 25 | + - kotlin-mcp-client |
| 26 | + - kotlin-mcp-server |
| 27 | + - weather-stdio-server |
| 28 | + |
| 29 | + name: Validate PR |
| 30 | + timeout-minutes: 10 |
| 31 | + env: |
| 32 | + JAVA_OPTS: "-Xmx8g -Dfile.encoding=UTF-8 -Djava.awt.headless=true -Dkotlin.daemon.jvm.options=-Xmx6g" |
| 33 | + steps: |
| 34 | + - uses: actions/checkout@v5 |
| 35 | + |
| 36 | + - name: Set up JDK 21 |
| 37 | + uses: actions/setup-java@v5 |
| 38 | + with: |
| 39 | + java-version: 21 |
| 40 | + distribution: 'temurin' |
| 41 | + |
| 42 | + - name: Setup Gradle |
| 43 | + uses: gradle/actions/setup-gradle@v5 |
| 44 | + with: |
| 45 | + add-job-summary: 'always' |
| 46 | + cache-read-only: true |
| 47 | + |
| 48 | + - name: Build with Gradle |
| 49 | + working-directory: matrix.sample |
| 50 | + run: |- |
| 51 | + ./../../gradlew --no-daemon --rerun-tasks \ |
| 52 | + clean \ |
| 53 | + ktlintCheck \ |
| 54 | + build \ |
| 55 | + koverLog koverHtmlReport \ |
| 56 | + publishToMavenLocal |
| 57 | +
|
| 58 | + - name: "Build Sample: ${{ matrix.sample }}" |
| 59 | + working-directory: ./samples/${{ matrix.sample }} |
| 60 | + run: ./../../gradlew --no-daemon --rerun-tasks clean build |
| 61 | + |
| 62 | + - name: Upload Reports |
| 63 | + if: ${{ !cancelled() }} |
| 64 | + uses: actions/upload-artifact@v4 |
| 65 | + with: |
| 66 | + name: reports |
| 67 | + path: | |
| 68 | + **/build/reports/ |
| 69 | +
|
| 70 | + - name: Disable Auto-Merge on Fail |
| 71 | + if: failure() && github.event_name == 'pull_request' |
| 72 | + run: gh pr merge --disable-auto "$PR_URL" |
| 73 | + env: |
| 74 | + PR_URL: ${{github.event.pull_request.html_url}} |
| 75 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 76 | + |
| 77 | + report: |
| 78 | + runs-on: ubuntu-latest |
| 79 | + steps: |
| 80 | + - name: Publish Test Report |
| 81 | + uses: mikepenz/action-junit-report@v5 |
| 82 | + if: ${{ !cancelled() }} # always run even if the previous step fails |
| 83 | + with: |
| 84 | + report_paths: '**/test-results/**/TEST-*.xml' |
| 85 | + detailed_summary: true |
| 86 | + flaky_summary: true |
| 87 | + include_empty_in_summary: false |
| 88 | + include_time_in_summary: true |
| 89 | + annotate_only: true |
0 commit comments