From 46167ea4922b83458b717422ccdb7c3e98c58e8d Mon Sep 17 00:00:00 2001 From: ldm0 Date: Mon, 23 Nov 2026 22:01:02 +0800 Subject: [PATCH] ci(molio): separate desktop validation from Moli --- .github/scripts/cancel-pr-ci.cjs | 9 +++- .github/scripts/cancel-pr-ci.test.cjs | 16 +++--- .github/workflows/ci.yml | 39 ++++++++++++-- .github/workflows/molio-ci.yml | 73 +++++++++++++++++++++++++++ 4 files changed, 123 insertions(+), 14 deletions(-) create mode 100644 .github/workflows/molio-ci.yml diff --git a/.github/scripts/cancel-pr-ci.cjs b/.github/scripts/cancel-pr-ci.cjs index 8c315fa4502..bd6d52484fc 100644 --- a/.github/scripts/cancel-pr-ci.cjs +++ b/.github/scripts/cancel-pr-ci.cjs @@ -1,5 +1,10 @@ 'use strict'; +const ciWorkflowPaths = new Set([ + '.github/workflows/ci.yml', + '.github/workflows/molio-ci.yml', +]); + function belongsToPr(run, pullRequest) { if (run.pull_requests?.length) { return run.pull_requests.some((pr) => pr.number === pullRequest.number); @@ -36,10 +41,9 @@ async function cancelClosedPrCi({ github, context, core }) { // Collect every page before cancelling: all revisions belong to the PR, // including queued runs for older HEADs. A branch name alone is not identity. - const runs = await github.paginate(github.rest.actions.listWorkflowRuns, { + const runs = await github.paginate(github.rest.actions.listWorkflowRunsForRepo, { owner, repo, - workflow_id: 'ci.yml', event: 'pull_request', branch: current.head.ref, created: `${current.created_at}..${current.closed_at}`, @@ -51,6 +55,7 @@ async function cancelClosedPrCi({ github, context, core }) { if ( run.event !== 'pull_request' || run.status === 'completed' || + !ciWorkflowPaths.has(run.path) || !belongsToPr(run, current) ) { continue; diff --git a/.github/scripts/cancel-pr-ci.test.cjs b/.github/scripts/cancel-pr-ci.test.cjs index d422d588abf..663f7013bec 100644 --- a/.github/scripts/cancel-pr-ci.test.cjs +++ b/.github/scripts/cancel-pr-ci.test.cjs @@ -8,6 +8,7 @@ function run(id, overrides = {}) { return { id, event: 'pull_request', + path: '.github/workflows/ci.yml', status: 'in_progress', head_branch: 'topic', head_sha: `revision-${id}`, @@ -20,7 +21,7 @@ function run(id, overrides = {}) { function fixture({ pages = [[]], current = {}, cancel, getRun } = {}) { const calls = { cancelled: [], listed: [], notices: [], warnings: [] }; - const listWorkflowRuns = async () => assert.fail('Use pagination to find older revisions'); + const listWorkflowRunsForRepo = async () => assert.fail('Use pagination to find older revisions'); const github = { rest: { pulls: { @@ -40,7 +41,7 @@ function fixture({ pages = [[]], current = {}, cancel, getRun } = {}) { }, }, actions: { - listWorkflowRuns, + listWorkflowRunsForRepo, cancelWorkflowRun: async (args) => { calls.cancelled.push(args.run_id); assert.equal(args.owner, 'lexmount'); @@ -54,7 +55,7 @@ function fixture({ pages = [[]], current = {}, cancel, getRun } = {}) { }, }, paginate: async (method, args) => { - assert.equal(method, listWorkflowRuns); + assert.equal(method, listWorkflowRunsForRepo); calls.listed.push(args); return pages.flat(); }, @@ -88,7 +89,6 @@ test('merging a PR cancels every unfinished revision across all pages', async () assert.deepEqual(f.calls.listed, [{ owner: 'lexmount', repo: 'moli', - workflow_id: 'ci.yml', event: 'pull_request', branch: 'topic', created: '2026-10-24T10:00:00Z..2026-10-24T12:00:00Z', @@ -133,7 +133,7 @@ test('closing a fork PR matches the fork repository rather than a same-named loc assert.deepEqual(await cancelClosedPrCi(f), [1]); }); -test('preserves completed runs, other PRs with the same branch, and main or manual runs', async () => { +test('cancels both CI workflows and preserves unrelated runs', async () => { const f = fixture({ pages: [[ run(1, { status: 'completed' }), run(2, { pull_requests: [{ number: 43 }] }), @@ -142,9 +142,11 @@ test('preserves completed runs, other PRs with the same branch, and main or manu run(5, { pull_requests: [], head_repository: undefined }), run(6, { pull_requests: undefined, head_repository: undefined }), run(7, { pull_requests: [{ number: 43 }, { number: 42 }] }), + run(8, { path: '.github/workflows/molio-ci.yml' }), + run(9, { path: '.github/workflows/macos-tls.yml' }), ]] }); - assert.deepEqual(await cancelClosedPrCi(f), [7]); - assert.deepEqual(f.calls.cancelled, [7]); + assert.deepEqual(await cancelClosedPrCi(f), [7, 8]); + assert.deepEqual(f.calls.cancelled, [7, 8]); }); test('a delayed close event does not cancel a reopened PR', async () => { diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f42f743da24..d905f486f51 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -3,9 +3,13 @@ name: CI on: pull_request: types: [opened, synchronize, reopened] + paths-ignore: &molio_paths + - molio/** + - .github/workflows/molio-ci.yml push: branches: - main + paths-ignore: *molio_paths workflow_dispatch: inputs: base_ref: @@ -95,7 +99,17 @@ jobs: run: rustup component add rustfmt - name: Check formatting - run: cargo fmt --all --check + uses: actions/github-script@f28e40c7f34bde8b3046d885e986cb6290c5673b # v7 + with: + script: | + const { execFileSync } = require('node:child_process'); + const metadata = execFileSync('cargo', [ + 'metadata', '--locked', '--no-deps', '--format-version', '1', + ], { encoding: 'utf8' }); + const packages = JSON.parse(metadata).packages + .filter(({ name }) => name !== 'molio') + .flatMap(({ name }) => ['-p', name]); + execFileSync('cargo', ['fmt', '--check', ...packages], { stdio: 'inherit' }); clippy: name: Clippy @@ -114,8 +128,23 @@ jobs: - name: Install clippy run: rustup component add clippy - - name: Check clippy - run: cargo clippy --workspace --all-targets --all-features -- -D warnings + - name: Check Clippy without Molio + uses: actions/github-script@f28e40c7f34bde8b3046d885e986cb6290c5673b # v7 + with: + script: | + const { execFileSync } = require('node:child_process'); + const metadata = execFileSync('cargo', [ + 'metadata', '--locked', '--no-deps', '--format-version', '1', + ], { encoding: 'utf8' }); + const features = JSON.parse(metadata).packages + .filter(({ name }) => name !== 'molio') + .flatMap(({ name, features }) => Object.keys(features) + .filter(feature => feature !== 'molio') + .map(feature => `${name}/${feature}`)); + execFileSync('cargo', [ + 'clippy', '--locked', '--workspace', '--exclude', 'molio', '--all-targets', + '--features', features.join(','), '--', '-D', 'warnings', + ], { stdio: 'inherit' }); # The target cfg adds -Dwarnings alongside the repository's linker flags. - name: Check renderer tests without DevTools @@ -168,8 +197,8 @@ jobs: echo "NEXTEST_TEST_THREADS=$test_threads" >> "$GITHUB_ENV" echo "Nextest test threads: $test_threads ($cpu_count available CPUs)" - - name: Run full workspace tests - run: cargo nextest run --workspace --profile ci + - name: Run Moli tests + run: cargo nextest run --workspace --exclude molio --profile ci - name: Run ACE protocol tests run: >- diff --git a/.github/workflows/molio-ci.yml b/.github/workflows/molio-ci.yml new file mode 100644 index 00000000000..353a9d628c8 --- /dev/null +++ b/.github/workflows/molio-ci.yml @@ -0,0 +1,73 @@ +name: molio CI + +on: + pull_request: + types: [opened, synchronize, reopened] + paths: &build_paths + - molio/** + - moli-*/** + - '!moli-benchmark/**' + - '!moli-*-smoke/**' + - '!moli-playground/**' + - vendor/** + - Cargo.toml + - Cargo.lock + - rust-toolchain + - .cargo/** + - .config/nextest.toml + - .github/workflows/molio-ci.yml + push: + branches: + - main + paths: *build_paths + workflow_dispatch: + +permissions: + contents: read + +concurrency: + group: molio-ci-${{ github.event.pull_request.number || (github.event_name == 'push' && github.ref) || github.run_id }} + cancel-in-progress: true + +env: + CARGO_TERM_COLOR: always + CARGO_INCREMENTAL: "0" + +jobs: + linux: + name: molio Linux + runs-on: ubuntu-latest + container: rust:1.100.0-bookworm + timeout-minutes: 45 + steps: + - name: Checkout repository + uses: actions/checkout@v4 + with: + persist-credentials: false + + - name: Install Rust components + run: rustup component add rustfmt clippy + + - name: Check formatting + run: cargo fmt -p molio --check + + - name: Install desktop build dependencies + run: | + set -eu + apt-get update + apt-get install --yes --no-install-recommends cmake libclang-dev pkg-config \ + libfontconfig1-dev libwayland-dev libx11-dev libxcb1-dev libxcb-shape0-dev \ + libxcb-xfixes0-dev libxkbcommon-dev libxkbcommon-x11-dev + + - name: Check Clippy + run: >- + cargo clippy --locked -p molio -p moli-core -p moli-renderer-v8 + --all-targets --all-features -- -D warnings + + - name: Install cargo-nextest + uses: taiki-e/install-action@13608cbb45b01feb47ef444ab1a42dc41ad56f1a # v2.79.11 + with: + tool: nextest@0.9.132 + + - name: Run desktop tests + run: cargo nextest run --locked -p molio -p moli-core --bins --test viewport --profile ci