-
-
Notifications
You must be signed in to change notification settings - Fork 4
147 lines (131 loc) · 5.25 KB
/
build-and-test.yml
File metadata and controls
147 lines (131 loc) · 5.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
name: Build and Run Tests
on:
push:
branches:
- main
pull_request:
branches:
- main
schedule:
- cron: '00 6 * * *'
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: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'
cache: maven
- name: Check if SDK version is SNAPSHOT
run: |
SDK_VERSION=$(grep -oP '<version\.sdk>\K[^<]+' pom.xml)
echo "Detected SDK_VERSION: ${SDK_VERSION}"
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: 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 2>&1 | grep -v '\[')
echo "Detected a2a-java version: ${VERSION}"
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