Skip to content

SWIS-344: Run only English tests in PRs#595

Draft
clarissarichard wants to merge 5 commits intoSWIS-347/language-agnostic-congratsfrom
SWIS-344/filter-lang
Draft

SWIS-344: Run only English tests in PRs#595
clarissarichard wants to merge 5 commits intoSWIS-347/language-agnostic-congratsfrom
SWIS-344/filter-lang

Conversation

@clarissarichard
Copy link
Copy Markdown
Collaborator

@clarissarichard clarissarichard commented Mar 9, 2026

Description

  • Filters languages to be tested based on the environment
  • Splits workflow step into two - one for PRs and the second for pushes to main and QA

Tickets:

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 main and 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 test to run English tests locally. Run SUPPORTED_LANGUAGES=en,es npx playwright test or npx playwright test to run both English and Spanish tests locally.

Checklist:

  • I have updated the documentation accordingly.
  • All new and existing tests passed.

@clarissarichard clarissarichard self-assigned this Mar 9, 2026
@vercel
Copy link
Copy Markdown

vercel bot commented Mar 9, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
nypl-library-card-app Ready Ready Preview, Comment Mar 18, 2026 4:31pm

Request Review

@clarissarichard clarissarichard changed the base branch from main to SWIS-347/language-agnostic-congrats March 9, 2026 15:53
// { lang: "zhcn", name: "Chinese" },
];

const requestedLanguages = process.env.SUPPORTED_LANGUAGES || "all";
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

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.

Comment on lines +128 to +134
const filteredLanguages = ALL_SUPPORTED_LANGUAGES.filter(({ lang }) =>
requestedLanguages
.split(",")
.map((value) => value.trim())
.filter(Boolean)
.includes(lang)
);
Copy link
Copy Markdown
Collaborator Author

@clarissarichard clarissarichard Mar 17, 2026

Choose a reason for hiding this comment

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

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]).

Comment on lines +136 to +141
export const SUPPORTED_LANGUAGES =
requestedLanguages === "all"
? ALL_SUPPORTED_LANGUAGES
: filteredLanguages.length
? filteredLanguages
: [{ lang: "en", name: "English" }];
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

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' }}
Copy link
Copy Markdown
Collaborator Author

@clarissarichard clarissarichard Mar 17, 2026

Choose a reason for hiding this comment

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

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant