Repository navigation
fix(docker): 修复重复 Cargo registry 定义并增加容器 CI #2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| .git | ||
| target | ||
| .cargo | ||
| *.log | ||
| *_out.html |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,62 @@ | ||
| name: Docker build and smoke test | ||
|
|
||
| on: | ||
| push: | ||
| branches: | ||
| - main | ||
| - 'fix/docker-*' | ||
| paths: | ||
| - Dockerfile | ||
| - .dockerignore | ||
| - docker-compose.yml | ||
| - Makefile | ||
| - Cargo.toml | ||
| - Cargo.lock | ||
| - src/** | ||
| - scripts/smoke-docker.py | ||
| - .github/workflows/docker.yml | ||
| pull_request: | ||
| paths: | ||
| - Dockerfile | ||
| - .dockerignore | ||
| - docker-compose.yml | ||
| - Makefile | ||
| - Cargo.toml | ||
| - Cargo.lock | ||
| - src/** | ||
| - scripts/smoke-docker.py | ||
| - .github/workflows/docker.yml | ||
| workflow_dispatch: | ||
|
|
||
| permissions: | ||
| contents: read | ||
|
|
||
| concurrency: | ||
| group: docker-${{ github.workflow }}-${{ github.ref }} | ||
| cancel-in-progress: true | ||
|
|
||
| jobs: | ||
| docker: | ||
| runs-on: ubuntu-latest | ||
| timeout-minutes: 30 | ||
| env: | ||
| PORT: '11380' | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
|
|
||
| - name: Validate Compose configuration | ||
| run: docker compose config --quiet | ||
|
|
||
| - name: Build and start the service | ||
| run: make docker-compose-up | ||
|
|
||
| - name: Check HTTP startup and MCP protocol | ||
| run: python3 scripts/smoke-docker.py | ||
|
|
||
| - name: Show container logs | ||
| if: always() | ||
| run: docker compose logs --no-color | ||
|
|
||
| - name: Stop the service | ||
| if: always() | ||
| run: docker compose down | ||
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,3 @@ | ||
| version: '3.8' | ||
|
|
||
| services: | ||
| sosearch: | ||
| build: | ||
|
|
||
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| """Validate the built container without depending on public search engines.""" | ||
|
|
||
| import json | ||
| import os | ||
| import subprocess | ||
| import time | ||
| import urllib.error | ||
| import urllib.request | ||
|
|
||
|
|
||
| port = os.environ.get("PORT", "11380") | ||
| url = f"http://127.0.0.1:{port}/search" | ||
| deadline = time.monotonic() + 30 | ||
| while True: | ||
| try: | ||
| with urllib.request.urlopen(url, timeout=2): | ||
| raise AssertionError("HTTP must reject a missing query") | ||
| except urllib.error.HTTPError as error: | ||
| assert error.code == 400, f"Unexpected HTTP status: {error.code}" | ||
| break | ||
| except (urllib.error.URLError, TimeoutError): | ||
| if time.monotonic() >= deadline: | ||
| raise | ||
| time.sleep(1) | ||
| print("HTTP: service started and rejects missing query with 400") | ||
|
|
||
| requests = [ | ||
| {"jsonrpc": "2.0", "id": 1, "method": "initialize", "params": {}}, | ||
| {"jsonrpc": "2.0", "id": 2, "method": "tools/list"}, | ||
| {"jsonrpc": "2.0", "id": 3, "method": "ping"}, | ||
| ] | ||
| process = subprocess.run( | ||
| ["docker", "compose", "run", "--rm", "--no-deps", "-T", "sosearch", "./SoSearch", "--mcp"], | ||
| input="".join(json.dumps(request) + "\n" for request in requests), | ||
| capture_output=True, | ||
| text=True, | ||
| timeout=30, | ||
| check=True, | ||
| ) | ||
| responses = [json.loads(line) for line in process.stdout.splitlines()] | ||
| assert len(responses) == 3, process.stdout | ||
| assert [response["id"] for response in responses] == [1, 2, 3] | ||
| assert all(response["jsonrpc"] == "2.0" for response in responses) | ||
| assert responses[0]["result"]["serverInfo"]["name"] == "sosearch" | ||
| assert responses[0]["result"]["capabilities"] == {"tools": {}} | ||
| tool = responses[1]["result"]["tools"][0] | ||
| assert tool["name"] == "web_search" | ||
| assert tool["inputSchema"]["required"] == ["query"] | ||
| assert responses[2]["result"] == {} | ||
| print("MCP: initialize, tool discovery and ping passed") |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.