-
Notifications
You must be signed in to change notification settings - Fork 25
Add LICENSE, Dockerfile, E2E tests, and CI/CD for Glama MCP directory compatibility #3
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
Closed
Closed
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
43cd7ff
Initial plan
Copilot cc97757
Add LICENSE and Dockerfile for Glama compatibility
Copilot e26647a
Update LICENSE copyright to SerpApi
Copilot 3892965
Add comprehensive e2e tests for Docker container
Copilot 634433e
Add GitHub Actions workflow for CI/CD with e2e tests
Copilot 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,41 @@ | ||
| # Git files | ||
| .git | ||
| .gitignore | ||
|
|
||
| # Python | ||
| __pycache__ | ||
| *.py[cod] | ||
| *$py.class | ||
| *.so | ||
| .Python | ||
| *.egg-info | ||
| dist | ||
| build | ||
| *.egg | ||
|
|
||
| # Virtual environments | ||
| .env | ||
| .venv | ||
| env/ | ||
| venv/ | ||
| ENV/ | ||
| env.bak/ | ||
| venv.bak/ | ||
|
|
||
| # IDE | ||
| .vscode/ | ||
| .idea/ | ||
| *.swp | ||
| *.swo | ||
| *~ | ||
|
|
||
| # OS | ||
| .DS_Store | ||
| Thumbs.db | ||
|
|
||
| # Other | ||
| scratch/ | ||
| README.md | ||
| .python-version | ||
| uv.lock | ||
| smithery.yaml |
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,54 @@ | ||
| # GitHub Actions Workflows | ||
|
|
||
| This directory contains GitHub Actions workflows for continuous integration and deployment. | ||
|
|
||
| ## Workflows | ||
|
|
||
| ### Python Package CI (`python-package.yml`) | ||
|
|
||
| Runs on every push to `main` and on all pull requests. | ||
|
|
||
| #### Jobs | ||
|
|
||
| 1. **test** - Runs the e2e test suite | ||
| - Sets up Python 3.13 | ||
| - Installs dependencies including pytest | ||
| - Configures Docker Buildx for optimal caching | ||
| - Runs the comprehensive e2e test suite (`tests/test_e2e_docker.py`) | ||
| - Tests Docker container build, startup, and functionality | ||
|
|
||
| 2. **lint** - Code quality checks | ||
| - Sets up Python 3.13 | ||
| - Installs Ruff linter | ||
| - Runs linting checks on the codebase | ||
| - Continues on error to not block the build | ||
|
|
||
| 3. **docker-build** - Docker image validation | ||
| - Sets up Docker Buildx with GitHub Actions caching | ||
| - Builds the Docker image | ||
| - Tests basic container functionality | ||
| - Validates API key requirement | ||
| - Confirms container starts successfully | ||
|
|
||
| #### Best Practices Implemented | ||
|
|
||
| - ✅ **Matrix strategy**: Easy to add multiple Python versions if needed | ||
| - ✅ **Dependency caching**: Speeds up workflow runs using pip cache | ||
| - ✅ **Docker layer caching**: Uses GitHub Actions cache for Docker builds | ||
| - ✅ **Parallel jobs**: Test, lint, and docker-build run in parallel | ||
| - ✅ **Latest actions**: Uses latest versions of GitHub Actions (v4, v5) | ||
| - ✅ **Clear job names**: Easy to understand what each job does | ||
| - ✅ **Fail-fast disabled**: All test scenarios run even if one fails | ||
| - ✅ **Continue on error for lint**: Linting doesn't block the build | ||
|
|
||
| ## Monitoring | ||
|
|
||
| Check the [Actions tab](https://github.com/ilyazub/serpapi-mcp-server/actions) in the repository to monitor workflow runs and review results. | ||
|
|
||
| ## Badge | ||
|
|
||
| The build status badge in the README shows the current status of the `python-package.yml` workflow: | ||
|
|
||
| ```markdown | ||
| [](https://github.com/ilyazub/serpapi-mcp-server/actions/workflows/python-package.yml) | ||
| ``` |
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,90 @@ | ||
| name: Python Package CI | ||
|
|
||
| on: | ||
| push: | ||
| branches: [ main ] | ||
| pull_request: | ||
| branches: [ main ] | ||
|
|
||
| jobs: | ||
| test: | ||
| runs-on: ubuntu-latest | ||
| strategy: | ||
| matrix: | ||
| python-version: ["3.13"] | ||
| fail-fast: false | ||
|
|
||
| steps: | ||
| - name: Checkout code | ||
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Set up Python ${{ matrix.python-version }} | ||
| uses: actions/setup-python@v5 | ||
| with: | ||
| python-version: ${{ matrix.python-version }} | ||
| cache: 'pip' | ||
|
|
||
| - name: Install dependencies | ||
| run: | | ||
| python -m pip install --upgrade pip | ||
| pip install pytest | ||
| if [ -f pyproject.toml ]; then | ||
| pip install -e .[test] || true | ||
| fi | ||
|
|
||
| - name: Set up Docker Buildx | ||
| uses: docker/setup-buildx-action@v3 | ||
|
|
||
| - name: Run e2e tests | ||
| run: | | ||
| pytest tests/test_e2e_docker.py -v --tb=short | ||
|
|
||
| lint: | ||
| runs-on: ubuntu-latest | ||
|
|
||
| steps: | ||
| - name: Checkout code | ||
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Set up Python | ||
| uses: actions/setup-python@v5 | ||
| with: | ||
| python-version: "3.13" | ||
| cache: 'pip' | ||
|
|
||
| - name: Install linting tools | ||
| run: | | ||
| python -m pip install --upgrade pip | ||
| pip install ruff | ||
|
|
||
| - name: Run Ruff linter | ||
| run: | | ||
| ruff check . --output-format=github | ||
| continue-on-error: true | ||
|
|
||
| docker-build: | ||
| runs-on: ubuntu-latest | ||
|
|
||
| steps: | ||
| - name: Checkout code | ||
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Set up Docker Buildx | ||
| uses: docker/setup-buildx-action@v3 | ||
|
|
||
| - name: Build Docker image | ||
| uses: docker/build-push-action@v5 | ||
| with: | ||
| context: . | ||
| push: false | ||
| tags: serpapi-mcp-server:test | ||
| cache-from: type=gha | ||
| cache-to: type=gha,mode=max | ||
|
|
||
| - name: Test Docker image | ||
| run: | | ||
| # Test that container fails without API key | ||
| docker run --rm serpapi-mcp-server:test 2>&1 | grep -q "SERPAPI_API_KEY" && echo "✓ API key validation works" || exit 1 | ||
|
|
||
| # Test that container starts with API key | ||
| timeout 3 docker run --rm -e SERPAPI_API_KEY=test_key serpapi-mcp-server:test || [ $? -eq 124 ] && echo "✓ Container starts successfully" |
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,21 @@ | ||
| # Use Python 3.13 slim image for smaller size | ||
| FROM python:3.13-slim | ||
|
|
||
| # Set working directory | ||
| WORKDIR /app | ||
|
|
||
| # Copy project files | ||
| COPY pyproject.toml ./ | ||
| COPY src/ ./src/ | ||
|
|
||
| # Install dependencies | ||
| RUN pip install --no-cache-dir google-search-results>=2.4.2 "mcp[cli]>=1.3.0" python-dotenv httpx | ||
|
|
||
| # Set environment variables | ||
| ENV PYTHONUNBUFFERED=1 | ||
|
|
||
| # Expose the MCP server (stdio mode doesn't need ports, but keeping for future HTTP mode) | ||
| # No EXPOSE needed for stdio mode | ||
|
|
||
| # Run the server | ||
| CMD ["python", "-m", "src.serpapi-mcp-server.server"] | ||
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,21 @@ | ||
| MIT License | ||
|
|
||
| Copyright (c) 2025 SerpApi | ||
|
|
||
| Permission is hereby granted, free of charge, to any person obtaining a copy | ||
| of this software and associated documentation files (the "Software"), to deal | ||
| in the Software without restriction, including without limitation the rights | ||
| to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
| copies of the Software, and to permit persons to whom the Software is | ||
| furnished to do so, subject to the following conditions: | ||
|
|
||
| The above copyright notice and this permission notice shall be included in all | ||
| copies or substantial portions of the Software. | ||
|
|
||
| THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
| IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
| FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
| AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
| LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
| OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
| SOFTWARE. |
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 |
|---|---|---|
| @@ -0,0 +1,54 @@ | ||
| # End-to-End Tests | ||
|
|
||
| This directory contains end-to-end tests for the SerpApi MCP Server. | ||
|
|
||
| ## Running Tests | ||
|
|
||
| ### Prerequisites | ||
|
|
||
| Install test dependencies: | ||
|
|
||
| ```bash | ||
| pip install pytest | ||
| ``` | ||
|
|
||
| ### Run All Tests | ||
|
|
||
| ```bash | ||
| pytest tests/ -v | ||
| ``` | ||
|
|
||
| ### Run Specific Test File | ||
|
|
||
| ```bash | ||
| pytest tests/test_e2e_docker.py -v | ||
| ``` | ||
|
|
||
| ## Test Coverage | ||
|
|
||
| ### Docker E2E Tests (`test_e2e_docker.py`) | ||
|
|
||
| Tests the Docker container functionality: | ||
|
|
||
| - **test_docker_image_exists**: Verifies the Docker image builds successfully | ||
| - **test_container_requires_api_key**: Ensures container validates the required `SERPAPI_API_KEY` environment variable | ||
| - **test_container_starts_with_api_key**: Confirms container starts properly when API key is provided | ||
| - **test_container_python_version**: Validates Python 3.13 is used in the container | ||
| - **test_container_has_dependencies**: Checks all required dependencies are installed | ||
| - **test_server_module_exists**: Verifies the server module is present and accessible | ||
|
|
||
| ## CI/CD | ||
|
|
||
| These tests are designed to run in CI/CD pipelines and handle environment-specific issues like SSL certificate verification in restricted networks. | ||
|
|
||
| ### GitHub Actions | ||
|
|
||
| The e2e tests run automatically on every push to `main` and on all pull requests via GitHub Actions. See `.github/workflows/python-package.yml` for the workflow configuration. | ||
|
|
||
| The workflow includes: | ||
| - Running the full e2e test suite | ||
| - Code linting with Ruff | ||
| - Docker image build and validation | ||
| - Dependency and Docker layer caching for faster builds | ||
|
|
||
| Check the [Actions tab](https://github.com/ilyazub/serpapi-mcp-server/actions) to monitor test results. |
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 @@ | ||
| """Tests for SerpApi MCP Server.""" |
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@copilot Cool, thanks! Please add an e2e test.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added comprehensive e2e test suite in commit 3892965. The tests validate:
All 6 tests pass. Run with:
pytest tests/test_e2e_docker.py -v