Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove codeowners validator from pre-commit #3762

Merged
merged 1 commit into from
Feb 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions .github/workflows/ci_cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,19 @@ jobs:
just precommit
just lint

validate-codeowners:
name: Validate CODEOWNERS
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v4

- uses: mszostok/[email protected]
with:
checks: "files,duppatterns,syntax"
experimental_checks: "notowned,avoid-shadowing"

add-stack-label:
name: Add stack label
if: |
Expand Down
11 changes: 0 additions & 11 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -157,14 +157,3 @@ repos:
- id: renovate-config-validator
args:
- --strict

- repo: local
hooks:
- id: codeowners-validator
name: CODEOWNERS validator
language: docker_image
pass_filenames: false
entry: >
-e REPOSITORY_PATH="."
-e CHECKS="files,duppatterns,syntax"
ghcr.io/mszostok/codeowners-validator:v0.7.4
25 changes: 25 additions & 0 deletions documentation/meta/ci_cd/jobs/preparation.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,31 @@ Runs the linting steps defined in the repository's
[pre-commit configuration](https://github.com/WordPress/openverse/blob/main/.pre-commit-config.yaml).
This is executed via `just lint`.

## `validate-codeowners`

This job should be considered a complement to `lint` and would ideally be part
of it, as a pre-commit hook. However, the docker image we relied on for the
pre-commit hook causes issues with arm64 computers (which includes recent Apply
devices). Therefore, we run the hook as a CI step instead.

It is still possible to run this hook locally, assuming the docker image works
on your computer's architecture, by invoking the `lint-codeowners` just recipe:

```bash
just lint-codeowners
```

````{tip}
In CI we run the set of "experimental" checks as well, which are disabled
in the just recipe because they fail if there are uncommitted changes.
To run precisely the check that CI uses, enable experimental checks:

```bash
just lint-codeowners all
```

````

## `add-stack-label`

```{note}
Expand Down
11 changes: 11 additions & 0 deletions justfile
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,17 @@ precommit:
lint hook="" *files="": precommit
python3 pre-commit.pyz run {{ hook }} {{ if files == "" { "--all-files" } else { "--files" } }} {{ files }}

# Run codeowners validator locally. Only enable experimental hooks if there are no uncommitted changes.
lint-codeowners checks="stable":
docker run --rm \
-u 1000:1000 \
-v $PWD:/src:rw,Z \
--workdir=/src \
-e REPOSITORY_PATH="." \
-e CHECKS="files,duppaterns,syntax" \
{{ if checks != "stable" { "-e EXPERIMENTAL_CHECKS='notowned,avoid-shadowing'" } else { "" } }} \
ghcr.io/mszostok/codeowners-validator:v0.7.4

########
# Init #
########
Expand Down
Loading