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

fix(check_redirects): make the checks fail fast #7226

Merged
merged 2 commits into from
Nov 7, 2022

Conversation

OnkarRuikar
Copy link
Contributor

Summary

Wrapping original error and failing at the end, after all the checks are done, makes it hard to figure out what went wrong.
Refer mdn/translated-content#8171 (comment)

Problem

The check run https://github.com/mdn/translated-content/actions/runs/3114446745/jobs/5050295335 failed with following log:

Run yarn content validate-redirects --strict
yarn run v1.22.19
$ env-cmd --silent cross-env CONTENT_ROOT=files yari-tool validate-redirects --strict
Skipping: non en-us locale: /en-US/docs/Secciones_y_contornos_de_un_documento_HTML5	/es/docs/Sections_and_Outlines_of_an_HTML5_document
Skipping: non en-us locale: /en-US/docs/Web/API/WebGL_API/Getting_started_with_WebGL/Commencer_avec_le_WebGL	/fr/docs/Web/API/WebGL_API/Tutorial/Commencer_avec_WebGL
Skipping: non en-us locale: /en-US/docs/Web/API/WebGL_API/Tutorial/Getting_started_with_WebGL/Commencer_avec_le_WebGL	/fr/docs/Web/API/WebGL_API/Tutorial/Commencer_avec_WebGL
Skipping: non en-us locale: /en-US/docs/Web/WebGL/Getting_started_with_WebGL/Commencer_avec_le_WebGL	/fr/docs/Web/API/WebGL_API/Tutorial/Commencer_avec_WebGL
Skipping: non en-us locale: /en-US/docs/WebGL/Getting_started_with_WebGL/Commencer_avec_le_WebGL	/fr/docs/Web/API/WebGL_API/Tutorial/Commencer_avec_WebGL
Skipping: non en-us locale: /en-US/docs/video	/es/docs/Web/HTML/Elemento/video
Skipping: non en-us locale: /en-US/docs/zh-n/JavaScript/Reference/Global_Objects/String/quote	/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/String/quote
info: ✓ redirects for en-us looking good!
Skipping: non es locale: /es/docs/Web/JavaScript/Guide/Obsolete_Pages/The_Employee_Example	/en-US/docs/Web/JavaScript/Guide/Details_of_the_Object_Model
removing orphaned redirect (from exists): /es/docs/Web/JavaScript/Reference/Global_Objects/WeakMap/clear	/es/docs/conflicting/Web/JavaScript/Reference/Deprecated_and_obsolete_features
removing orphaned redirect (from exists): /es/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly	/es/docs/WebAssembly/JavaScript_interface
info: _redirects.txt for es is causing issues: Error: Invalid redirect for /es/docs/Web/JavaScript/Reference/Global_Objects/WeakMap/clear -> /es/docs/conflicting/Web/JavaScript/Reference/Deprecated_and_obsolete_features or /es/docs/Web/JavaScript/Reference/Global_Objects/null -> /es/docs/Web/JavaScript/Reference/Operators/null
info: ✓ redirects for fr looking good!
info: ✓ redirects for ja looking good!
info: ✓ redirects for ko looking good!
info: ✓ redirects for pt-br looking good!
info: ✓ redirects for ru looking good!
info: ✓ redirects for zh-cn looking good!
Skipping: non zh-tw locale: /zh-TW/docs/Web/API/Detecting_device_orientation	/en-US/docs/Web/Events/Detecting_device_orientation
Skipping: non zh-tw locale: /zh-TW/docs/WebAPI/Detecting_device_orientation	/en-US/docs/Web/Events/Detecting_device_orientation
info: ✓ redirects for zh-tw looking good!

error: 🔥 Errors loading redirects 🔥

error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
Error: Process completed with exit code 1.

There are no colors in GitHub's run logs.
The log before the error 🔥 Errors loading redirects 🔥 message said all went well: info: ✓ redirects for zh-tw looking good!.
So the PR author failed to figure out what actually went wrong:

chat

Solution

Fail fast: we do not have to continue checking remaining locales if one fails.
Fail on the spot: delaying the reporting makes it hard to figure out what and where is went wrong.


Screenshots

Before

❯ yarn tool validate-redirects --strict
yarn run v1.22.19
$ ts-node tool/cli.ts validate-redirects --strict
Skipping: non en-us locale: /en-US/docs/Secciones_y_contornos_de_un_documento_HTML5     /es/docs/Sections_and_Outlines_of_an_HTML5_document
Skipping: non en-us locale: /en-US/docs/Web/API/WebGL_API/Getting_started_with_WebGL/Commencer_avec_le_WebGL    /fr/docs/Web/API/WebGL_API/Tutorial/Commencer_avec_WebGL
Skipping: non en-us locale: /en-US/docs/Web/API/WebGL_API/Tutorial/Getting_started_with_WebGL/Commencer_avec_le_WebGL   /fr/docs/Web/API/WebGL_API/Tutorial/Commencer_avec_WebGL
Skipping: non en-us locale: /en-US/docs/Web/WebGL/Getting_started_with_WebGL/Commencer_avec_le_WebGL    /fr/docs/Web/API/WebGL_API/Tutorial/Commencer_avec_WebGL
Skipping: non en-us locale: /en-US/docs/WebGL/Getting_started_with_WebGL/Commencer_avec_le_WebGL        /fr/docs/Web/API/WebGL_API/Tutorial/Commencer_avec_WebGL
Skipping: non en-us locale: /en-US/docs/video   /es/docs/Web/HTML/Elemento/video
Skipping: non en-us locale: /en-US/docs/zh-n/JavaScript/Reference/Global_Objects/String/quote   /zh-CN/docs/Web/JavaScript/Reference/Global_Objects/String/quote
info: ✓ redirects for en-us looking good!
Skipping: non es locale: /es/docs/Web/JavaScript/Guide/Obsolete_Pages/The_Employee_Example      /en-US/docs/Web/JavaScript/Guide/Details_of_the_Object_Model
removing orphaned redirect (from exists): /es/docs/Web/JavaScript/Reference/Global_Objects/WeakMap/clear        /es/docs/conflicting/Web/JavaScript/Reference/Deprecated_and_obsolete_features
removing orphaned redirect (from exists): /es/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly  /es/docs/WebAssembly/JavaScript_interface
info: _redirects.txt for es is causing issues: Error: Invalid redirect for /es/docs/Web/JavaScript/Reference/Global_Objects/WeakMap/clear -> /es/docs/conflicting/Web/JavaScript/Reference/Deprecated_and_obsolete_features or /es/docs/Web/JavaScript/Reference/Global_Objects/null -> /es/docs/Web/JavaScript/Reference/Operators/null
info: ✓ redirects for fr looking good!
info: ✓ redirects for ja looking good!
info: ✓ redirects for ko looking good!
info: ✓ redirects for pt-br looking good!
info: ✓ redirects for ru looking good!
info: ✓ redirects for zh-cn looking good!
Skipping: non zh-tw locale: /zh-TW/docs/Web/API/Detecting_device_orientation    /en-US/docs/Web/Events/Detecting_device_orientation
Skipping: non zh-tw locale: /zh-TW/docs/WebAPI/Detecting_device_orientation     /en-US/docs/Web/Events/Detecting_device_orientation
info: ✓ redirects for zh-tw looking good!

error: 🔥 Errors loading redirects 🔥

error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

After

❯ yarn tool validate-redirects --strict
yarn run v1.22.19
$ ts-node tool/cli.ts validate-redirects --strict
Skipping: non en-us locale: /en-US/docs/Secciones_y_contornos_de_un_documento_HTML5     /es/docs/Sections_and_Outlines_of_an_HTML5_document
Skipping: non en-us locale: /en-US/docs/Web/API/WebGL_API/Getting_started_with_WebGL/Commencer_avec_le_WebGL    /fr/docs/Web/API/WebGL_API/Tutorial/Commencer_avec_WebGL
Skipping: non en-us locale: /en-US/docs/Web/API/WebGL_API/Tutorial/Getting_started_with_WebGL/Commencer_avec_le_WebGL   /fr/docs/Web/API/WebGL_API/Tutorial/Commencer_avec_WebGL
Skipping: non en-us locale: /en-US/docs/Web/WebGL/Getting_started_with_WebGL/Commencer_avec_le_WebGL    /fr/docs/Web/API/WebGL_API/Tutorial/Commencer_avec_WebGL
Skipping: non en-us locale: /en-US/docs/WebGL/Getting_started_with_WebGL/Commencer_avec_le_WebGL        /fr/docs/Web/API/WebGL_API/Tutorial/Commencer_avec_WebGL
Skipping: non en-us locale: /en-US/docs/video   /es/docs/Web/HTML/Elemento/video
Skipping: non en-us locale: /en-US/docs/zh-n/JavaScript/Reference/Global_Objects/String/quote   /zh-CN/docs/Web/JavaScript/Reference/Global_Objects/String/quote
info: ✓ redirects for en-us looking good!
Skipping: non es locale: /es/docs/Web/JavaScript/Guide/Obsolete_Pages/The_Employee_Example      /en-US/docs/Web/JavaScript/Guide/Details_of_the_Object_Model
removing orphaned redirect (from exists): /es/docs/Web/JavaScript/Reference/Global_Objects/WeakMap/clear        /es/docs/conflicting/Web/JavaScript/Reference/Deprecated_and_obsolete_features
removing orphaned redirect (from exists): /es/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly  /es/docs/WebAssembly/JavaScript_interface

error: _redirects.txt for es is causing issues: Error: Invalid redirect for /es/docs/Web/JavaScript/Reference/Global_Objects/WeakMap/clear -> /es/docs/conflicting/Web/JavaScript/Reference/Deprecated_and_obsolete_features or /es/docs/Web/JavaScript/Reference/Global_Objects/null -> /es/docs/Web/JavaScript/Reference/Operators/null


error: 🔥 Errors loading redirects 🔥

error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.


How did you test this change?

In terminal using command yarn tool validate-redirects --strict

@OnkarRuikar
Copy link
Contributor Author

Ping @caugner

Copy link
Contributor

@caugner caugner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the checks fail fast, doesn't this mean that only the first error will be displayed?

Alternatively, could we make sure that all output is prefixed with either info: or error: , and additionally prefix the error messages with ❌ to make them easier to discover? (Likewise, skipping could have ➖.)

@caugner caugner removed the request for review from fiji-flo October 20, 2022 18:47
@OnkarRuikar
Copy link
Contributor Author

If the checks fail fast, doesn't this mean that only the first error will be displayed?

If a locale has error(s) it'll be processed but remaining locales after it won't be processed.
This shouldn't matter as hardly any PR works on files of multiple locales, because code owners/reviewers are different for each locale. Major change like rename/delete files certainly happens separately for each locale.

We shouldn't keep the feature (of gathering errors) for that very rare PR. Unless I am missing any historical context, in such case, the contributor will not hesitate to fix redirection errors one by one for each locale.

Copy link
Contributor

@caugner caugner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alright, let's stick with throwing, but then we can throw the specific error message directly.

tool/cli.ts Outdated Show resolved Hide resolved
tool/cli.ts Outdated Show resolved Hide resolved
@OnkarRuikar
Copy link
Contributor Author

After applying the changes:

❯ yarn tool validate-redirects --strict
yarn run v1.22.19
$ ts-node tool/cli.ts validate-redirects --strict
Skipping: non en-us locale: /en-US/docs/Secciones_y_contornos_de_un_documento_HTML5    /es/docs/Sections_and_Outlines_of_an_HTML5_document
Skipping: non en-us locale: /en-US/docs/Web/API/WebGL_API/Getting_started_with_WebGL/Commencer_avec_le_WebGL      /fr/docs/Web/API/WebGL_API/Tutorial/Commencer_avec_WebGL
Skipping: non en-us locale: /en-US/docs/Web/API/WebGL_API/Tutorial/Getting_started_with_WebGL/Commencer_avec_le_WebGL     /fr/docs/Web/API/WebGL_API/Tutorial/Commencer_avec_WebGL
avec_le_WebGL en/fr/docs/Web/API/WebGL_API/Tutorial/Commencer_avec_WebGLebGL/Commencer_
Skipping: non en-us locale: /en-US/docs/WebGL/Getting_started_with_WebGL/Commencer_avec_le_WebGL       /fr/docs/Web/API/WebGL_API/Tutorial/Commencer_avec_WebGL
Skipping: non en-us locale: /en-US/docs/video   /es/docs/Web/HTML/Elemento/video
Skipping: non en-us locale: /en-US/docs/zh-n/JavaScript/Reference/Global_Objects/String/quote     /zh-CN/docs/Web/JavaScript/Reference/Global_Objects/String/quote
info: ✓ redirects for en-us looking good!
Skipping: non es locale: /es/docs/Web/JavaScript/Guide/Obsolete_Pages/The_Employee_Example      /en-US/docs/Web/JavaScript/Guide/Details_of_the_Object_Model
removing orphaned redirect (from exists): /es/docs/Web/JavaScript/Reference/Global_Objects/WeakMap/clear        /es/docs/conflicting/Web/JavaScript/Reference/Deprecated_and_obsolete_features
removing orphaned redirect (from exists): /es/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly  /es/docs/WebAssembly/JavaScript_interface

error: _redirects.txt for es is causing issues: Error: Invalid redirect for /es/docs/Web/JavaScript/Reference/Global_Objects/WeakMap/clear -> /es/docs/conflicting/Web/JavaScript/Reference/Deprecated_and_obsolete_features or /es/docs/AJAX -> /es/docs/Web/Guide/AJAX

error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

@OnkarRuikar
Copy link
Contributor Author

Ping @caugner

@caugner caugner merged commit 33c907f into mdn:main Nov 7, 2022
@OnkarRuikar OnkarRuikar deleted the fix-check_redirects branch November 8, 2022 02:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🧑‍🤝‍🧑 community contributions by our wonderful community 🚉 platform keeping the platform healthy
Projects
Development

Successfully merging this pull request may close these issues.

4 participants