Repository navigation
Run the OpenJDK tests in CI, split and picked by change #12
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
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
190e583
Run the OpenJDK tests on pull requests and pushes, split over paralle…
Project516 0d6fa2b
Drop checkout credentials in the jtreg jobs, reject bad shard values,…
Project516 46ff1c0
Choose the jtreg selection argument in shell rather than a nested exp…
Project516 88c49eb
Read the jtreg filters into a bash array.
Project516 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,74 @@ | ||
| name: jtreg | ||
|
|
||
| # The OpenJDK regression tests in test/jtreg/passing.txt, split over parallel | ||
| # jobs. A pull request runs the tests its changes need; `full` runs them all. | ||
| on: | ||
| workflow_call: | ||
| inputs: | ||
| full: | ||
| type: boolean | ||
| default: false | ||
|
|
||
| permissions: | ||
| contents: read | ||
|
|
||
| jobs: | ||
| plan: | ||
| runs-on: ubuntu-latest | ||
| outputs: | ||
| filters: ${{ steps.select.outputs.filters }} | ||
| shards: ${{ steps.select.outputs.shards }} | ||
| steps: | ||
| - uses: actions/checkout@v7 | ||
| with: | ||
| fetch-depth: 0 | ||
| persist-credentials: false | ||
| - uses: actions/setup-node@v7 | ||
| with: | ||
| node-version: 24 | ||
| - id: select | ||
|
project516-review-bot[bot] marked this conversation as resolved.
Resolved
|
||
| env: | ||
| FULL: ${{ inputs.full }} | ||
| BASE: ${{ github.event.pull_request.base.sha }} | ||
| # a pull request runs what its diff needs; anything else runs everything | ||
| run: | | ||
| if [ "$FULL" = true ] || [ -z "$BASE" ]; then arg=--full; else arg=$BASE; fi | ||
| node scripts/jtreg/select.ts "$arg" >> "$GITHUB_OUTPUT" | ||
|
|
||
| run: | ||
| needs: plan | ||
| if: needs.plan.outputs.shards != '[]' | ||
| runs-on: ubuntu-latest | ||
| timeout-minutes: 90 | ||
| strategy: | ||
| fail-fast: false | ||
| matrix: | ||
| shard: ${{ fromJSON(needs.plan.outputs.shards) }} | ||
| steps: | ||
| - uses: actions/checkout@v7 | ||
| with: | ||
| persist-credentials: false | ||
| - uses: pnpm/action-setup@v6 | ||
| with: | ||
| version: 12 | ||
| - uses: actions/setup-node@v7 | ||
| with: | ||
| node-version: 24 | ||
| cache: pnpm | ||
| - uses: actions/cache@v6 | ||
| with: | ||
| path: ~/.cache/java-web | ||
| key: jdk-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('scripts/build-jdk.sh') }} | ||
| - run: pnpm install --frozen-lockfile | ||
| - run: pnpm jdk | ||
| - name: OpenJDK regression tests | ||
| env: | ||
| FILTERS: ${{ needs.plan.outputs.filters }} | ||
| run: | | ||
| release=$(sed -n 's/^release=//p' scripts/build-jdk.sh) | ||
| git clone -q --filter=blob:none --sparse --depth 1 --branch "jdk-${release%+*}-ga" https://github.com/openjdk/jdk25u.git build/ref/jdk25u | ||
|
project516-review-bot[bot] marked this conversation as resolved.
Resolved
|
||
| dirs=$(grep -v '^#' test/jtreg/passing.txt | cut -d/ -f1-2 | sort -u | sed 's|^|test/jdk/|') | ||
| git -C build/ref/jdk25u sparse-checkout set test/lib test/jdk/lib test/jdk/tools/lib $dirs | ||
| read -ra filters <<< "$FILTERS" | ||
| node scripts/jtreg/run.ts build/ref/jdk25u --only-passing --jobs 4 --timeout 600 \ | ||
| --shard ${{ matrix.shard }}/${{ strategy.job-total }} "${filters[@]}" | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,56 @@ | ||
| // Picks the OpenJDK tests a change needs, for CI. | ||
| // | ||
| // node scripts/jtreg/select.ts [<base> | --full] | ||
| // | ||
| // Prints GitHub Actions outputs: `filters`, the test areas to pass to run.ts | ||
| // (empty for all of them), and `shards`, a JSON list of shard numbers ([] when | ||
| // no test is needed). A changed file this does not know runs every test. | ||
|
|
||
| import { execFileSync } from "node:child_process"; | ||
| import { readFileSync } from "node:fs"; | ||
| import { join } from "node:path"; | ||
|
|
||
| const root = join(import.meta.dirname, "..", ".."); | ||
| const passingFile = "test/jtreg/passing.txt"; | ||
|
|
||
| // first match wins; null runs no test | ||
| const areas: [RegExp, string[] | null][] = [ | ||
| [/\.md$|^docs\/|^LICENSE|^renovate\.json$|^\.coderabbit/, null], | ||
| [/^src\/browser\/|^src\/(bridge|library|image|http-proxy)\.ts$|^types\/|^scripts\/(build-web|serve)\.ts$/, null], | ||
| [/^test\/(?!jtreg\/)/, null], | ||
| [/^src\/natives\/zip\.ts$|^src\/inflate\.ts$/, ["java/util/zip", "java/util/jar"]], | ||
| [/^src\/natives\/(io|nio)\.ts$|^src\/fs\.ts$/, ["java/io", "java/nio", "java/util/zip", "java/util/jar"]], | ||
| [/^src\/natives\/(net|sockets)\.ts$|^src\/(sockets|net-node)\.ts$|^scripts\/tls\//, ["java/net", "java/nio/channels"]], | ||
| [/^src\/natives\/(font|java2d)[\w-]*\.ts$/, ["java/awt", "java/beans"]], | ||
| [/^src\/natives\/management\.ts$/, ["java/lang/management"]], | ||
| ]; | ||
|
|
||
| const shardsFor = (n: number) => Array.from({ length: Math.min(4, Math.ceil(n / 400)) }, (_, i) => i + 1); | ||
|
project516-review-bot[bot] marked this conversation as resolved.
Resolved
|
||
| const listed = readFileSync(join(root, passingFile), "utf8").split("\n").map((l) => l.trim()).filter((l) => l && !l.startsWith("#")); | ||
| const under = (id: string, f: string) => id === f || id.startsWith(f + "/") || id.startsWith(f + "#"); | ||
|
|
||
| function select(base: string | undefined): string[] | "all" { | ||
| if (!base) return "all"; | ||
| const git = (...args: string[]) => execFileSync("git", args, { cwd: root, encoding: "utf8" }); | ||
| const filters = new Set<string>(); | ||
| for (const file of git("diff", "--name-only", "--no-renames", `${base}...HEAD`).split("\n").filter(Boolean)) { | ||
| if (file === passingFile) { | ||
| // the tests it adds | ||
| for (const l of git("diff", "-U0", `${base}...HEAD`, "--", file).split("\n")) { | ||
| if (l.startsWith("+") && !l.startsWith("+++") && !l.startsWith("+#") && l.slice(1).trim()) filters.add(l.slice(1).trim()); | ||
| } | ||
| continue; | ||
| } | ||
| const hit = areas.find(([re]) => re.test(file)); | ||
| if (!hit) return "all"; | ||
| for (const f of hit[1] ?? []) filters.add(f); | ||
| } | ||
| return [...filters]; | ||
| } | ||
|
|
||
| const arg = process.argv[2]; | ||
| const picked = select(arg === "--full" ? undefined : arg); | ||
| const count = picked === "all" ? listed.length : listed.filter((id) => picked.some((f) => under(id, f))).length; | ||
| console.log(`filters=${picked === "all" ? "" : picked.join(" ")}`); | ||
| console.log(`shards=${JSON.stringify(count ? shardsFor(count) : [])}`); | ||
| console.error(`${count} tests${picked === "all" ? " (all)" : picked.length ? ": " + picked.join(" ") : ""}`); | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.