SWIS-344: Run only English tests in PRs#595
SWIS-344: Run only English tests in PRs#595clarissarichard wants to merge 5 commits intoSWIS-347/language-agnostic-congratsfrom
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
| // { lang: "zhcn", name: "Chinese" }, | ||
| ]; | ||
|
|
||
| const requestedLanguages = process.env.SUPPORTED_LANGUAGES || "all"; |
There was a problem hiding this comment.
This reads the environment variable passed in from the workflow. If the environment variable wasn't set (e.g., ran locally or empty SUPPORTED_LANGUAGES), then all languages are tested.
| const filteredLanguages = ALL_SUPPORTED_LANGUAGES.filter(({ lang }) => | ||
| requestedLanguages | ||
| .split(",") | ||
| .map((value) => value.trim()) | ||
| .filter(Boolean) | ||
| .includes(lang) | ||
| ); |
There was a problem hiding this comment.
This filters all possible languages into only the ones we want to test. It takes the requested languages from the PR workflow step and stores them in an array by splitting the string by commas (e.g., en,es -> [en,es]), removing whitespace (e.g., en, es -> en,es -> [en,es]), and keeping only the non-empty values (e.g., en, ,es -> [en,es]).
| export const SUPPORTED_LANGUAGES = | ||
| requestedLanguages === "all" | ||
| ? ALL_SUPPORTED_LANGUAGES | ||
| : filteredLanguages.length | ||
| ? filteredLanguages | ||
| : [{ lang: "en", name: "English" }]; |
There was a problem hiding this comment.
This determines for the tests and for the Main/QA workflow step which languages to use and loop through. If the environment variable wasn't set (e.g., ran locally or empty SUPPORTED_LANGUAGES), then all languages are tested. Otherwise, if there are filtered languages, use those languages. It falls back to English if there happened to be an issue with the filtered languages.
| - name: Run Playwright tests (Main/QA - all languages) | ||
| if: ${{ github.event_name != 'pull_request' }} | ||
| env: | ||
| SUPPORTED_LANGUAGES: ${{ inputs.SUPPORTED_LANGUAGES || 'all' }} |
There was a problem hiding this comment.
inputs.SUPPORTED_LANGUAGES is already set to default: all above, but we could customize that to only run certain languages on Main/QA if needed.
Description
mainand QATickets:
Motivation and Context
At the moment, it is not necessary to run tests in all languages in PRs. We can instead run them on pushes to
mainand QA. This will reduce the time it takes to run the Playwright tests.How Has This Been Tested?
Observe how only English is tested in Playwright tests workflow in PR. Run
SUPPORTED_LANGUAGES=en npx playwright testto run English tests locally. RunSUPPORTED_LANGUAGES=en,es npx playwright testornpx playwright testto run both English and Spanish tests locally.Checklist: