-
Notifications
You must be signed in to change notification settings - Fork 4
Migrate to uv from requirements.txt #375
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
Open
andersonshatch
wants to merge
1
commit into
main
Choose a base branch
from
full-uv
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
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
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 |
|---|---|---|
|
|
@@ -24,13 +24,14 @@ jobs: | |
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v6 | ||
| - uses: actions/setup-python@v6 | ||
| - name: Install uv | ||
| uses: astral-sh/setup-uv@v4 | ||
| with: | ||
| python-version: ${{ env.DEFAULT_PYTHON }} | ||
| cache: "pip" | ||
| cache-dependency-path: requirements-dev.txt | ||
| - name: Install dev dependencies | ||
| run: pip install -r requirements-dev.txt | ||
| enable-cache: true | ||
| - name: Set up Python | ||
| run: uv python install ${{ env.DEFAULT_PYTHON }} | ||
| - name: Install dependencies | ||
| run: uv sync --group dev | ||
| - name: Restore pre-commit environment from cache | ||
| id: cache-precommit | ||
| uses: actions/[email protected] | ||
|
|
@@ -40,11 +41,11 @@ jobs: | |
| ${{ runner.os }}-pre-commit-${{ hashFiles('.pre-commit-config.yaml') }} | ||
| - name: Install pre-commit dependencies | ||
| if: steps.cache-precommit.outputs.cache-hit != 'true' | ||
| run: pre-commit install-hooks | ||
| run: uv run pre-commit install-hooks | ||
| - name: Run pre-commit | ||
| run: pre-commit run --hook-stage manual --all-files --show-diff-on-failure | ||
| run: uv run pre-commit run --hook-stage manual --all-files --show-diff-on-failure | ||
| - name: Run unit-tests | ||
| run: python -m pytest --cov --cov-config=tox.ini --cov-report=term --cov-report=html | ||
| run: uv run pytest --cov --cov-config=tox.ini --cov-report=term --cov-report=html | ||
| - uses: actions/upload-artifact@v6 | ||
| with: | ||
| name: test-coverage | ||
|
|
||
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,14 +1,24 @@ | ||
| FROM ghcr.io/astral-sh/uv:python3.13-alpine | ||
|
|
||
| ENV VIRT_ENV=/opt/venv | ||
| RUN uv venv $VIRT_ENV --python 3.13 | ||
| ENV PATH="$VIRT_ENV/bin:$PATH" | ||
| WORKDIR /app | ||
|
|
||
| ADD requirements.txt requirements.txt | ||
| RUN uv pip install -r requirements.txt | ||
| # Copy pyproject.toml and lock file for dependency installation | ||
| COPY pyproject.toml uv.lock* ./ | ||
|
|
||
| ADD contrastverify contrastverify | ||
| ADD version.py version.py | ||
| ADD verify.py verify.py | ||
| # Install dependencies and create the virtual environment | ||
| RUN uv sync --frozen --no-dev | ||
|
|
||
| ENTRYPOINT ["/usr/bin/env", "python3", "/verify.py"] | ||
| # Copy application code | ||
| COPY contrastverify contrastverify | ||
| COPY version.py version.py | ||
| COPY verify.py verify.py | ||
| COPY verify-wrapper.py verify-wrapper.py | ||
|
|
||
| # Install the local package in the already created environment | ||
| RUN uv pip install --no-deps -e . | ||
|
|
||
| # Create backward compatibility symlink for GitLab users | ||
| RUN ln -s /app/verify-wrapper.py /verify.py && chmod +x /verify.py | ||
|
|
||
| # Use the virtual environment directly instead of uv run | ||
| ENTRYPOINT ["/app/.venv/bin/python3", "verify.py"] | ||
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,30 @@ | ||
| [project] | ||
| name = "contrast-verify-action" | ||
| version = "1.0.0" | ||
| description = "GitHub Action to verify an application by determining whether the application violates a job outcome policy or threshold of open vulnerabilities from Contrast Security" | ||
| authors = [ | ||
| {name = "Josh Anderson", email = "[email protected]"} | ||
| ] | ||
| requires-python = ">=3.13" | ||
| dependencies = [ | ||
| "requests", | ||
| "actions-toolkit", | ||
| "certifi", | ||
| "cryptography", | ||
| ] | ||
|
|
||
| [dependency-groups] | ||
| dev = [ | ||
| "pytest", | ||
| "pytest-cov", | ||
| "responses", | ||
| "pre-commit", | ||
| "bump2version", | ||
| ] | ||
|
|
||
| [build-system] | ||
| requires = ["hatchling"] | ||
| build-backend = "hatchling.build" | ||
|
|
||
| [tool.hatch.build.targets.wheel] | ||
| packages = ["contrastverify"] |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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.
Installing the package in editable mode (-e) in a production Docker image is unnecessary and can cause confusion. For production containers, use a regular installation without the -e flag to ensure a clean, non-editable installation.