Skip to content

Commit

Permalink
Fix don't update environment while building
Browse files Browse the repository at this point in the history
  • Loading branch information
CarrotManMatt committed Dec 15, 2024
1 parent aec3744 commit afd4ef1
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 30 deletions.
87 changes: 58 additions & 29 deletions .github/workflows/check-build-publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,10 @@ jobs:
mypy-package:
needs: [uv-check]
runs-on: ubuntu-latest
env:
UV_NO_SYNC: "true"
UV_FROZEN: "true"
UV_NO_PYTHON_DOWNLOADS: "true"

strategy:
matrix:
Expand All @@ -90,25 +94,27 @@ jobs:
python-version: ${{matrix.python-version}}

- name: Install mypy From Locked Dependencies
run: uv sync --python ${{matrix.python-version}} --no-python-downloads --no-group dev
--group type-check --frozen
run: uv sync --python ${{matrix.python-version}} --no-group dev --group type-check

- name: Save Hashed Python Version
id: save_hashed_python_version
run: echo "HASHED_PYTHON_VERSION=$(uv run --no-sync --no-python-downloads --python
${{matrix.python-version}} python -VV | sha256sum | cut -d' ' -f1)" >> $GITHUB_OUTPUT
run: echo "HASHED_PYTHON_VERSION=$(uv run --python ${{matrix.python-version}} python
-VV | sha256sum | cut -d' ' -f1)" >> $GITHUB_OUTPUT

- uses: actions/cache@v4
with:
path: ./.mypy_cache
key: mypy|${{steps.save_hashed_python_version.outputs.hashed_python_version}}|package

- name: Run mypy
run: uv run --python ${{matrix.python-version}} --no-sync --no-python-downloads mypy
pydowndoc/ # TODO: Add GitHub workflows output format
run: uv run --python ${{matrix.python-version}} mypy pydowndoc/ # TODO: Add GitHub workflows output format

mypy-build-script:
runs-on: ubuntu-latest
env:
UV_NO_SYNC: true
UV_FROZEN: true
UV_PYTHON_DOWNLOADS: never

steps:
- uses: actions/checkout@v4
Expand All @@ -125,23 +131,27 @@ jobs:
python-version-file: .python-version

- name: Install mypy From Locked Dependencies
run: uv sync --no-python-downloads --only-group type-check --only-group build-dev --frozen
run: uv sync --only-group type-check --only-group build-dev

- name: Save Hashed Python Version
id: save_hashed_python_version
run: echo "HASHED_PYTHON_VERSION=$(uv run --no-sync --no-python-downloads python -VV
| sha256sum | cut -d' ' -f1)" >> $GITHUB_OUTPUT
run: echo "HASHED_PYTHON_VERSION=$(uv run python -VV | sha256sum | cut -d' ' -f1)"
>> $GITHUB_OUTPUT

- uses: actions/cache@v4
with:
path: ./.mypy_cache
key: mypy|${{steps.save_hashed_python_version.outputs.hashed_python_version}}|build-script

- name: Run mypy
run: uv run --no-sync --no-python-downloads mypy hatch_build.py # TODO: Add GitHub workflows output format
run: uv run mypy hatch_build.py # TODO: Add GitHub workflows output format

pre-commit:
runs-on: ubuntu-latest
env:
UV_NO_SYNC: true
UV_FROZEN: true
UV_PYTHON_DOWNLOADS: never

steps:
- uses: actions/checkout@v4
Expand All @@ -158,31 +168,34 @@ jobs:
python-version-file: .python-version

- name: Install pre-commit From Locked Dependencies
run: uv sync --no-python-downloads --only-group pre-commit --frozen
run: uv sync --only-group pre-commit

- name: Save Hashed Python Version
id: save_hashed_python_version
run: echo "hashed_python_version=$(uv run --no-sync --no-python-downloads python -VV
| sha256sum | cut -d' ' -f1)" >> $GITHUB_OUTPUT
run: echo "hashed_python_version=$(uv run python -VV | sha256sum | cut -d' ' -f1)"
>> $GITHUB_OUTPUT

- uses: actions/cache@v4
with:
path: ~/.cache/pre-commit
key: pre-commit|${{steps.save_hashed_python_version.outputs.hashed_python_version}}|${{hashFiles('.pre-commit-config.yaml')}}

- name: Setup pre-commit Environments
run: uv run --no-sync --no-python-downloads pre-commit install-hooks
run: uv run pre-commit install-hooks

- name: Save pre-commit Checks Which Require Skipping
run: echo "SKIP=check-github-workflows,ruff,ruff-format,taplo-format,taplo-lint,uv-lock,yamlfmt"
>> $GITHUB_ENV

- name: Run pre-commit
run: uv run --no-sync --no-python-downloads pre-commit run --all-files --hook-stage
manual # TODO: Add GitHub workflows output format
run: uv run pre-commit run --all-files --hook-stage manual # TODO: Add GitHub workflows output format

ruff-lint:
runs-on: ubuntu-latest
env:
UV_NO_SYNC: true
UV_FROZEN: true
UV_PYTHON_DOWNLOADS: never

steps:
- uses: actions/checkout@v4
Expand All @@ -199,24 +212,28 @@ jobs:
python-version-file: .python-version

- name: Install ruff From Locked Dependencies
run: uv sync --no-python-downloads --only-group lint-format --frozen
run: uv sync --only-group lint-format

- name: Save Hashed Python Version
id: save_hashed_python_version
run: echo "hashed_python_version=$(uv run --no-sync --no-python-downloads python -VV
| sha256sum | cut -d' ' -f1)" >> $GITHUB_OUTPUT
run: echo "hashed_python_version=$(uv run python -VV | sha256sum | cut -d' ' -f1)"
>> $GITHUB_OUTPUT

- uses: actions/cache@v4
with:
path: ./.ruff_cache
key: ruff|${{steps.save_hashed_python_version.outputs.hashed_python_version}}

- name: Run Ruff
run: uv run --no-sync --no-python-downloads ruff check --no-fix --output-format=github
run: uv run ruff check --no-fix --output-format=github

ruff-format:
needs: [ruff-lint]
runs-on: ubuntu-latest
env:
UV_NO_SYNC: true
UV_FROZEN: true
UV_PYTHON_DOWNLOADS: never

steps:
- uses: actions/checkout@v4
Expand All @@ -233,23 +250,27 @@ jobs:
python-version-file: .python-version

- name: Install ruff From Locked Dependencies
run: uv sync --no-python-downloads --only-group lint-format --frozen
run: uv sync --only-group lint-format

- name: Save Hashed Python Version
id: save_hashed_python_version
run: echo "hashed_python_version=$(uv run --no-sync --no-python-downloads python -VV
| sha256sum | cut -d' ' -f1)" >> $GITHUB_OUTPUT
run: echo "hashed_python_version=$(uv run python -VV | sha256sum | cut -d' ' -f1)"
>> $GITHUB_OUTPUT

- uses: actions/cache@v4
with:
path: ./.ruff_cache
key: ruff|${{steps.save_hashed_python_version.outputs.hashed_python_version}}

- name: Run Ruff
run: uv run --no-sync --no-python-downloads ruff format --check
run: uv run ruff format --check

taplo-format:
runs-on: ubuntu-latest
env:
UV_NO_SYNC: true
UV_FROZEN: true
UV_PYTHON_DOWNLOADS: never

steps:
- uses: actions/checkout@v4
Expand All @@ -266,14 +287,18 @@ jobs:
python-version-file: .python-version

- name: Install Taplo From Locked Dependencies
run: uv sync --no-python-downloads --only-group lint-format --frozen
run: uv sync --only-group lint-format

- name: Run Taplo Formatter
run: uv run --no-sync --no-python-downloads taplo format . --check # TODO: Add GitHub workflows output format
run: uv run taplo format . --check # TODO: Add GitHub workflows output format

taplo-lint:
needs: [taplo-format]
runs-on: ubuntu-latest
env:
UV_NO_SYNC: true
UV_FROZEN: true
UV_PYTHON_DOWNLOADS: never

steps:
- uses: actions/checkout@v4
Expand All @@ -290,10 +315,10 @@ jobs:
python-version-file: .python-version

- name: Install Taplo From Locked Dependencies
run: uv sync --no-python-downloads --only-group lint-format --frozen
run: uv sync --only-group lint-format

- name: Run Taplo Linter
run: uv run --no-sync --no-python-downloads taplo lint . --default-schema-catalogs # TODO: Add GitHub workflows output format
run: uv run taplo lint . --default-schema-catalogs # TODO: Add GitHub workflows output format

yamlfmt:
runs-on: ubuntu-latest
Expand All @@ -317,6 +342,10 @@ jobs:
ruff-lint, taplo-format, taplo-lint, yamlfmt, uv-check]
runs-on: ubuntu-latest
container: {image: quay.io/pypa/manylinux_2_34_x86_64}
env:
UV_NO_SYNC: true
UV_FROZEN: true
UV_PYTHON_DOWNLOADS: never

steps:
- uses: actions/checkout@v4
Expand All @@ -336,7 +365,7 @@ jobs:
path: downloads/

- name: Install Build Dependencies From Lock File
run: uv sync --no-python-downloads --only-group build --frozen
run: uv sync --only-group build

- name: Build Package
run: uv run hatch build -t custom
Expand Down
2 changes: 1 addition & 1 deletion uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit afd4ef1

Please sign in to comment.