Skip to content

Commit

Permalink
Run tools with uv
Browse files Browse the repository at this point in the history
  • Loading branch information
kdeldycke committed Jun 5, 2024
1 parent ddfabde commit 24f6df2
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 41 deletions.
21 changes: 8 additions & 13 deletions .github/workflows/autofix.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -149,8 +149,7 @@ jobs:
# - --aggressive is requires to force autopep8 to consider comments.
# Explicit list of files is provided, as autopep8 is not able to handle find files in ".github" subdirectory.
run: >
source .venv/bin/activate &&
autopep8 --recursive --in-place --max-line-length 88 --select E501 --aggressive
uv tool run autopep8 --recursive --in-place --max-line-length 88 --select E501 --aggressive
${{ needs.project-metadata.outputs.python_files }}
- name: Optional Ruff config
if: needs.project-metadata.outputs.ruff_py_version
Expand Down Expand Up @@ -206,15 +205,13 @@ jobs:
run: |
cat ./ruff.toml
- name: Run Ruff check
run: >
source .venv/bin/activate &&
ruff check --config ./ruff.toml
run: |
uv tool run ruff check --config ./ruff.toml
- name: Run Ruff format
# XXX: Ruff is planning to support linting and formatting in one unified command at one point.
# See: https://github.com/astral-sh/ruff/issues/8232
run: >
source .venv/bin/activate &&
ruff format --config ./ruff.toml
run: |
uv tool run ruff format --config ./ruff.toml
- name: Remove temporary Ruff config
run: |
rm ./ruff.toml
Expand All @@ -228,8 +225,7 @@ jobs:
# TODO: replace blacken-docs by ruff. See: https://github.com/astral-sh/ruff/issues/8237
# https://github.com/astral-sh/ruff/issues/3792
run: >
source .venv/bin/activate &&
blacken-docs
uv tool run blacken-docs
--line-length 88
${{ needs.project-metadata.outputs.blacken_docs_params }}
${{ needs.project-metadata.outputs.doc_files }}
Expand Down Expand Up @@ -304,9 +300,8 @@ jobs:
run: |
sudo apt install --yes shfmt
- name: Auto-format Markdown
run: >
source .venv/bin/activate &&
find ./ -iname "*.md" -exec mdformat "{}" \;
run: |
find ./ -iname "*.md" -exec uv tool run mdformat "{}" \;
- name: Markdown fixes for Awesome Lists
if: startsWith(github.event.repository.name, 'awesome-')
# Remove forbidden TOC entries
Expand Down
35 changes: 13 additions & 22 deletions .github/workflows/changelog.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,12 @@ jobs:
- name: ${{ matrix.part }} version bump
# TODO: get configuration URL once https://github.com/callowayproject/bump-my-version/issues/148 is addressed,
# so we can factorize projects' pyproject.toml files to kdeldycke/workflow/pyproject.toml .
run: >
source .venv/bin/activate &&
bump-my-version bump --verbose ${{ matrix.part }}
run: |
uv tool run bump-my-version bump --verbose ${{ matrix.part }}
- name: Extract version
id: get_version
run: >
source .venv/bin/activate &&
echo "new_version=$( bump-my-version show current_version )" >> "$GITHUB_OUTPUT"
run: |
echo "new_version=$( uv tool run bump-my-version show current_version )" >> "$GITHUB_OUTPUT"
- name: Print version
run: |
echo "New version: ${{ steps.get_version.outputs.new_version }}"
Expand Down Expand Up @@ -130,9 +128,8 @@ jobs:
uv pip install -r https://raw.githubusercontent.com/kdeldycke/workflows/main/requirements/changelog.txt
- name: Extract version
id: get_version
run: >
source .venv/bin/activate &&
echo "current_version=$( bump-my-version show current_version )" >> "$GITHUB_OUTPUT"
run: |
echo "current_version=$( uv tool run bump-my-version show current_version )" >> "$GITHUB_OUTPUT"
- name: Print version
run: |
echo "Current version: ${{ steps.get_version.outputs.current_version }}"
Expand All @@ -143,31 +140,27 @@ jobs:
# This hack could be removed if we manage to encode these search and replace patterns into bump-my-version's
# TOML.
run: >
source .venv/bin/activate &&
RELEASE_DEFAULT_BRANCH="main" &&
bump-my-version replace --no-configured-files --ignore-missing-version
uv tool run bump-my-version replace --no-configured-files --ignore-missing-version
--search "/workflows/$RELEASE_DEFAULT_BRANCH/"
--replace "/workflows/v{current_version}/"
./.github/workflows/*.yaml
- name: Set release date in changelog
run: >
source .venv/bin/activate &&
bump-my-version replace --no-configured-files
uv tool run bump-my-version replace --no-configured-files
--search " (unreleased)"
--replace " ({utcnow:%Y-%m-%d})"
./changelog.md
- name: Update comparison URL in changelog
run: >
source .venv/bin/activate &&
bump-my-version replace --no-configured-files
uv tool run bump-my-version replace --no-configured-files
--search "...main"
--replace "...v{current_version}"
./changelog.md
- name: Remove first warning message in changelog
# Matches first occurrence of a multi-line block of text delimited by triple-backticks (```<anything>```).
run: >
source .venv/bin/activate &&
bump-my-version replace --no-configured-files --ignore-missing-version
uv tool run bump-my-version replace --no-configured-files --ignore-missing-version
--regex --search "^\\\`\\\`\\\`.*?\\\`\\\`\\\`\\n\\n"
--replace ""
./changelog.md
Expand All @@ -188,9 +181,8 @@ jobs:
# This hack could be removed if we manage to encode these search and replace patterns into bump-my-version's
# TOML.
run: >
source .venv/bin/activate &&
RELEASE_DEFAULT_BRANCH="main" &&
bump-my-version replace --no-configured-files --ignore-missing-version
uv tool run bump-my-version replace --no-configured-files --ignore-missing-version
--search "/workflows/v{current_version}/"
--replace "/workflows/$RELEASE_DEFAULT_BRANCH/"
./.github/workflows/*.yaml
Expand All @@ -201,9 +193,8 @@ jobs:
- name: Version bump
# TODO: get configuration URL once https://github.com/callowayproject/bump-my-version/issues/148 is addressed,
# so we can factorize projects' pyproject.toml files to kdeldycke/workflow/pyproject.toml .
run: >
source .venv/bin/activate &&
bump-my-version bump --verbose patch
run: |
uv tool run bump-my-version bump --verbose patch
- name: Commit post-release version bump
run: |
git commit --all --message="[changelog] Post-release version bump"
Expand Down
8 changes: 3 additions & 5 deletions .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ jobs:
if: fromJSON(needs.project-metadata.outputs.is_poetry_project)
run: |
uv pip install -r https://raw.githubusercontent.com/kdeldycke/workflows/main/requirements/build.txt
source .venv/bin/activate && poetry install --all-extras --with typing --with test --no-interaction
uv tool run poetry install --all-extras --with typing --with test --no-interaction
- name: Install package with uv
if: ${{ ! fromJSON(needs.project-metadata.outputs.is_poetry_project) }}
run: |
Expand All @@ -117,8 +117,7 @@ jobs:
# We can use the bare mypy CLI for both Poetry and non-Poetry projects after activating the venv.
# --color-output - Force colorized output as in CI, Mypy defaults to no color in CI.
run: >
source .venv/bin/activate &&
mypy --color-output ${{ needs.project-metadata.outputs.mypy_params }}
uv tool run mypy --color-output ${{ needs.project-metadata.outputs.mypy_params }}
${{ needs.project-metadata.outputs.python_files }}
lint-yaml:
Expand Down Expand Up @@ -172,8 +171,7 @@ jobs:
uv pip install -r https://raw.githubusercontent.com/kdeldycke/workflows/main/requirements/yamllint.txt
- name: Run yamllint
run: |
source .venv/bin/activate &&
yamllint --strict --config-data "{rules: {line-length: {max: 120}}}" --format github .
uv tool run yamllint --strict --config-data "{rules: {line-length: {max: 120}}}" --format github .
lint-zsh:
runs-on: ubuntu-22.04
Expand Down
2 changes: 1 addition & 1 deletion changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
This version is not released yet and is under active development.
```

- Use `uv` to install tools.
- Use `uv` to install and run tools.

## [3.5.6 (2024-06-05)](https://github.com/kdeldycke/workflows/compare/v3.5.5...v3.5.6)

Expand Down

0 comments on commit 24f6df2

Please sign in to comment.