CI runs your tests in UTF-8, UTC, English, ASCII paths and LF line endings. Your users don't.
works-elsewhere is a GitHub Action that re-runs your existing test command under real but unfriendly environments: a legacy CJK locale, Turkish, time zones with awkward DST rules, a checkout path with Japanese and Chinese characters and spaces, and a CRLF checkout. It reports only what passes on a normal run and fails under one of them.
There are no new tests to write. It reuses the ones you have.
jobs:
works-elsewhere:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- uses: actions/setup-node@v5
with:
node-version: 22
- run: npm ci
- uses: b84330808/works-elsewhere@v1
with:
run: npm test # required: the project's test command
profiles: legacy-locale,turkish,dst-gap,unicode-paths,crlf # default: all
junit: reports/**/*.xml # optional: per-test comparison when the command writes JUnit XMLWhat happens:
- Baseline.
runruns once in the job's normal environment. - Profiles.
runruns again once per profile environment: 8 more runs with every profile on. - Report. A table goes to the job summary, and the step sets the
findingsandreportoutputs. With findings, the step fails, unless you setfail-on-findings: false.
Every run, the baseline included, works on its own fresh copy of the workspace. Your checkout is never modified, so later steps see it as it was.
Install your dependencies before this step, as in the example. The command runs with bash -eo pipefail, like a run: step.
| Profile | Runs | What changes | Bugs it surfaces |
|---|---|---|---|
legacy-locale |
2 | LANG and LC_ALL set to zh_TW.BIG5, then ja_JP.EUC-JP (generated with localedef). PYTHONUTF8=0, and PYTHONIOENCODING is unset. |
Text files read or written without an explicit encoding: Python's open() (3.14 and earlier), Java's FileReader (17 and earlier), Ruby's File.read, C's mbstowcs. |
turkish |
1 | LANG and LC_ALL set to tr_TR.UTF-8. -Duser.language=tr -Duser.country=TR is appended to JAVA_TOOL_OPTIONS. |
Locale-sensitive case mapping: Java "integer".toUpperCase() gives İNTEGER; JavaScript toLocaleUpperCase() with no locale; case-insensitive keyword and header lookups. |
dst-gap |
3 | TZ set to America/New_York, Australia/Lord_Howe, then Asia/Kathmandu. |
Mixing local time and UTC, which is invisible when the machine is on UTC; assuming every local time exists, DST moves the clock by an hour, and offsets are whole hours. |
unicode-paths |
1 | The workspace copy is at $RUNNER_TEMP/works-elsewhere.*/w/テスト 測試 ü/<repo>, and TMPDIR, TEMP and TMP point to .../一時 temp ü/. |
Paths pasted into shell commands without quoting, new URL(import.meta.url).pathname used as a path, paths turned into URLs by string concatenation. |
crlf |
1 | Tracked text files in the copy are checked out again with core.autocrlf=true, the Git for Windows default. |
Splitting on "\n" and comparing lines exactly, regexes that do not expect \r, fixtures compared byte for byte. |
Why these three time zones:
- America/New_York has an ordinary one-hour DST change. On the spring-forward day, 02:00 to 03:00 does not exist, so code that builds a local date from UTC fields gets a different time.
- Australia/Lord_Howe moves its clock by 30 minutes for DST (UTC+10:30 and UTC+11).
- Asia/Kathmandu is at UTC+5:45, neither a whole nor a half hour, and skipped 15 minutes when it moved there from UTC+5:30 on 1 January 1986.
The crlf profile leaves alone files that .gitattributes marks -text, binary or eol=lf, as Git would for a Windows contributor.
| Input | Default | Description |
|---|---|---|
run |
(required) | The test command. It runs with bash, in working-directory. |
profiles |
all |
Comma- or space-separated profiles, or all. |
junit |
Space-separated globs for the JUnit XML files the command writes, relative to working-directory. ** matches any number of directories. |
|
working-directory |
. |
Where to run the command, relative to the workspace. |
timeout-minutes |
30 |
Timeout for each run. With every profile on, the command runs 9 times. |
fail-on-findings |
true |
Fail the step when there are findings. |
| Output | Description |
|---|---|
findings |
Number of findings. |
report |
Path of the JSON report. Each run's log is next to it, in runs/<run>/log.txt. |
To keep the logs, upload the report's directory:
- if: always()
uses: actions/upload-artifact@v4
with:
name: works-elsewhere
path: ${{ runner.temp }}/works-elsewhere.*/Without junit, each profile run is judged by its exit code: the baseline passes and the profile run fails, so that is one finding. You learn which environment breaks something, but not which test.
With junit, works-elsewhere reads the JUnit XML each run wrote. A finding is a test that passed on the baseline and fails under a profile. Tests that already fail on the baseline are ignored, so a red baseline still gives useful results. A profile run that exits non-zero without a failing test, for example because it crashed before writing its report, still counts as one finding. If the baseline wrote no JUnit file, all runs are compared by exit code instead.
Only report files written during the run count, so stale reports from earlier steps are ignored. Tests are matched by suite, class name, test name and file, with the path of each run's copy taken out.
Common ways to get JUnit XML:
| Tool | Command | junit |
|---|---|---|
| pytest | pytest --junitxml=reports/junit.xml |
reports/junit.xml |
| node:test | mkdir -p reports && node --test --test-reporter=spec --test-reporter-destination=stdout --test-reporter=junit --test-reporter-destination=reports/junit.xml |
reports/junit.xml |
| Vitest | vitest run --reporter=default --reporter=junit --outputFile.junit=reports/junit.xml |
reports/junit.xml |
| Jest | jest --reporters=default --reporters=jest-junit (with jest-junit installed) |
junit.xml |
| Maven | mvn -B test |
**/target/surefire-reports/*.xml |
| Gradle | ./gradlew test |
**/build/test-results/test/*.xml |
| Go | gotestsum --junitfile reports/junit.xml |
reports/junit.xml |
GITHUB_WORKSPACEpoints to the run's copy.WORKS_ELSEWHERE_PROFILEisbaselineor the profile name.WORKS_ELSEWHERE_VARIANTis the locale or time zone, if any. Use them to skip a test that cannot work in an environment.GITHUB_OUTPUT,GITHUB_ENV,GITHUB_PATHandGITHUB_STEP_SUMMARYpoint to files of the run, so the command cannot change later steps.- Workflow commands printed by the command are paused (
::stop-commands::), so a test reporter's annotations are not repeated once per run. - The copy is deleted when the run ends, so only one copy exists at a time.
These were fixed recently. Each belongs to one of the bug families above, but not every one can be caught by a Linux runner, so each row says what works-elsewhere would have done.
| Pull request | Bug | Profile | Would works-elsewhere catch it? |
|---|---|---|---|
| dbcli/mycli#2389 (open) | Startup crash under the cp932 locale: the packaged UTF-8 config file is read with the locale's encoding. | legacy-locale |
Yes, on Python 3.14 and earlier. The same file fails to decode as EUC-JP or BIG5 at its first en dash, and mycli's existing tests read the default config. |
| charmbracelet/glamour#651 (open) | CRLF line endings blank out code blocks in the styles that render without chroma. | crlf |
Not with glamour's current tests. They pass in a CRLF checkout of the commit before the fix (checked with go test ./...). A test that renders a committed Markdown file with a code block in one of those styles would fail under crlf. |
| Y2Z/monolith#541 (merged) | Windows drive-letter paths such as C:\page.html are parsed as URLs with the scheme c. |
related to unicode-paths |
No. The bug needs Windows path syntax, which a Linux runner cannot produce. Run your tests on windows-latest as well. |
| fuma-nama/fumadocs#3752 (merged) | Index card links are built from paths relative to the wrong directory, and from backslashes on Windows. | related to unicode-paths |
No. The first half is an ordinary logic bug, and the second half needs Windows paths. |
- Linux runners only. A Windows runner cannot switch its system ANSI code page without a reboot, so
windows-latestruns as cp1252 and misses the CJK code page bugs thatlegacy-localefinds. In the other direction, Linux cannot reproduce Windows path syntax (drive letters, backslashes, reserved names), so keep awindows-latestjob for those. - Python 3.15 and later default to UTF-8 mode (PEP 686), so most users of those versions never hit locale-encoding bugs. works-elsewhere sets
PYTHONUTF8=0, which turns that default off. Alegacy-localefinding on 3.15+ only affects users who turn UTF-8 mode off, or who run your code on 3.14 or earlier. The profile matters most for Python 3.14 and earlier, and for C, C++, Ruby, PHP and Perl. - Java 18 and later default to UTF-8 for file contents (JEP 400), so
legacy-localefinds fewer Java bugs there.turkishstill applies to every Java version. Underturkish, the JVM printsPicked up JAVA_TOOL_OPTIONS: ...to stderr, which can upset tests that check stderr exactly. - Exit-code mode is coarse. One finding per run and no test names. Use
junitwhen you can. - Flaky tests look like findings. A test that fails at random can fail in a profile run. Run again before you trust a single finding.
- It takes longer. With every profile on, the command runs 9 times, and the workspace is copied for each run. Choose
profiles, or run this job on a schedule or for selected pull requests. - Installed copies point at the original checkout. A virtualenv or an editable install created inside the workspace still refers to the original path, so tests may import code from the checkout instead of the copy, and
unicode-pathscan miss path bugs in it. Install insiderunif you need the copy to be self-contained. - crlf re-checks out tracked text files from Git, so changes an earlier step made to tracked files are not in the crlf copy. Untracked files such as
node_modulesare copied as they are. - The command must stay in its copy. A command that changes to an absolute path, or writes JUnit files outside
working-directory, works on the original checkout instead.
npm testThe unit tests cover the JUnit reader, the comparison and the summary, and run the script end to end on a small repository (on Windows, through Git Bash). The self-test workflow runs the action on the projects in fixtures/. Each has one deliberate bug that passes on a normal runner and fails under exactly one profile, and fixtures/control must have no findings.
To run the script outside Linux (with bash 4 or later), set WORKS_ELSEWHERE_DEV=1. Locales are not generated then, so only some profiles behave as they do on a runner.
MIT © Wei-Lun Li
Built with help from Claude Code.