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)

Most upvoted comments

I don’t think this is a bug because gitignore files 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 .ignore file or install git in your container.

@MichaReiser should this tagged as bug to track it?

I think I know where the difference comes from. almalinux ships without git. At least, I see the following in the almalinux workflow logs (checkout repository)

Run actions/checkout@v4
/usr/bin/docker exec  574be3a89f9a68333acc5500512e3a15fbb7bb14162e8b5c19f7d63b0af3415f sh -c "cat /etc/*release | grep ^ID"
Syncing repository: lagamura/gitruff
Getting Git version info
Deleting the contents of '/__w/gitruff/gitruff'
The repository will be downloaded using the GitHub REST API
To create a local Git repository instead, add Git 2.18 or higher to the PATH
Downloading the archive
Writing archive to disk
Extracting the archive
/usr/bin/tar xz --warning=no-unknown-keyword --overwrite -C /__w/gitruff/gitruff/d58e8101-e5f8-4c36-91bc-c4205f75cfd8 -f /__w/gitruff/gitruff/d58e8101-e5f8-4c36-91bc-c4205f75cfd8.tar.gz
Resolved version lagamura-gitruff-1aad048

vs on ubuntu

Run actions/checkout@v4
Syncing repository: lagamura/gitruff
Getting Git version info
Temporarily overriding HOME='/home/runner/work/_temp/d60449e8-18c9-4e31-8403-acd7f1ab76ca' before making global git config changes
Adding repository directory to the temporary git global config as a safe directory
/usr/bin/git config --global --add safe.directory /home/runner/work/gitruff/gitruff
Deleting the contents of '/home/runner/work/gitruff/gitruff'
Initializing the repository
Disabling automatic garbage collection
Setting up auth
Fetching the repository
Determining the checkout info
/usr/bin/git sparse-checkout disable
/usr/bin/git config --local --unset-all extensions.worktreeConfig
Checking out the ref
/usr/bin/git log -1 --format=%H
ae96f389bb63b95b777493781fb18e5e41f7f76b

And the absence of the .git directory changes how ignore (our crate to traverse directories) handles .gitignore files.

Is there any chance the two ruff versions are different? I see 0.11.2 in the original report, but I didn’t see a version in the logs. I could have missed it though.

We had a case recently where a CI workflow randomly picked an old version of a package, so that’s on my mind!

No, both versions are printed before the command:

ruff --version
ruff 0.11.2