Skip to content

Commit 20e78b2

Browse files
committed
将CI/CD改成并行运行
1 parent 713da75 commit 20e78b2

1 file changed

Lines changed: 49 additions & 35 deletions

File tree

.github/workflows/maven.yml

Lines changed: 49 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -127,47 +127,61 @@ jobs:
127127
# Optional: Print initial logs
128128
head -n 20 server.log
129129
130-
- name: Run Java Client Chain
131-
continue-on-error: true
130+
- name: Wait For Service Registration In Nacos
132131
run: |
133132
set -euo pipefail
134-
mkdir -p .ci-status
135-
CLASSPATH="rpc-consumer/target/rpc-consumer-1.0-SNAPSHOT.jar:rpc-transport-netty/target/rpc-transport-netty-1.0-SNAPSHOT.jar:rpc-core/target/rpc-core-1.0-SNAPSHOT.jar:rpc-common/target/rpc-common-1.0-SNAPSHOT.jar:rpc-api/target/rpc-api-1.0-SNAPSHOT.jar:$(mvn -q dependency:build-classpath -Dmdep.outputFile=/dev/stdout -pl rpc-consumer -am)"
136-
137-
echo "Running Java Client (grpc)..."
138-
if java -Drpc.protocol=grpc -Drpc.serializer=protobuf -cp "$CLASSPATH" com.xiaoyu.rpc.consumer.ConsumerApp | tee java-client.log \
139-
&& grep -q "Result1:" java-client.log \
140-
&& grep -q "Result2:" java-client.log; then
141-
echo "PASS" > .ci-status/java.status
142-
else
143-
echo "FAIL" > .ci-status/java.status
144-
fi
133+
echo "Waiting for HelloService registration in Nacos..."
134+
timeout 60s bash -c 'until curl -sf "http://localhost:8848/nacos/v1/ns/instance/list?serviceName=com.xiaoyu.rpc.api.HelloService" | grep -q "\"hosts\":\\[{"; do sleep 1; done'
135+
echo "HelloService is discoverable from Nacos."
145136
146-
- name: Run Python Client Chain
147-
working-directory: python_client
148-
continue-on-error: true
137+
- name: Run Multi-Client Chains In Parallel
149138
run: |
150139
set -euo pipefail
151-
mkdir -p ../.ci-status
152-
echo "Running Python Client..."
153-
if python client.py | tee ../python-client.log && grep -q "Message: Success" ../python-client.log; then
154-
echo "PASS" > ../.ci-status/python.status
155-
else
156-
echo "FAIL" > ../.ci-status/python.status
157-
fi
140+
mkdir -p .ci-status
158141
159-
- name: Run Go Client Chain
160-
working-directory: go_client
161-
continue-on-error: true
162-
run: |
163-
set -euo pipefail
164-
mkdir -p ../.ci-status
165-
echo "Running Go Client..."
166-
if go run main.go | tee ../go-client.log && grep -q "Message: Success" ../go-client.log; then
167-
echo "PASS" > ../.ci-status/go.status
168-
else
169-
echo "FAIL" > ../.ci-status/go.status
170-
fi
142+
CLASSPATH="rpc-consumer/target/rpc-consumer-1.0-SNAPSHOT.jar:rpc-transport-netty/target/rpc-transport-netty-1.0-SNAPSHOT.jar:rpc-core/target/rpc-core-1.0-SNAPSHOT.jar:rpc-common/target/rpc-common-1.0-SNAPSHOT.jar:rpc-api/target/rpc-api-1.0-SNAPSHOT.jar:$(mvn -q dependency:build-classpath -Dmdep.outputFile=/dev/stdout -pl rpc-consumer -am)"
143+
144+
run_java() {
145+
echo "Running Java Client (grpc)..."
146+
if java -Drpc.protocol=grpc -Drpc.serializer=protobuf -cp "$CLASSPATH" com.xiaoyu.rpc.consumer.ConsumerApp | tee java-client.log \
147+
&& grep -q "Result1:" java-client.log \
148+
&& grep -q "Result2:" java-client.log; then
149+
echo "PASS" > .ci-status/java.status
150+
else
151+
echo "FAIL" > .ci-status/java.status
152+
fi
153+
}
154+
155+
run_python() {
156+
echo "Running Python Client..."
157+
if (cd python_client && python client.py) | tee python-client.log \
158+
&& grep -q "Message: Success" python-client.log; then
159+
echo "PASS" > .ci-status/python.status
160+
else
161+
echo "FAIL" > .ci-status/python.status
162+
fi
163+
}
164+
165+
run_go() {
166+
echo "Running Go Client..."
167+
if (cd go_client && go run main.go) | tee go-client.log \
168+
&& grep -q "Message: Success" go-client.log; then
169+
echo "PASS" > .ci-status/go.status
170+
else
171+
echo "FAIL" > .ci-status/go.status
172+
fi
173+
}
174+
175+
run_java &
176+
PID_JAVA=$!
177+
run_python &
178+
PID_PY=$!
179+
run_go &
180+
PID_GO=$!
181+
182+
wait "${PID_JAVA}" || true
183+
wait "${PID_PY}" || true
184+
wait "${PID_GO}" || true
171185
172186
- name: Aggregate Multi-Client Results
173187
run: |

0 commit comments

Comments
 (0)