-
Notifications
You must be signed in to change notification settings - Fork 0
ci: add pytest, ruff, mypy, and Docker build verification to CI #36
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
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,120 @@ | ||
| name: Test & Lint | ||
|
|
||
| on: | ||
| push: | ||
| branches: ["main"] | ||
| pull_request: | ||
| branches: ["main"] | ||
| workflow_dispatch: | ||
|
|
||
| permissions: | ||
| contents: read | ||
|
|
||
| jobs: | ||
| test: | ||
| name: Python Tests | ||
| runs-on: ubuntu-latest | ||
|
|
||
| steps: | ||
| - uses: actions/checkout@v6 | ||
|
|
||
| - uses: actions/setup-python@v5 | ||
| with: | ||
| python-version: '3.12' | ||
| cache: 'pip' | ||
| cache-dependency-path: | | ||
| auth-proxy/requirements.txt | ||
| requirements-test.txt | ||
|
|
||
| - name: Install dependencies | ||
| run: | | ||
| python -m pip install --upgrade pip | ||
| pip install -r auth-proxy/requirements.txt | ||
| pip install -r requirements-test.txt | ||
|
|
||
| - name: Run tests | ||
| working-directory: . | ||
| run: | | ||
| python -m pytest tests/ -v --tb=short | ||
|
|
||
| lint: | ||
| name: Ruff Lint & Format | ||
| runs-on: ubuntu-latest | ||
|
|
||
| steps: | ||
| - uses: actions/checkout@v6 | ||
|
|
||
| - uses: actions/setup-python@v5 | ||
| with: | ||
| python-version: '3.12' | ||
| cache: 'pip' | ||
|
|
||
| - name: Install ruff | ||
| run: pip install ruff | ||
|
|
||
| - name: Run ruff check | ||
| run: ruff check auth-proxy/ scripts/ tests/ | ||
|
|
||
| - name: Run ruff format check | ||
| run: ruff format --check auth-proxy/ scripts/ tests/ | ||
|
|
||
| typecheck: | ||
| name: Mypy Type Check | ||
| runs-on: ubuntu-latest | ||
|
|
||
| steps: | ||
| - uses: actions/checkout@v6 | ||
|
|
||
| - uses: actions/setup-python@v5 | ||
| with: | ||
| python-version: '3.12' | ||
| cache: 'pip' | ||
| cache-dependency-path: | | ||
| auth-proxy/requirements.txt | ||
| requirements-test.txt | ||
|
|
||
| - name: Install dependencies | ||
| run: | | ||
| python -m pip install --upgrade pip | ||
| pip install -r auth-proxy/requirements.txt | ||
| pip install -r requirements-test.txt | ||
| pip install mypy | ||
|
|
||
| - name: Run mypy | ||
| run: | | ||
| echo "Mypy is advisory — errors are reported but do not fail CI." | ||
| echo "Fix errors incrementally as you touch files." | ||
| mypy auth-proxy/ scripts/ --ignore-missing-imports --check-untyped-defs --no-strict-optional || true | ||
|
|
||
| docker: | ||
| name: Docker Build Check | ||
| runs-on: ubuntu-latest | ||
|
|
||
| steps: | ||
| - uses: actions/checkout@v6 | ||
|
|
||
| - name: Set up Docker Buildx | ||
| uses: docker/setup-buildx-action@v3 | ||
|
|
||
| - name: Build Docker image | ||
| uses: docker/build-push-action@v6 | ||
| with: | ||
| context: . | ||
| push: false | ||
| load: true | ||
| tags: privatemode-proxy:test | ||
| cache-from: type=gha | ||
| cache-to: type=gha,mode=max | ||
|
|
||
| - name: Verify container starts | ||
| run: | | ||
| docker run --rm -d --name test-container \ | ||
| -e API_KEYS_FILE=/app/secrets/keys.json \ | ||
| -e UPSTREAM_URL=http://localhost:8081 \ | ||
| -e PORT=8080 \ | ||
| -e PRIVATEMODE_API_KEY=test-key \ | ||
| -e FORCE_HTTPS=false \ | ||
| privatemode-proxy:test | ||
| sleep 5 | ||
| docker logs test-container | ||
| docker stop test-container | ||
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.
🧩 Analysis chain
🏁 Script executed:
Repository: Open-Paws/privatemode-proxy
Length of output: 2536
Docker smoke test may silently mask container startup failures.
Two compounding issues:
Missing
PBKDF2_SALTandADMIN_PASSWORD:auth-proxy/admin.pyraisesValueErrorat import time ifPBKDF2_SALTis shorter than 16 bytes. The docker run command doesn't set these variables, so the container will crash immediately on startup. The test configuration intests/conftest.pyproperly sets both to valid defaults.--rm+ crash = misleading failure: With--rm -d, if the container exits within the 5-second window due to the startup error above, it is automatically removed. Subsequentdocker logs test-containeranddocker stop test-containercommands then fail with "no such container" — the CI step exits non-zero for the wrong reason and the actual crash logs are lost.🔧 Proposed fix
- name: Verify container starts run: | - docker run --rm -d --name test-container \ + docker run -d --name test-container \ -e API_KEYS_FILE=/app/secrets/keys.json \ -e UPSTREAM_URL=http://localhost:8081 \ -e PORT=8080 \ -e PRIVATEMODE_API_KEY=test-key \ -e FORCE_HTTPS=false \ + -e PBKDF2_SALT=test-salt-value-1234567890 \ + -e ADMIN_PASSWORD=test-admin-password \ privatemode-proxy:test sleep 5 docker logs test-container - docker stop test-container + docker stop test-container || true + docker rm -f test-container || true📝 Committable suggestion
🤖 Prompt for AI Agents