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

Update to Vale 3 and refactor setup in light of ov #4866

Merged
merged 2 commits into from
Sep 9, 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
4 changes: 2 additions & 2 deletions .github/workflows/ci_cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,8 @@ jobs:
- name: Setup CI env
uses: ./.github/actions/setup-env
with:
# No Python setup is needed, the built-in Python runtime is okay.
setup_python: false
# PDM is needed to run Vale
setup_python: "true"
# Node.js is needed by lint actions.
install_recipe: "node-install"

Expand Down
2 changes: 1 addition & 1 deletion .vale/.gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
styles/*
!styles/Vocab/
!styles/config/
!styles/Openverse/
2 changes: 0 additions & 2 deletions .vale/.vale.ini
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
StylesPath = styles

MinAlertLevel = suggestion
Vocab = Openverse
# Using an explicit reference to downloads for package zips rather than the shorthand allows us to
Expand Down
10 changes: 0 additions & 10 deletions .vale/Dockerfile

This file was deleted.

23 changes: 12 additions & 11 deletions .vale/README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
# Openverse Vale configuration

Openverse runs Vale using Docker. This bypasses the need for contributors to
install the Vale binary on their computers. It also prevents Vale styles getting
downloaded into the repository in clear text, which is critical to avoid lists
of sensitive terms being accidentally too-easily available.
Openverse runs Vale using
[Vale's PyPI distribution](https://pypi.org/project/vale/). This allows our Vale
version to be tracked in this directory's `pyproject.toml`, meaning tools like
Renovate will be aware of and update it automatically.

This approach to running Vale is intended specifically for running inside `ov`,
and will likely not work outside `ov`. Synced styles are kept in `ov`'s `opt`
directory, which prevents downloaded styles from appearing within the project
files on a contributor's computer.

For more information about this motivation to avoid lists of sensitive terms in
the Openverse monorepo, refer to the README at
Expand All @@ -15,15 +20,11 @@ To run Vale with Openverse's configuration, use the just recipe:
ov just .vale/run
```

This recipe _always_ builds Vale. The Openverse Vale docker image is fast to
build, and the most expensive steps are cached. Docker will automatically reuse
the pre-existing image unless there are changes to the Vale configuration.

Typically it is unnecessary to run Vale directly, as pre-commit automatically
Typically, it is unnecessary to run Vale directly, as pre-commit automatically
runs Vale on each commit. You only need to run Vale directly when iterating on
changes to Openverse's Vale configuration.

Refer to the `VALE_FILES` variable [in the justfile](./justfile) to identify
which files we currently check with Vale. A comment on the variable explains the
Refer to the `_files` recipe [in the `justfile`](./justfile) to identify which
files we currently check with Vale. A comment on the recipe explains the
rationale for that choice. The list of files will ideally expand in the future
to include all textual content in the repository.
33 changes: 17 additions & 16 deletions .vale/justfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,35 +7,36 @@ NO_COLOR := "\\033[0m"
printf "===================={{ NO_COLOR }}\n"
just --list --unsorted

# Build a local version of `openverse-vale:local` for testing
build:
docker build . -t openverse-vale:local

IGNORE_FILES_PATTERN := ".pnpm|changelogs|projects/proposals|node_modules|.?venv"

# This recipe generates a list of Markdown and MDX files to be processed, excluding those
# matched by the IGNORE_FILES_PATTERN. Files are listed relative to the parent directory
# of the current working directory. If a custom separator is specified, newlines are
# replaced with this separator before outputting the file list.
@files separator="\n":
_files separator="\n":
#! /usr/bin/env sh
files=$(
find "$PWD/.." -type f \( -name "*.md" -o -name "*.mdx" \) \
| grep -vE "{{ IGNORE_FILES_PATTERN }}" \
| sed "s|$PWD/../||"
| grep -vE "{{ IGNORE_FILES_PATTERN }}"
)
if [ '{{ separator }}' != '\n' ]; then
echo "$files" | tr '\n' '{{ separator }}'
exit 0
fi
echo "$files"

# Run Vale configured for Openverse in Docker.
# Using Docker avoids the need for contributors to install the Vale binary.
#Configuration defaults to what is used for CI.
run: build
docker run --rm \
-v $PWD/..:/src:rw,Z \
--workdir=/src \
openverse-vale:local \
{{ "`just files`" }}
VALE_STYLES_PATH := "/opt/.local/share/vale/styles"

@_link_openverse_styles:
mkdir -p {{ VALE_STYLES_PATH }}
[ ! -L {{ VALE_STYLES_PATH }}/config ] && ln -s "$(pwd)"/styles/config {{ VALE_STYLES_PATH }}/config || true
[ ! -L {{ VALE_STYLES_PATH }}/Openverse ] && ln -s "$(pwd)"/styles/Openverse {{ VALE_STYLES_PATH }}/Openverse || true

# Run Vale configured for Openverse.
@run: _link_openverse_styles
# Ensure vale is available
pdm install
# Sync to make sure styles are up to date (this is fast if they are already synced)
VALE_STYLES_PATH={{ VALE_STYLES_PATH }} pdm run vale sync
# Run vale :)
VALE_STYLES_PATH={{ VALE_STYLES_PATH }} pdm run vale {{ "`just _files`" }}
22 changes: 22 additions & 0 deletions .vale/pdm.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 16 additions & 0 deletions .vale/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
[project]
name = "openverse-vale"
version = "0.0.0"
description = "Openverse Vale configuration"
authors = [
{name = "Openverse Contributors", email = "[email protected]"},
]
dependencies = [
"vale>=3.7.1.0",
]
requires-python = "==3.12.*"
readme = "README.md"
license = {text = "MIT"}

[tool.pdm]
distribution = false
3 changes: 0 additions & 3 deletions .vale/styles/Vocab/Openverse/accept.txt

This file was deleted.

2 changes: 2 additions & 0 deletions .vale/styles/config/vocabularies/Openverse/accept.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Decision-Making Process
decision-making process
2 changes: 1 addition & 1 deletion documentation/meta/decision_making/index.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Openverse Decision-Making Process
# Openverse decision-making process

This process is loosely based on the Sociocratic "consent decision-making"
model, but is heavily adapted for an asynchronous context. The purpose of this
Expand Down