-
Notifications
You must be signed in to change notification settings - Fork 1
Switched to UV #43
Switched to UV #43
Changes from 3 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,139 +1,41 @@ | ||
| name: Linting | ||
| name: Lint | ||
|
|
||
| on: | ||
| push: | ||
| branches: | ||
| - main | ||
| pull_request: | ||
| branches: | ||
| - main | ||
|
|
||
| jobs: | ||
| lint-flake8: | ||
| name: Linting with flake8 | ||
| linting: | ||
| name: Linting | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| - name: Setup Python | ||
| uses: actions/setup-python@v5 | ||
| - name: Install uv | ||
| uses: astral-sh/setup-uv@v2 | ||
| with: | ||
| python-version: '3.11' | ||
| cache: 'pip' | ||
| cache-dependency-path: | | ||
| requirements.txt | ||
| requirements-dev.txt | ||
| - uses: actions/cache@v4 | ||
| with: | ||
| path: ~/.cache/pip | ||
| key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }} | ||
| restore-keys: | | ||
| ${{ runner.os }}-pip- | ||
| - name: Install requirements | ||
| run: | | ||
| python -m pip install --upgrade pip | ||
| pip install -r requirements-dev.txt | ||
| - name: Lint with flake8 | ||
| run: | | ||
| flake8 --version # Verify flake8 is picking up flake8-bugbear | ||
| flake8 --max-line-length=120 . --exclude env,configuration,venv,src,scripts,.venv,e2e | ||
|
|
||
| lint-black: | ||
| name: Linting with black | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| enable-cache: true | ||
| cache-dependency-glob: "uv.lock" | ||
| - name: Setup Python | ||
| uses: actions/setup-python@v5 | ||
| with: | ||
| python-version: '3.11' | ||
| cache: 'pip' | ||
| cache-dependency-path: | | ||
| requirements.txt | ||
| requirements-dev.txt | ||
| - uses: actions/cache@v4 | ||
| with: | ||
| path: ~/.cache/pip | ||
| key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }} | ||
| restore-keys: | | ||
| ${{ runner.os }}-pip- | ||
| - name: Install requirements | ||
| run: | | ||
| python -m pip install --upgrade pip | ||
| pip install -r requirements-dev.txt | ||
| - name: Lint with black | ||
| run: black flask_utils -l119 --check | ||
|
|
||
| lint-imports-order: | ||
| name: Checking imports order | ||
| run: uv python install | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Correct the The command Apply this diff to correct the command: - run: uv python install
+ run: uv installAlso applies to: 37-37 |
||
| - name: Run Ruff | ||
| run: uv run ruff check --output-format=github . | ||
| type-checking: | ||
|
Comment on lines
+17
to
+26
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Refactor to eliminate duplication in job steps The steps for installing Also applies to: 31-41 |
||
| name: Type Checking | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| - name: Setup Python | ||
| uses: actions/setup-python@v5 | ||
| with: | ||
| python-version: '3.11' | ||
| cache: 'pip' | ||
| cache-dependency-path: | | ||
| requirements.txt | ||
| requirements-dev.txt | ||
| - uses: actions/cache@v4 | ||
| - name: Install uv | ||
| uses: astral-sh/setup-uv@v2 | ||
| with: | ||
| path: ~/.cache/pip | ||
| key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }} | ||
| restore-keys: | | ||
| ${{ runner.os }}-pip- | ||
| - name: Install requirements | ||
| run: | | ||
| python -m pip install --upgrade pip | ||
| pip install -r requirements-dev.txt | ||
| - name: Lint with reorder-python-imports | ||
| run: reorder-python-imports flask_utils/**/*.py tests/*.py | ||
|
|
||
| lint-typing: | ||
| name: Checking Typing with MyPy | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| enable-cache: true | ||
| cache-dependency-glob: "uv.lock" | ||
| - name: Setup Python | ||
| uses: actions/setup-python@v5 | ||
| with: | ||
| python-version: '3.11' | ||
| cache: 'pip' | ||
| cache-dependency-path: | | ||
| requirements.txt | ||
| requirements-dev.txt | ||
| - uses: actions/cache@v4 | ||
| with: | ||
| path: ~/.cache/pip | ||
| key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }} | ||
| restore-keys: | | ||
| ${{ runner.os }}-pip- | ||
| - name: Install requirements | ||
| run: | | ||
| python -m pip install --upgrade pip | ||
| pip install -r requirements-dev.txt | ||
| pip install types-flask | ||
| - name: Lint with mypy | ||
| run: mypy flask_utils | ||
|
|
||
| lint-sphinx: | ||
| name: Checking documentation with Sphinx | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| - name: Setup Python | ||
| uses: actions/setup-python@v5 | ||
| with: | ||
| python-version: '3.11' | ||
| cache: 'pip' | ||
| cache-dependency-path: | | ||
| requirements.txt | ||
| requirements-dev.txt | ||
| - uses: actions/cache@v4 | ||
| with: | ||
| path: ~/.cache/pip | ||
| key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }} | ||
| restore-keys: | | ||
| ${{ runner.os }}-pip- | ||
| - name: Install requirements | ||
| run: | | ||
| python -m pip install --upgrade pip | ||
| pip install -r requirements-dev.txt | ||
| - name: Lint with sphinx | ||
| run: sphinx-lint -i .venv -i .tox | ||
| run: uv python install | ||
| - name: Run mypy | ||
| # Using strict mode. | ||
| # Waiting for https://github.com/python/mypy/pull/17771 | ||
| run: uv run mypy --strict flask_utils | ||
| Original file line number | Diff line number | Diff line change | ||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -20,18 +20,17 @@ jobs: | |||||||||||||||
| - name: Check out repository | ||||||||||||||||
| uses: actions/checkout@v4 | ||||||||||||||||
|
|
||||||||||||||||
| - name: Set up Python ${{ matrix.python-version }} | ||||||||||||||||
| uses: actions/setup-python@v5 | ||||||||||||||||
| - name: Install uv | ||||||||||||||||
| uses: astral-sh/setup-uv@v2 | ||||||||||||||||
| with: | ||||||||||||||||
| python-version: ${{ matrix.python-version }} | ||||||||||||||||
| enable-cache: true | ||||||||||||||||
| cache-dependency-glob: "uv.lock" | ||||||||||||||||
|
|
||||||||||||||||
| - name: Install dependencies | ||||||||||||||||
| run: | | ||||||||||||||||
| python -m pip install --upgrade pip | ||||||||||||||||
| pip install tox | ||||||||||||||||
| - name: Setup Python | ||||||||||||||||
| run: uv python install ${{ matrix.python-version }} | ||||||||||||||||
|
|
||||||||||||||||
| - name: Run tests | ||||||||||||||||
| run: | | ||||||||||||||||
| PYTHON_VERSION=${{ matrix.python-version }} | ||||||||||||||||
| TOX_ENV=`tox --listenvs | grep "py${PYTHON_VERSION//./}-" | tr '\n' ','` | ||||||||||||||||
| tox -e $TOX_ENV | ||||||||||||||||
| export PYTHON_VERSION=${{ matrix.python-version }} | ||||||||||||||||
| export TOX_ENV=`uv run tox --listenvs | grep "py${PYTHON_VERSION//./}-" | tr '\n' ','` | ||||||||||||||||
| uv run tox -e $TOX_ENV | ||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nice work! Just a few suggestions to improve the script. Exporting the Running the tests using However, the static analysis tools have reported a few potential issues with the shell script:
To address these issues, please apply the following changes: - export TOX_ENV=`uv run tox --listenvs | grep "py${PYTHON_VERSION//./}-" | tr '\n' ','`
+ TOX_ENV=$(uv run tox --listenvs | grep "py${PYTHON_VERSION//./}-" | tr '\n' ',')
+ export TOX_ENV
- uv run tox -e $TOX_ENV
+ uv run tox -e "$TOX_ENV"These changes will:
Let me know if you have any questions or need further assistance with these changes. Committable suggestion
Suggested change
|
||||||||||||||||
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.
Correct the caching parameter name
In the
Install uvstep, the parametercache-dependency-globmay be incorrect. According to theastral-sh/setup-uv@v2documentation, the correct parameter iscache-dependency-path. Please update the parameter name to ensure caching works as intended.Apply this diff to correct the parameter name:
Also applies to: 35-35