ruff: exclude default configuration not working on github workflow
Summary
When I use ruff format --check . is executed locally works as expected ignoring the .venv directory, but when is used in github workflow, it starts iterating the .venv:
Downloaded ruff Installed 1 package in 157ms warning: The top-level linter settings are deprecated in favour of their counterparts in the lint section. Please update the following options in .venv/lib/python3.11…/actions/runs/…/site-packages/pandas/pyproject.toml:
‘ignore’ -> ‘lint.ignore’ ‘select’ -> ‘lint.select’ ‘typing-modules’ -> ‘lint.typing-modules’ ‘unfixable’ -> ‘lint.unfixable’ ‘per-file-ignores’ -> ‘lint.per-file-ignores’ warning: PGH001 has been remapped to S307. error: Failed to read .venv/lib/python3.11/site-packages/joblib/test/test_func_inspect_special_encoding.py: stream did not contain valid UTF-8 Would reformat: .venv/bin/activate_this.py Would reformat: .venv/bin/jp.py Would reformat: .venv/lib/python3.11/site-packages/IPython/init.py …
I’ve tried also the --isolated flag with identical result.
As a base environment I use our custom action with the following code:
name: "Setup UV Build Environment"
description: "Sets up the build environment with Python, dependencies, and tools."
runs:
using: "composite"
steps:
- name: Install tar
run: yum install -y tar
shell: bash
- name: Install uv
uses: astral-sh/setup-uv@v5
with:
python-version: 3.11
enable-cache: true
cache-dependency-glob: |
**/uv.lock
**/pyproject.toml
version: "latest"
- name: Install dependencies
run: uv sync --all-extras --index https://pypi.org/simple -U -v
shell: bash
And here my github workflow:
name: satio workflow
on:
pull_request:
# all branches
branches:
- '*'
push:
branches: ['main', 'dev']
workflow_dispatch:
jobs:
format-lint:
runs-on: ubuntu-latest
container:
image: almalinux:9
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup build environment
uses: VITO-RS-Vegetation/veg-template@v1 # Reuse the composite action
with:
token: ${{ secrets.GITHUB_TOKEN }} # Use the built-in GITHUB_TOKEN for authentication
- name: Run format-linter
run: |
ruff --version
ruff format --check .
ruff check .
perform-tests:
runs-on: ubuntu-latest
container:
image: almalinux:9
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup build environment
uses: VITO-RS-Vegetation/veg-template@v1 # Reuse the composite action
with:
token: ${{ secrets.GITHUB_TOKEN }} # Use the built-in GITHUB_TOKEN for authentication
- name: Run tests
run: uv run pytest tests
Lastly and strangely, I am using the same workflow file in another repository and it ignores correctly as expected the .venv directory
Version
ruff 0.11.2
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Comments: 16 (8 by maintainers)
I don’t think this is a bug because
gitignorefiles should only be respected in a git repository, and the GitHub REST API doesn’t create a checkout that mimics a full git repository.The solution here is to either use an
.ignorefile or install git in your container.@MichaReiser should this tagged as bug to track it?
I think I know where the difference comes from.
almalinuxships without git. At least, I see the following in the almalinux workflow logs (checkout repository)vs on ubuntu
And the absence of the
.gitdirectory changes howignore(our crate to traverse directories) handles.gitignorefiles.No, both versions are printed before the command: