-
Notifications
You must be signed in to change notification settings - Fork 42
ci: add cross-platform install matrix and API smoke checks #32
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
6 commits
Select commit
Hold shift + click to select a range
698e550
ci: add cross-platform install and api smoke matrix
Mehdi-Bl b2a72db
ci: fix workflow-dispatch input context in matrix workflow
Mehdi-Bl 92d3a97
ci: move secret guard out of job-level condition
Mehdi-Bl 1e4e440
build: add explicit greenlet runtime dependency
Mehdi-Bl e764df5
build: include requests in test extras
Mehdi-Bl 4c5a2f1
test: make security path assertions cross-platform
Mehdi-Bl 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,217 @@ | ||
| name: Install Matrix + API Smoke | ||
|
|
||
| on: | ||
| pull_request: | ||
| push: | ||
| branches: | ||
| - main | ||
| workflow_dispatch: | ||
| inputs: | ||
| run_live_claude: | ||
| description: Run optional live Claude + Haiku validation | ||
| required: false | ||
| type: boolean | ||
| default: false | ||
| live_model: | ||
| description: Model ID for optional live validation | ||
| required: false | ||
| type: string | ||
| default: claude-haiku-4-5-20251001 | ||
|
|
||
| permissions: | ||
| contents: read | ||
|
|
||
| jobs: | ||
| install-check: | ||
| name: Install ${{ matrix.install_mode }} | ${{ matrix.os }} | py${{ matrix.python-version }} | ||
| runs-on: ${{ matrix.os }} | ||
| strategy: | ||
| fail-fast: false | ||
| matrix: | ||
| os: | ||
| - ubuntu-latest | ||
| - macos-latest | ||
| - windows-latest | ||
| python-version: | ||
| - '3.11' | ||
| - '3.12' | ||
| install_mode: | ||
| - pep517 | ||
| - fallback | ||
| steps: | ||
| - name: Checkout repository | ||
| uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6 | ||
|
|
||
| - name: Set up Python | ||
| uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6 | ||
| with: | ||
| python-version: ${{ matrix.python-version }} | ||
|
|
||
| - name: Upgrade packaging tools | ||
| run: python -m pip install --upgrade pip setuptools wheel | ||
|
|
||
| - name: Install package with PEP 517 editable mode | ||
| if: ${{ matrix.install_mode == 'pep517' }} | ||
| run: python -m pip install -e . --use-pep517 | ||
|
|
||
| - name: Install package with editable fallback mode | ||
| if: ${{ matrix.install_mode == 'fallback' }} | ||
| run: python -m pip install -e . | ||
|
|
||
| - name: Validate dependency graph | ||
| run: python -m pip check | ||
|
|
||
| - name: Validate runtime imports | ||
| run: python -c "import claude_code_api, greenlet, sqlalchemy; print('install-import-smoke-ok')" | ||
|
|
||
| api-smoke: | ||
| name: API smoke | ${{ matrix.os }} | py${{ matrix.python-version }} | ||
| runs-on: ${{ matrix.os }} | ||
| needs: install-check | ||
| strategy: | ||
| fail-fast: false | ||
| matrix: | ||
| os: | ||
| - ubuntu-latest | ||
| - macos-latest | ||
| - windows-latest | ||
| python-version: | ||
| - '3.11' | ||
| - '3.12' | ||
| steps: | ||
| - name: Checkout repository | ||
| uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6 | ||
|
|
||
| - name: Set up Python | ||
| uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6 | ||
| with: | ||
| python-version: ${{ matrix.python-version }} | ||
|
|
||
| - name: Upgrade packaging tools | ||
| run: python -m pip install --upgrade pip setuptools wheel | ||
|
|
||
| - name: Install project with test extras | ||
| run: python -m pip install -e ".[test]" --use-pep517 | ||
|
|
||
| - name: Run deterministic tests (excluding live e2e) | ||
| run: python -m pytest -q -m "not e2e" | ||
|
|
||
| - name: Run API health smoke test | ||
| run: python -m pytest -q tests/test_end_to_end.py::TestHealthAndBasics::test_health_check | ||
|
|
||
| - name: Run API models smoke test | ||
| run: python -m pytest -q tests/test_end_to_end.py::TestModelsAPI::test_list_models | ||
|
|
||
| - name: Upload test artifacts on failure | ||
| if: ${{ failure() }} | ||
| uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0 | ||
| with: | ||
| name: api-smoke-artifacts-${{ matrix.os }}-py${{ matrix.python-version }} | ||
| path: | | ||
| .pytest_cache | ||
| dist/tests | ||
| if-no-files-found: ignore | ||
| retention-days: 14 | ||
|
|
||
| live-claude-haiku: | ||
| name: Live Claude + Haiku validation (manual) | ||
| if: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.run_live_claude == 'true' }} | ||
| runs-on: ubuntu-latest | ||
| needs: api-smoke | ||
| continue-on-error: true | ||
| steps: | ||
| - name: Checkout repository | ||
| uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6 | ||
|
|
||
| - name: Set up Python | ||
| uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6 | ||
| with: | ||
| python-version: '3.12' | ||
|
|
||
| - name: Upgrade packaging tools | ||
| run: python -m pip install --upgrade pip setuptools wheel | ||
|
|
||
| - name: Install project with test extras | ||
| run: python -m pip install -e ".[test]" --use-pep517 | ||
|
|
||
| - name: Install Claude CLI | ||
| run: curl -fsSL https://claude.ai/install.sh | bash | ||
|
|
||
| - name: Add Claude CLI path | ||
| run: echo "$HOME/.local/bin" >> "$GITHUB_PATH" | ||
|
|
||
| - name: Verify ANTHROPIC_API_KEY is configured | ||
| env: | ||
| ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }} | ||
| run: | | ||
| if [ -z "${ANTHROPIC_API_KEY:-}" ]; then | ||
| echo "ANTHROPIC_API_KEY secret is required for live Claude validation." | ||
| exit 1 | ||
| fi | ||
|
|
||
| - name: Configure Claude auth from API key | ||
| env: | ||
| ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }} | ||
| run: | | ||
| python - <<'PY' | ||
| import json | ||
| import os | ||
| from pathlib import Path | ||
|
|
||
| config_dir = Path.home() / ".config" / "claude" | ||
| config_dir.mkdir(parents=True, exist_ok=True) | ||
| config = {"apiKey": os.environ["ANTHROPIC_API_KEY"], "autoUpdate": False} | ||
| with (config_dir / "config.json").open("w", encoding="utf-8") as handle: | ||
| json.dump(config, handle) | ||
| PY | ||
|
|
||
| - name: Start API server | ||
| run: | | ||
| nohup python -m claude_code_api.main > api-server.log 2>&1 & | ||
| echo "$!" > api-server.pid | ||
|
|
||
| - name: Wait for health endpoint | ||
| run: | | ||
| python - <<'PY' | ||
| import time | ||
| import urllib.error | ||
| import urllib.request | ||
|
|
||
| url = "http://127.0.0.1:8000/health" | ||
| deadline = time.time() + 60 | ||
| while time.time() < deadline: | ||
| try: | ||
| with urllib.request.urlopen(url, timeout=5) as response: | ||
| if response.status == 200: | ||
| raise SystemExit(0) | ||
| except urllib.error.URLError: | ||
| pass | ||
| time.sleep(2) | ||
|
|
||
| raise SystemExit("API health check failed after 60 seconds") | ||
| PY | ||
|
|
||
| - name: Run live E2E against Haiku | ||
| env: | ||
| CLAUDE_CODE_API_E2E: '1' | ||
| CLAUDE_CODE_API_BASE_URL: http://127.0.0.1:8000 | ||
| CLAUDE_CODE_API_TEST_MODEL: ${{ github.event.inputs.live_model || 'claude-haiku-4-5-20251001' }} | ||
| run: python -m pytest -q tests/test_e2e_live_api.py -m e2e -v | ||
|
|
||
| - name: Stop API server | ||
| if: ${{ always() }} | ||
| run: | | ||
| if [ -f api-server.pid ]; then | ||
| kill "$(cat api-server.pid)" || true | ||
| fi | ||
|
|
||
| - name: Upload live validation logs | ||
| if: ${{ always() }} | ||
| uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0 | ||
| with: | ||
| name: live-claude-haiku-logs | ||
| path: | | ||
| api-server.log | ||
| dist/tests | ||
| if-no-files-found: ignore | ||
| retention-days: 14 | ||
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
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
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
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.
🚨 suggestion (security): Piping curl directly to bash introduces a supply-chain risk.
Using
curl -fsSL … | bashmakes the workflow dependent on executing whatever that endpoint serves at runtime. Where possible, prefer a more controlled install path (e.g., versioned release or package manager) and/or pin via checksum or signature verification so a compromised install endpoint can’t silently impact CI runs.Suggested implementation:
https://claude.ai/install.shscript (e.g., from release notes or by downloading the script once in a controlled environment and computingsha256sum install.sh)."<expected-sha256-of-install.sh>"placeholder with that exact checksum value so the workflow will fail if the installer content changes unexpectedly.CLAUDE_INSTALL_URLto a specific versioned installer URL if the project provides one, further reducing the risk of unexpected changes.