|
| 1 | +name: Java CI with Maven, Nacos, and Python |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [ "main" ] |
| 6 | + pull_request: |
| 7 | + branches: [ "main" ] |
| 8 | + |
| 9 | +jobs: |
| 10 | + integration-test: |
| 11 | + runs-on: ubuntu-latest |
| 12 | + |
| 13 | + services: |
| 14 | + nacos: |
| 15 | + image: nacos/nacos-server:v2.2.3 |
| 16 | + env: |
| 17 | + MODE: standalone |
| 18 | + AUTH_ENABLE: false |
| 19 | + ports: |
| 20 | + - 8848:8848 |
| 21 | + # Wait for Nacos to be fully ready |
| 22 | + options: >- |
| 23 | + --name nacos-server |
| 24 | + --health-cmd "curl -f http://localhost:8848/nacos/v1/console/health/readiness" |
| 25 | + --health-interval 10s |
| 26 | + --health-timeout 5s |
| 27 | + --health-retries 10 |
| 28 | +
|
| 29 | + steps: |
| 30 | + - uses: actions/checkout@v4 |
| 31 | + |
| 32 | + - name: Set up JDK 17 |
| 33 | + uses: actions/setup-java@v4 |
| 34 | + with: |
| 35 | + java-version: '17' |
| 36 | + distribution: 'temurin' |
| 37 | + cache: maven |
| 38 | + |
| 39 | + - name: Set up Python |
| 40 | + uses: actions/setup-python@v4 |
| 41 | + with: |
| 42 | + python-version: '3.x' |
| 43 | + cache: 'pip' |
| 44 | + |
| 45 | + - name: Install Python Dependencies |
| 46 | + run: | |
| 47 | + python -m pip install --upgrade pip |
| 48 | + pip install grpcio grpcio-tools protobuf |
| 49 | +
|
| 50 | + - name: Build with Maven |
| 51 | + run: mvn clean install -DskipTests |
| 52 | + |
| 53 | + - name: Start RPC Provider (Java Server) |
| 54 | + run: | |
| 55 | + # Build classpath including project jars and dependencies |
| 56 | + CLASSPATH="rpc-provider/target/rpc-provider-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-provider -am)" |
| 57 | + |
| 58 | + echo "Starting Java Server..." |
| 59 | + # Run in background with nohup |
| 60 | + nohup java -cp "$CLASSPATH" com.xiaoyu.rpc.provider.ProviderApp > server.log 2>&1 & |
| 61 | + |
| 62 | + # Wait for server port 8080 to be available |
| 63 | + echo "Waiting for Java Server to start on port 8080..." |
| 64 | + timeout 60s bash -c 'until echo > /dev/tcp/localhost/8080; do sleep 1; done' |
| 65 | + |
| 66 | + echo "Java Server is running!" |
| 67 | + # Optional: Print initial logs |
| 68 | + head -n 20 server.log |
| 69 | +
|
| 70 | + - name: Run Python Client |
| 71 | + working-directory: python_client |
| 72 | + run: | |
| 73 | + echo "Running Python Client..." |
| 74 | + python client.py |
0 commit comments