diff --git a/.vale/.gitignore b/.vale/.gitignore index 9658b6fb34e..02190720aeb 100644 --- a/.vale/.gitignore +++ b/.vale/.gitignore @@ -1,3 +1,4 @@ +vale_*_* styles/* !styles/config/ !styles/Openverse/ diff --git a/.vale/download.sh b/.vale/download.sh new file mode 100755 index 00000000000..9b6ad2f7c1d --- /dev/null +++ b/.vale/download.sh @@ -0,0 +1,14 @@ +#!/bin/bash + +BIN_NAME="$1" +VERSION="3.7.1" +OS=$([ "$(uname)" = "Darwin" ] && echo "macOS" || echo "Linux") +ARCH=$([ "$(uname -m)" = "aarch64" ] || [ "$(uname -m)" = "arm64" ] && echo "arm64" || echo "64-bit") + +URL="https://github.com/errata-ai/vale/releases/download/v${VERSION}/vale_${VERSION}_${OS}_${ARCH}.tar.gz" + +echo "Downloading ${URL}" +curl --output vale.tar.gz --location "${URL}" +tar -xvzf "vale.tar.gz" vale +mv vale "${BIN_NAME}" +rm "vale.tar.gz" diff --git a/.vale/justfile b/.vale/justfile index d8d9331c540..e74863cd6f4 100644 --- a/.vale/justfile +++ b/.vale/justfile @@ -25,6 +25,7 @@ _files separator="\n": fi echo "$files" +VALE_BIN_NAME := "vale_" + os() + "_" + arch() VALE_STYLES_PATH := "/opt/.local/share/vale/styles" @_link_openverse_styles: @@ -34,9 +35,15 @@ VALE_STYLES_PATH := "/opt/.local/share/vale/styles" # Run Vale configured for Openverse. @run: _link_openverse_styles - # Ensure vale is available - pdm install + #!/usr/bin/env bash + # Download vale if not not found by which + if [ ! -f ./{{ VALE_BIN_NAME }} ]; then + echo "Downloading Vale" + ./download.sh {{ VALE_BIN_NAME }} + fi + + export VALE_STYLES_PATH={{ VALE_STYLES_PATH }} # 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 + ./{{ VALE_BIN_NAME }} sync # Run vale :) - VALE_STYLES_PATH={{ VALE_STYLES_PATH }} pdm run vale {{ "`just _files`" }} + ./{{ VALE_BIN_NAME }} {{ "`just _files`" }} diff --git a/.vale/pdm.lock b/.vale/pdm.lock deleted file mode 100644 index 66af9d68357..00000000000 --- a/.vale/pdm.lock +++ /dev/null @@ -1,22 +0,0 @@ -# This file is @generated by PDM. -# It is not intended for manual editing. - -[metadata] -groups = ["default"] -strategy = ["inherit_metadata"] -lock_version = "4.5.0" -content_hash = "sha256:a0a9239f1729ced61ee239a99bf78fffdf4a7c52fac089012c11b3e6efbf8e41" - -[[metadata.targets]] -requires_python = "==3.12.*" - -[[package]] -name = "vale" -version = "3.7.1.0" -requires_python = ">=3.7" -summary = "Install and use Vale (grammar & style check tool) in python environments." -groups = ["default"] -files = [ - {file = "vale-3.7.1.0-py3-none-any.whl", hash = "sha256:3d311c11cf7e7621bf048f0898734634273ab15109ea2474ce4fc6f8778be6c8"}, - {file = "vale-3.7.1.0.tar.gz", hash = "sha256:67e5474da8c3d438e0bc1f470d7d63d3d0080ad992e037dd33157536621738d1"}, -] diff --git a/.vale/pyproject.toml b/.vale/pyproject.toml deleted file mode 100644 index 64951919ff1..00000000000 --- a/.vale/pyproject.toml +++ /dev/null @@ -1,16 +0,0 @@ -[project] -name = "openverse-vale" -version = "0.0.0" -description = "Openverse Vale configuration" -authors = [ - {name = "Openverse Contributors", email = "openverse@wordpress.org"}, -] -dependencies = [ - "vale>=3.7.1.0", -] -requires-python = "==3.12.*" -readme = "README.md" -license = {text = "MIT"} - -[tool.pdm] -distribution = false diff --git a/docker/dev_env/Dockerfile b/docker/dev_env/Dockerfile index f661bf4795b..c2a6f7252d6 100644 --- a/docker/dev_env/Dockerfile +++ b/docker/dev_env/Dockerfile @@ -28,19 +28,22 @@ ENV PATH="${PNPM_BIN}:${N_PREFIX}/bin:${PDM_PYTHONS}:${HOME}/.local/bin:${PATH}" # Dependency explanations: # - git: required by some python package; contributors should use git on their host -# - perl: used in linting -# - gcc, g++: required by some pre-commit hooks for node-gyp +# - g++: required by some pre-commit hooks for node-gyp # - just: command runner # - jq: JSON processor # - which: locate a program file in `PATH` # - tree: list files in a tree +# - xdg-utils: added because Storybook wants to open in a browser +# - nodejs, npm: language runtime (does not include Corepack) # - python*: required by some Python libraries for compilation during installation -# - libffi*: required for the Python package cffi # - pipx: Python CLI app installer -# - nodejs: language runtime (includes npm but not Corepack) +# - libffi*: required for the Python package cffi # - docker*: used to interact with host Docker socket +# - unzip: used to extract zip files of visual regression patches from CI artifacts # - postgresql*: required to connect to PostgreSQL databases -# - k6: used for load testing +# +# System-specific dependencies: +# - k6: used for load testing (only installed on x86 architectures) # # pipx dependencies: # - httpie: CLI HTTP client @@ -51,10 +54,10 @@ ENV PATH="${PNPM_BIN}:${N_PREFIX}/bin:${PDM_PYTHONS}:${HOME}/.local/bin:${PATH}" # Node dependencies: # - n: Node.js distribution manager # - corepack: Node.js package-manager-manager -RUN mkdir /pipx \ +RUN mkdir -p $HOME/.local/bin \ + && mkdir /pipx \ && dnf5 -y install dnf-plugins-core \ && dnf5 -y config-manager addrepo --from-repofile=https://download.docker.com/linux/fedora/docker-ce.repo \ - && dnf5 -y install https://dl.k6.io/rpm/repo.rpm \ && dnf5 -y install \ git \ g++ \ @@ -64,12 +67,16 @@ RUN mkdir /pipx \ tree \ xdg-utils \ nodejs npm \ - python3.12 python3.12-devel pipx \ + python3.12 python3.12-devel \ + pipx \ libffi-devel \ docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin \ unzip \ postgresql postgresql-devel \ - k6 \ + && if [ "$(uname -m)" = "x86_64" ]; then \ + dnf5 -y install https://dl.k6.io/rpm/repo.rpm \ + && dnf5 -y install k6; \ + fi \ && dnf5 clean all \ && pipx install --global \ httpie \ diff --git a/docker/dev_env/hooks/pre-commit b/docker/dev_env/hooks/pre-commit old mode 100644 new mode 100755 diff --git a/docker/dev_env/hooks/pre-push b/docker/dev_env/hooks/pre-push old mode 100644 new mode 100755 diff --git a/docker/dev_env/run.sh b/docker/dev_env/run.sh index 48d35642736..4adcce196fa 100755 --- a/docker/dev_env/run.sh +++ b/docker/dev_env/run.sh @@ -26,9 +26,6 @@ shared_args=( run_args=( -d --name "$container_name" - # Since we have build an amd64 image, we must specify the platform to - # suppress warnings about platform mismatch. - --platform linux/amd64 # Use host network so things like Sphinx and the frontend that run directly in `ov` # will have ports available on the host (and this way we don't have to manually map each one) --network host diff --git a/ov b/ov index 29410dc0d3b..5141d474c1a 100755 --- a/ov +++ b/ov @@ -93,7 +93,7 @@ init) build) # k6 does not install on aarch64, so we must specify the platform on macOS. - docker build "${@:2}" --platform linux/amd64 -t openverse-dev_env:latest "$dev_env" + docker build "${@:2}" --tag openverse-dev_env:latest "$dev_env" ;; setup-env)