Skip to content

Commit

Permalink
Remove codeowners validator from pre-commit (#3762)
Browse files Browse the repository at this point in the history
The docker image has issues running on arm64, so we will instead run it in CI using the GitHub action, with an utility just recipe to run the same checks locally as needed
  • Loading branch information
sarayourfriend authored Feb 7, 2024
1 parent 5475c78 commit dcbee23
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 11 deletions.
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

0 comments on commit dcbee23

Please sign in to comment.