# Copyright 2025 Google LLC
#
# Licensed 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
#
#      https://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: Java sample build and test

on:
  push:
    branches:
      - main
    paths:
      - 'a2a_agents/java/**'
  pull_request:
    paths:
      - 'a2a_agents/java/**'

jobs:
  build-and-test:
    name: Build and test Java agent sample
    runs-on: ubuntu-latest

    steps:
      - name: Checkout repository
        uses: actions/checkout@v3

      - name: Set up JDK
        uses: actions/setup-java@v3
        with:
          java-version: '21'
          distribution: 'temurin'

      - name: Build with Maven
        working-directory: a2a_agents/java
        run: mvn clean install

      - name: Run Tests
        working-directory: a2a_agents/java
        run: mvn test
