Merge pull request #38 from kabir/bump-next-version #138
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Build and Run Tests | |
| on: | |
| push: | |
| branches: | |
| - main | |
| pull_request: | |
| branches: | |
| - main | |
| workflow_dispatch: | |
| # Only run the latest job | |
| concurrency: | |
| group: '${{ github.workflow }} @ ${{ github.head_ref || github.ref }}' | |
| cancel-in-progress: true | |
| jobs: | |
| build-and-test: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout sources | |
| uses: actions/checkout@v4 | |
| - name: Check if SDK version is SNAPSHOT | |
| run: | | |
| SDK_VERSION=$(mvn help:evaluate -Dexpression=version.sdk -q -DforceStdout) | |
| echo "SDK_VERSION=${SDK_VERSION}" >> "$GITHUB_ENV" | |
| if [[ "${SDK_VERSION}" == *"-SNAPSHOT" ]]; then | |
| echo "IS_SNAPSHOT=true" >> "$GITHUB_ENV" | |
| else | |
| echo "IS_SNAPSHOT=false" >> "$GITHUB_ENV" | |
| fi | |
| - name: Checkout a2a-java | |
| if: env.IS_SNAPSHOT == 'true' | |
| uses: actions/checkout@v4 | |
| with: | |
| repository: a2aproject/a2a-java | |
| path: a2a-java | |
| - name: Set up JDK 17 | |
| uses: actions/setup-java@v4 | |
| with: | |
| java-version: '17' | |
| distribution: 'temurin' | |
| cache: maven | |
| - name: Build a2a-java with Maven, skipping tests | |
| if: env.IS_SNAPSHOT == 'true' | |
| run: | | |
| mvn -B install -DskipTests | |
| working-directory: a2a-java | |
| - name: Get a2a-java version and save as env var | |
| if: env.IS_SNAPSHOT == 'true' | |
| run: | | |
| VERSION=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout) | |
| echo "SDK_VERSION=${VERSION}" >> "$GITHUB_ENV" | |
| working-directory: a2a-java | |
| - name: Run tests | |
| run: | |
| mvn clean install -B -Dversion.sdk=${SDK_VERSION} | |
| - name: Test JSON-RPC simple example | |
| run: | | |
| # Build the server with jsonrpc | |
| mvn -B clean package -pl examples/simple/server -Pjsonrpc -Dversion.sdk=${SDK_VERSION} | |
| # Start server and wait | |
| mvn -B wildfly:start -pl examples/simple/server -Dstartup-timeout=120 | |
| # Run the client and capture output | |
| CLIENT_OUTPUT=$(mvn -B exec:java -pl examples/simple/client -Prun-jsonrpc -Duser.name="CI Run" -q 2>&1) | |
| # Stop server | |
| mvn -B wildfly:shutdown -pl examples/simple/server | |
| # Validate output | |
| EXPECTED="Agent responds: Hello CI Run" | |
| if [[ "$CLIENT_OUTPUT" == *"$EXPECTED"* ]]; then | |
| echo "✅ JSON-RPC example test passed" | |
| echo "Output: $CLIENT_OUTPUT" | |
| else | |
| echo "❌ JSON-RPC example test failed" | |
| echo "Expected: $EXPECTED" | |
| echo "Actual: $CLIENT_OUTPUT" | |
| exit 1 | |
| fi | |
| - name: Test gRPC simple example | |
| run: | | |
| # Build the server with grpc | |
| mvn -B clean package -pl examples/simple/server -Pgrpc -Dversion.sdk=${SDK_VERSION} | |
| # Start server and wait (we need the preview stability level since the gRPC subsystem is at that level) | |
| mvn -B wildfly:start -pl examples/simple/server -Dstartup-timeout=120 -Dwildfly.serverArgs="--stability=preview" | |
| # Run the client and capture output | |
| CLIENT_OUTPUT=$(mvn -B exec:java -pl examples/simple/client -Prun-grpc -Duser.name="CI Run" -q 2>&1) | |
| # Stop server | |
| mvn -B wildfly:shutdown -pl examples/simple/server | |
| # Validate output | |
| EXPECTED="Agent responds: Hello CI Run" | |
| if [[ "$CLIENT_OUTPUT" == *"$EXPECTED"* ]]; then | |
| echo "✅ gRPC example test passed" | |
| echo "Output: $CLIENT_OUTPUT" | |
| else | |
| echo "❌ gRPC example test failed" | |
| echo "Expected: $EXPECTED" | |
| echo "Actual: $CLIENT_OUTPUT" | |
| exit 1 | |
| fi | |
| - name: Test HTTP+JSON/REST simple example | |
| run: | | |
| # Build the server with rest | |
| mvn -B clean package -pl examples/simple/server -Prest -Dversion.sdk=${SDK_VERSION} | |
| # Start server and wait | |
| mvn -B wildfly:start -pl examples/simple/server -Dstartup-timeout=120 | |
| # Run the client and capture output | |
| CLIENT_OUTPUT=$(mvn -B exec:java -pl examples/simple/client -Prun-rest -Duser.name="CI Run" -q 2>&1) | |
| # Stop server | |
| mvn -B wildfly:shutdown -pl examples/simple/server | |
| # Validate output | |
| EXPECTED="Agent responds: Hello CI Run" | |
| if [[ "$CLIENT_OUTPUT" == *"$EXPECTED"* ]]; then | |
| echo "✅ HTTP+JSON/REST example test passed" | |
| echo "Output: $CLIENT_OUTPUT" | |
| else | |
| echo "❌ HTTP+JSON/REST example test failed" | |
| echo "Expected: $EXPECTED" | |
| echo "Actual: $CLIENT_OUTPUT" | |
| exit 1 | |
| fi | |
| - name: Upload WildFly logs on test failure | |
| if: failure() | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: wildfly-logs | |
| path: | | |
| tests/jsonrpc/target/wildfly/standalone/log/server.log | |
| tests/grpc/target/wildfly/standalone/log/server.log | |
| if-no-files-found: ignore | |
| retention-days: 5 |