mszostok/codeowners-validator

File Exist Checker fails on valid relative paths checked in all directories by CODEOWNERS

Opened this issue · 3 comments

First of all thank you for this tool, it helped me fixed CODEOWNERS for https://github.com/godotengine/godot
Turns out that review-requests don't work for teams without Write permission for some reason (as if a review from someone not able to press "Merge" is not valid), but your tool caught it + more issues :)

Version
0.6.0, installed in ./bin with curl instructions.

Description

There seems to be a false positive report from the File Exist Checker when using relative paths which are then checked in all directories by CODEOWNERS.
What I mean is what is described here: https://docs.github.com/en/github/creating-cloning-and-archiving-repositories/about-code-owners#codeowners-syntax

# In this example, @octocat owns any file in an apps directory
# anywhere in your repository.
apps/ @octocat

This will successfully match apps/ directories in any directory of the repository, even if there's no apps/ directory in the root.
But codeowners-validator issues a warning about this case.

Expected result
No warning if any nested directory matches the pattern.

Actual result

==> Executing File Exist Checker (45.227677ms)
    [err] line 11: "SCsub" does not match any files in repository
    [err] line 23: "doc_classes/*" does not match any files in repository

Yet:

$ find -type f -name SCsub | wc -l
124
$ find -type d -name doc_classes | wc -l
19

(This is on https://github.com/godotengine/godot/)

Steps to reproduce

Troubleshooting
n/a

Hi @akien-mga

Thank you for getting in touch!

First what you can do is to disable the file checker. As a result, you can benefit from other checks.

env REPOSITORY_PATH="." \
    CHECKS="owners,syntax,duppatterns" \
    OWNER_CHECKER_REPOSITORY="godotengine/godot" \
  ./bin/codeowners-validator

or with GitHub Action:

name: codeowners-validator

on:
  schedule:
    # Runs at 08:00 UTC every day
    - cron:  '0 8 * * *'
  workflow_dispatch:

jobs:
  sanity:
    runs-on: ubuntu-latest
    steps:
      # Checks-out your repository, which is validated in the next step
      - uses: actions/checkout@v2
      - name: GitHub CODEOWNERS Validator
        uses: mszostok/codeowners-validator@v0.6.0
        with:
          checks: "owners,duppatterns,syntax" # `files` check not specified 
          experimental_checks: "notowned"
          # GitHub access token is required only if the `owners` check is enabled
          github_access_token: "${{ secrets.OWNERS_VALIDATOR_GITHUB_SECRET }}"

In the meantime I will check implementation and I will ping you when new version with fix will be available :)

Thanks :) I did use the other checks successfully, so I'm just reporting this as a false positive but it's in no way blocking.

@mszostok this same issue affects files as well as directories, if that affects the implementation of the fix. For example if I have:

conftest.py  @octocat

GitHub will match the pattern against any conftest.py in the repo, but the file checker will only pass if I have a conftest.py in my repo root.