|
| 1 | +name: "aimock" |
| 2 | +description: "Start an aimock server for AI application testing — LLM APIs, MCP, A2A, AG-UI, vector DBs" |
| 3 | +branding: |
| 4 | + icon: "server" |
| 5 | + color: "green" |
| 6 | + |
| 7 | +inputs: |
| 8 | + fixtures: |
| 9 | + description: "Path to fixture files or directory" |
| 10 | + required: false |
| 11 | + default: "./fixtures" |
| 12 | + config: |
| 13 | + description: "Path to aimock JSON config file (overrides fixtures)" |
| 14 | + required: false |
| 15 | + port: |
| 16 | + description: "Port to listen on" |
| 17 | + required: false |
| 18 | + default: "4010" |
| 19 | + host: |
| 20 | + description: "Host to bind to" |
| 21 | + required: false |
| 22 | + default: "127.0.0.1" |
| 23 | + version: |
| 24 | + description: "aimock version to install (default: latest)" |
| 25 | + required: false |
| 26 | + default: "latest" |
| 27 | + args: |
| 28 | + description: "Additional CLI arguments (e.g., --strict --record --provider-openai https://api.openai.com)" |
| 29 | + required: false |
| 30 | + default: "" |
| 31 | + wait-timeout: |
| 32 | + description: "Max seconds to wait for health check (default: 30)" |
| 33 | + required: false |
| 34 | + default: "30" |
| 35 | + |
| 36 | +outputs: |
| 37 | + url: |
| 38 | + description: "The aimock server URL (e.g., http://127.0.0.1:4010)" |
| 39 | + value: ${{ steps.start.outputs.url }} |
| 40 | + |
| 41 | +runs: |
| 42 | + using: "composite" |
| 43 | + steps: |
| 44 | + - name: Install aimock |
| 45 | + shell: bash |
| 46 | + run: npm install -g @copilotkit/aimock@${{ inputs.version }} |
| 47 | + |
| 48 | + - name: Start aimock |
| 49 | + id: start |
| 50 | + shell: bash |
| 51 | + run: | |
| 52 | + URL="http://${{ inputs.host }}:${{ inputs.port }}" |
| 53 | + echo "url=${URL}" >> $GITHUB_OUTPUT |
| 54 | +
|
| 55 | + if [ -n "${{ inputs.config }}" ]; then |
| 56 | + aimock --config "${{ inputs.config }}" \ |
| 57 | + --port ${{ inputs.port }} \ |
| 58 | + --host ${{ inputs.host }} \ |
| 59 | + ${{ inputs.args }} & |
| 60 | + else |
| 61 | + llmock --fixtures "${{ inputs.fixtures }}" \ |
| 62 | + --port ${{ inputs.port }} \ |
| 63 | + --host ${{ inputs.host }} \ |
| 64 | + ${{ inputs.args }} & |
| 65 | + fi |
| 66 | +
|
| 67 | + echo $! > /tmp/aimock.pid |
| 68 | + echo "Started aimock (PID: $(cat /tmp/aimock.pid))" |
| 69 | +
|
| 70 | + - name: Wait for health check |
| 71 | + shell: bash |
| 72 | + run: | |
| 73 | + URL="http://${{ inputs.host }}:${{ inputs.port }}/health" |
| 74 | + TIMEOUT=${{ inputs.wait-timeout }} |
| 75 | + ELAPSED=0 |
| 76 | +
|
| 77 | + echo "Waiting for ${URL} ..." |
| 78 | + while [ $ELAPSED -lt $TIMEOUT ]; do |
| 79 | + if curl -sf "$URL" > /dev/null 2>&1; then |
| 80 | + echo "aimock is ready at http://${{ inputs.host }}:${{ inputs.port }}" |
| 81 | + exit 0 |
| 82 | + fi |
| 83 | + sleep 1 |
| 84 | + ELAPSED=$((ELAPSED + 1)) |
| 85 | + done |
| 86 | +
|
| 87 | + echo "::error::aimock failed to start within ${TIMEOUT}s" |
| 88 | + if [ -f /tmp/aimock.pid ]; then |
| 89 | + kill "$(cat /tmp/aimock.pid)" 2>/dev/null || true |
| 90 | + fi |
| 91 | + exit 1 |
0 commit comments