Skip to content

Commit

Permalink
Merge pull request ppy#10545 from cl8n/scripts-cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
TicClick authored Nov 26, 2023
2 parents b651dbd + 8188e2f commit 3daeb1d
Show file tree
Hide file tree
Showing 14 changed files with 56 additions and 133 deletions.
14 changes: 6 additions & 8 deletions .github/workflows/continuous-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,8 @@ jobs:
echo "${INTERESTING_FILES}" >> $GITHUB_ENV
echo "${DELIMITER}" >> $GITHUB_ENV
- name: inspect file sizes
shell: bash
run: |
readarray -t TARGET_FILES <<< "${{ env.INTERESTING_FILES }}"
bash scripts/ci/inspect_file_sizes.sh --target "${TARGET_FILES[@]}"
- name: check file sizes
run: meta/check-file-sizes.sh

- name: set up Node.js
id: setup-node
Expand All @@ -57,22 +54,23 @@ jobs:

- name: run remark on changed files
if: ${{ !contains(github.event.pull_request.body, 'SKIP_REMARK') }}
shell: bash
run: |
readarray -t REMARK_TARGET_FILES <<< $(
# ppy/osu-wiki#8867 -- disable style checks for non-article Markdown files, such as README.md
echo "${{ env.INTERESTING_FILES }}" | grep -e .md$ | grep -E -v '^[A-Z-]+\.md$' || true
)
bash scripts/ci/run_remark.sh --target "${REMARK_TARGET_FILES[@]}"
meta/remark.sh "${REMARK_TARGET_FILES[@]}"
- name: set up Python
uses: actions/setup-python@v4
with:
cache: pip
cache-dependency-path: scripts/requirements.txt
cache-dependency-path: requirements.txt
python-version: "3.11"

- name: set up Python CI dependencies
run: pip install -r scripts/requirements.txt
run: pip install -r requirements.txt

- name: run yamllint on .yaml and .md files
run: osu-wiki-tools check-yaml
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ RUN DEBIAN_FRONTEND=noninteractive apt-get install -y ca-certificates curl gnupg
DEBIAN_FRONTEND=noninteractive apt-get install -y nodejs

WORKDIR /osu-wiki
COPY package.json package-lock.json scripts/requirements.txt /osu-wiki/
COPY package.json package-lock.json requirements.txt /osu-wiki/

# Install osu-wiki tool dependencies
RUN npm install && npm install -g osu-wiki && pip3 install -r requirements.txt
Expand Down
23 changes: 23 additions & 0 deletions meta/check-file-sizes.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/bin/sh

set -eu

if test $# -eq 0; then
set -- news wiki
fi

error_files="$(find "$@" -type f -size +1000000c)"
warning_files="$(find "$@" -type f -size +500000c -size -1000001c)"

exec >&2

if test "$warning_files"; then
printf '\033[33mWarning:\033[m The following files are larger than 500kB and should be compressed if possible:\n'
printf %s "$warning_files" | sort | sed 's/^/ /'
fi

if test "$error_files"; then
printf '\033[31mError:\033[m The following files are larger than 1MB and must be compressed:\n'
printf %s "$error_files" | sort | sed 's/^/ /'
exit 1
fi
11 changes: 11 additions & 0 deletions meta/remark.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/sh

set -eu

reporter=@noomorph/vfile-reporter-position

if test "${GITHUB_ACTIONS:-}"; then
reporter=vfile-reporter-github-action
fi

npx remark -fq --color --no-stdout --report "$reporter" --silently-ignore "${@:-.}"
File renamed without changes.
5 changes: 3 additions & 2 deletions run-checks.sh
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,9 @@ function main() {

_build_container

_test_wrapper "file size" "_docker bash scripts/ci/inspect_file_sizes.sh --target" "${interesting_files}"
_test_wrapper "article style" "_docker bash scripts/ci/run_remark.sh --target" "${interesting_articles}"
# TODO give no arguments to check-file-sizes
_test_wrapper "file size" "_docker meta/check-file-sizes.sh" "${interesting_files}"
_test_wrapper "article style" "_docker meta/remark.sh" "${interesting_articles}"

_test_wrapper "YAML style" "_docker osu-wiki-tools check-yaml --target" .

Expand Down
56 changes: 0 additions & 56 deletions scripts/ci/inspect_file_sizes.sh

This file was deleted.

54 changes: 0 additions & 54 deletions scripts/ci/run_remark.sh

This file was deleted.

4 changes: 2 additions & 2 deletions wiki/osu!_wiki/Maintenance/de.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@ Nachstehend findest du eine Tabelle mit allen CI-Kontrollen in der richtigen Rei

| # | Prüfung | Tool | Erklärung | Umgehung |
| :-: | :-- | :-- | :-- | :-- |
| 1 | Dateigrößen | [`scripts/ci/inspect_file_sizes.sh`](https://github.com/ppy/osu-wiki/blob/master/scripts/ci/inspect_file_sizes.sh) | Ob eine Bilddatei unter dem [Dateigrößenlimit für Newsbeiträge und Wikiartikel](/wiki/Article_styling_criteria/Formatting#dateigröße) ist (1 MB). Gibt eine Warnung für Dateien über 0,5 MB. | Keine. |
| 2 | Markdown | [remark](https://github.com/remarkjs/remark) mit [`scripts/ci/run_remark.sh`](https://github.com/ppy/osu-wiki/blob/master/scripts/ci/run_remark.sh) | Ob die Markdown-Syntax in Wikiartikeln und Newsbeiträgen korrekt und einheitlich ist. | Füge `<!-- lint ignore Regel -->` über der beanstandeten Zeile ein, wobei `Regel` die Regel ist, die ignoriert werden soll. |
| 1 | Dateigrößen | [`meta/check-file-sizes.sh`](https://github.com/ppy/osu-wiki/blob/master/meta/check-file-sizes.sh) | Ob eine Bilddatei unter dem [Dateigrößenlimit für Newsbeiträge und Wikiartikel](/wiki/Article_styling_criteria/Formatting#dateigröße) ist (1 MB). Gibt eine Warnung für Dateien über 0,5 MB. | Keine. |
| 2 | Markdown | [remark](https://github.com/remarkjs/remark) mit [`meta/remark.sh`](https://github.com/ppy/osu-wiki/blob/master/meta/remark.sh) | Ob die Markdown-Syntax in Wikiartikeln und Newsbeiträgen korrekt und einheitlich ist. | Füge `<!-- lint ignore Regel -->` über der beanstandeten Zeile ein, wobei `Regel` die Regel ist, die ignoriert werden soll. |
| 3 | YAML | Befehl `check-yaml` aus [`osu-wiki-tools`](https://github.com/Walavouchey/osu-wiki-tools) | Ob die YAML-Syntax in der Datei [`redirect.yaml`](https://github.com/ppy/osu-wiki/blob/master/wiki/redirect.yaml) und in der [Titelsektion](/wiki/Article_styling_criteria/Formatting#titelsektion) korrekt und einheitlich ist. | Keine. |
| 4 | Kaputte Wiki-Links | Befehl `check-links` aus [`osu-wiki-tools`](https://github.com/Walavouchey/osu-wiki-tools) | Ob interne [Wiki-Links](/wiki/Article_styling_criteria/Formatting#wiki-links) auf einen tatsächlichen Artikel, Newsbeitrag (für Newsbeitrag-Links) oder einen Abschnitt davon zeigen. | Füge `SKIP_WIKILINK_CHECK` irgendwo zur Beschreibung des Änderungsvorschlags hinzu. |
| 5 | Nicht mehr aktuelle Übersetzungen | Befehl `check-outdated-articles` aus [`osu-wiki-tools`](https://github.com/Walavouchey/osu-wiki-tools) | Ob Übersetzungen korrekt als [nicht mehr aktuell gekennzeichnet](/wiki/Article_styling_criteria/Formatting#nicht-mehr-aktuelle-übersetzungen) werden, wenn ein englischer Artikel aktualisiert wird. | Füge `SKIP_OUTDATED_CHECK` irgendwo zur Beschreibung des Änderungsvorschlags hinzu. |
Expand Down
4 changes: 2 additions & 2 deletions wiki/osu!_wiki/Maintenance/en.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ For reference, below is a table of all CI checks in order:

| # | Check | Tool | Explanation | Bypass |
| :-: | :-- | :-- | :-- | :-- |
| 1 | File sizes | [`scripts/ci/inspect_file_sizes.sh`](https://github.com/ppy/osu-wiki/blob/master/scripts/ci/inspect_file_sizes.sh) | Whether an image file is below the [news post and wiki article image file size limit](/wiki/Article_styling_criteria/Formatting#file-size) (1 MB). Gives a warning for files above 0.5 MB. | None. |
| 2 | Markdown | [remark](https://github.com/remarkjs/remark) via [`scripts/ci/run_remark.sh`](https://github.com/ppy/osu-wiki/blob/master/scripts/ci/run_remark.sh) | Whether Markdown syntax is correct and consistent in wiki articles and news posts. | Add `SKIP_REMARK` anywhere in the pull request description. To permanently suppress a specific error, add `<!-- lint ignore rule-name -->` above the offending line, where `rule-name` is the rule to ignore. |
| 1 | File sizes | [`meta/check-file-sizes.sh`](https://github.com/ppy/osu-wiki/blob/master/meta/check-file-sizes.sh) | Whether an image file is below the [news post and wiki article image file size limit](/wiki/Article_styling_criteria/Formatting#file-size) (1 MB). Gives a warning for files above 0.5 MB. | None. |
| 2 | Markdown | [remark](https://github.com/remarkjs/remark) via [`meta/remark.sh`](https://github.com/ppy/osu-wiki/blob/master/meta/remark.sh) | Whether Markdown syntax is correct and consistent in wiki articles and news posts. | Add `SKIP_REMARK` anywhere in the pull request description. To permanently suppress a specific error, add `<!-- lint ignore rule-name -->` above the offending line, where `rule-name` is the rule to ignore. |
| 3 | YAML | `check-yaml` command of [`osu-wiki-tools`](https://github.com/Walavouchey/osu-wiki-tools) | Whether YAML syntax is correct and consistent in the [`redirect.yaml`](https://github.com/ppy/osu-wiki/blob/master/wiki/redirect.yaml) file and in [front matter](/wiki/Article_styling_criteria/Formatting#front-matter) | None. |
| 4 | Broken wiki links | `check-links` command of [`osu-wiki-tools`](https://github.com/Walavouchey/osu-wiki-tools) | Whether internal [wiki links](/wiki/Article_styling_criteria/Formatting#wiki-links) point to an actual article, news post (for news post links), or section thereof. | Add `SKIP_WIKILINK_CHECK` anywhere in the pull request description. |
| 5 | Outdated translations | `check-outdated-articles` command of [`osu-wiki-tools`](https://github.com/Walavouchey/osu-wiki-tools) | Whether translations are properly [marked as outdated](/wiki/Article_styling_criteria/Formatting#outdated-translations) when updating an English article. | Add `SKIP_OUTDATED_CHECK` anywhere in the pull request description. |
Expand Down
4 changes: 2 additions & 2 deletions wiki/osu!_wiki/Maintenance/es.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ A modo de referencia, a continuación se muestra una tabla de todas las comproba

| # | Comprobación | Herramienta | Explicación | Saltar |
| :-: | :-- | :-- | :-- | :-- |
| 1 | Tamaño de archivo | [`scripts/ci/inspect_file_sizes.sh`](https://github.com/ppy/osu-wiki/blob/master/scripts/ci/inspect_file_sizes.sh) | Si un archivo de imagen está por debajo del [límite de tamaño de archivo de imagen de las publicaciones de noticias y artículos de la wiki](/wiki/Article_styling_criteria/Formatting#tamaño-del-archivo) (1 MB). Da una advertencia para los archivos de más de 0.5 MB. | Ninguno. |
| 2 | Markdown | [remark](https://github.com/remarkjs/remark) a través de [`scripts/ci/run_remark.sh`](https://github.com/ppy/osu-wiki/blob/master/scripts/ci/run_remark.sh) | Si la sintaxis de Markdown es correcta y consistente en artículos de la wiki y publicaciones de noticias. | Agregue `<!-- lint ignore rule-name -->` encima de la línea ofensiva, donde `rule-name` es la regla a ignorar. |
| 1 | Tamaño de archivo | [`meta/check-file-sizes.sh`](https://github.com/ppy/osu-wiki/blob/master/meta/check-file-sizes.sh) | Si un archivo de imagen está por debajo del [límite de tamaño de archivo de imagen de las publicaciones de noticias y artículos de la wiki](/wiki/Article_styling_criteria/Formatting#tamaño-del-archivo) (1 MB). Da una advertencia para los archivos de más de 0.5 MB. | Ninguno. |
| 2 | Markdown | [remark](https://github.com/remarkjs/remark) a través de [`meta/remark.sh`](https://github.com/ppy/osu-wiki/blob/master/meta/remark.sh) | Si la sintaxis de Markdown es correcta y consistente en artículos de la wiki y publicaciones de noticias. | Agregue `<!-- lint ignore rule-name -->` encima de la línea ofensiva, donde `rule-name` es la regla a ignorar. |
| 3 | YAML | Comando `check-yaml` de [`osu-wiki-tools`](https://github.com/Walavouchey/osu-wiki-tools) | Si la sintaxis de YAML es correcta y coherente en el archivo [`redirect.yaml`](https://github.com/ppy/osu-wiki/blob/master/wiki/redirect.yaml) y en el [formato de serialización](/wiki/Article_styling_criteria/Formatting#formato-de-serialización) | Ninguno. |
| 4 | Enlaces de la wiki rotos | Comando `check-links` de [`osu-wiki-tools`](https://github.com/Walavouchey/osu-wiki-tools) | Si los [enlaces de la wiki](/wiki/Article_styling_criteria/Formatting#enlaces-de-la-wiki) internos apuntan a un artículo real, una publicación de noticias (para enlaces de publicaciones de noticias) o una sección del mismo. | Agregue `SKIP_WIKILINK_CHECK` en cualquier lugar de la descripción de la solicitud de cambios. |
| 5 | Traducciones obsoletas | Comando `check-outdated-articles` de [`osu-wiki-tools`](https://github.com/Walavouchey/osu-wiki-tools) | Si las traducciones [se marcan como obsoletas](/wiki/Article_styling_criteria/Formatting#traducciones-obsoletas) correctamente al actualizar un artículo en inglés. | Agregue `SKIP_OUTDATED_CHECK` en cualquier lugar de la descripción de la solicitud de cambios. |
Expand Down
4 changes: 2 additions & 2 deletions wiki/osu!_wiki/Maintenance/fr.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@ Pour référence, vous trouverez ci-dessous un tableau de toutes les CI checks d

| # | Check | Outil | Explication | Contournement |
| :-: | :-- | :-- | :-- | :-- |
| 1 | Tailles de fichiers | [`scripts/ci/inspect_file_sizes.sh`](https://github.com/ppy/osu-wiki/blob/master/scripts/ci/inspect_file_sizes.sh) | Indique si une image est inférieur à la [limite de taille des images des news post et des articles du wiki](/wiki/Article_styling_criteria/Formatting#taille-du-fichier) (1 MB). Donne un avertissement pour les fichiers supérieurs à 0,5 Mo. | Aucun. |
| 2 | Markdown | [remark](https://github.com/remarkjs/remark) via [`scripts/ci/run_remark.sh`](https://github.com/ppy/osu-wiki/blob/master/scripts/ci/run_remark.sh) | Vérifie si la syntaxe Markdown est correcte et cohérente dans les articles du wiki et les articles de news. | Ajouter `<!-- lint ignore rule-name -->` au-dessus de la ligne incriminée, où `rule-name` est la règle à ignorer. |
| 1 | Tailles de fichiers | [`meta/check-file-sizes.sh`](https://github.com/ppy/osu-wiki/blob/master/meta/check-file-sizes.sh) | Indique si une image est inférieur à la [limite de taille des images des news post et des articles du wiki](/wiki/Article_styling_criteria/Formatting#taille-du-fichier) (1 MB). Donne un avertissement pour les fichiers supérieurs à 0,5 Mo. | Aucun. |
| 2 | Markdown | [remark](https://github.com/remarkjs/remark) via [`meta/remark.sh`](https://github.com/ppy/osu-wiki/blob/master/meta/remark.sh) | Vérifie si la syntaxe Markdown est correcte et cohérente dans les articles du wiki et les articles de news. | Ajouter `<!-- lint ignore rule-name -->` au-dessus de la ligne incriminée, où `rule-name` est la règle à ignorer. |
| 3 | YAML | La commande `check-yaml` de [`osu-wiki-tools`](https://github.com/Walavouchey/osu-wiki-tools) | Vérifie si la syntaxe YAML est correcte et cohérente dans le fichier [`redirect.yaml`](https://github.com/ppy/osu-wiki/blob/master/wiki/redirect.yaml) et dans la [page de garde](/wiki/Article_styling_criteria/Formatting#page-de-garde) | Aucun. |
| 4 | Liens wiki cassés | La commande `check-links` de [`osu-wiki-tools`](https://github.com/Walavouchey/osu-wiki-tools) | Vérifie si les [liens wiki](/wiki/Article_styling_criteria/Formatting#liens-wiki) internes pointent vers un article du wiki, un article de news (pour les liens d'articles de news), ou une section de celui-ci. | Ajouter `SKIP_WIKILINK_CHECK` n'importe où dans la description de la pull request. |
| 5 | Traductions obsolètes | La commande `check-outdated-articles` de [`osu-wiki-tools`](https://github.com/Walavouchey/osu-wiki-tools) | Vérifie si les traductions sont correctement [marquées comme obsolètes](/wiki/Article_styling_criteria/Formatting#articles-obsolètes) lors de la mise à jour d'un article en anglais. | Ajouter `SKIP_OUTDATED_CHECK` n'importe où dans la description de la pull request. |
Expand Down
Loading

0 comments on commit 3daeb1d

Please sign in to comment.