From 81f1b8d125bb465624c2a7f3e56e5e5b835b7741 Mon Sep 17 00:00:00 2001 From: Martijn Laarman Date: Wed, 11 Nov 2026 14:17:28 +0100 Subject: [PATCH] Build on the .NET 11 SDK and bootstrap the toolchain with mise Every nullean repository is moving onto one standard: the SDK pinned in global.json, mise installing it (and here Node) the same way locally and in CI, the same `mise run` task names everywhere, and zizmor checking the workflows. cdp has no build project, so the mise tasks run the commands CI already runs. The net10.0 runtime is listed after the SDK because every project still targets net10.0, and mise installs only what is listed. CI swaps setup-dotnet for mise-action with its cache off (this workflow publishes what it builds) and installs one dotnet at a time, since parallel installs into one DOTNET_ROOT race. The journeys job takes Node from mise too; the npm publish job keeps setup-node, whose registry-url the trusted publishing setup relies on, now with its package cache off. Actions are pinned by SHA and checkouts drop their credentials. Releases are unchanged. SDK 11's IDE0028 rewrites two comparer-taking collections as [with(StringComparer.Ordinal), ...]; under warnings-as-errors they failed the build. Co-Authored-By: Claude Opus 5.5 --- .github/workflows/ci.yml | 87 +++++++++++++------ .github/workflows/docs.yml | 10 ++- AGENTS.md | 17 +++- global.json | 2 +- mise.toml | 62 +++++++++++++ src/Nullean.Cdp.Journeys/Safety.cs | 2 +- .../Accessibility/AccessibilityAudit.cs | 2 +- 7 files changed, 147 insertions(+), 35 deletions(-) create mode 100644 mise.toml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index dc1b04b..1f99f73 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -26,13 +26,17 @@ jobs: working-directory: js/journeys steps: - - uses: actions/checkout@v6 + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + persist-credentials: false - - uses: actions/setup-node@v7 + # Node comes from mise.toml, as it does locally; this job needs nothing else from it. + - uses: jdx/mise-action@b44d12e7d0d8ee7461bb893e1b1993500433185b # v5.2.7 with: - node-version: 24 - cache: npm - cache-dependency-path: js/journeys/package-lock.json + install_args: node + cache: false # this workflow publishes what its jobs build; never restore a cache a PR could have written + env: + MISE_JOBS: "1" - run: npm ci - run: npm run typecheck @@ -61,17 +65,20 @@ jobs: timeout-minutes: 20 steps: - - uses: actions/checkout@v6 + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: + persist-credentials: false fetch-depth: 0 # MinVer derives the version from tags, so the full tag list must be present. - run: git fetch --prune --tags shell: bash - - uses: actions/setup-dotnet@v5 + - uses: jdx/mise-action@b44d12e7d0d8ee7461bb893e1b1993500433185b # v5.2.7 with: - global-json-file: global.json + cache: false # this workflow publishes what these jobs build; never restore a cache a PR could have written + env: + MISE_JOBS: "1" # dotnet versions share one DOTNET_ROOT; installing them in parallel races - name: Build run: dotnet build -c Release @@ -97,7 +104,7 @@ jobs: - name: Upload the library packages if: github.event_name != 'pull_request' && matrix.os == 'ubuntu-latest' - uses: actions/upload-artifact@v4 + uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 with: name: nupkg-libraries path: .artifacts/package-output/*.nupkg @@ -120,16 +127,19 @@ jobs: timeout-minutes: 20 steps: - - uses: actions/checkout@v6 + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: + persist-credentials: false fetch-depth: 0 - run: git fetch --prune --tags shell: bash - - uses: actions/setup-dotnet@v5 + - uses: jdx/mise-action@b44d12e7d0d8ee7461bb893e1b1993500433185b # v5.2.7 with: - global-json-file: global.json + cache: false # this workflow publishes what these jobs build; never restore a cache a PR could have written + env: + MISE_JOBS: "1" # dotnet versions share one DOTNET_ROOT; installing them in parallel races - name: Pack the native tool for ${{ matrix.rid }} run: dotnet pack src/Nullean.Cdp.Cli -c Release -r ${{ matrix.rid }} -o .artifacts/package-output @@ -143,7 +153,7 @@ jobs: [[ -n "$BINARY" ]] || { echo "no native binary found"; exit 1; } ls -la "$BINARY" - - uses: actions/upload-artifact@v4 + - uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 with: name: nupkg-cli-${{ matrix.rid }} path: .artifacts/package-output/*.nupkg @@ -158,15 +168,18 @@ jobs: timeout-minutes: 20 steps: - - uses: actions/checkout@v6 + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: + persist-credentials: false fetch-depth: 0 - run: git fetch --prune --tags - - uses: actions/setup-dotnet@v5 + - uses: jdx/mise-action@b44d12e7d0d8ee7461bb893e1b1993500433185b # v5.2.7 with: - global-json-file: global.json + cache: false # this workflow publishes what these jobs build; never restore a cache a PR could have written + env: + MISE_JOBS: "1" # dotnet versions share one DOTNET_ROOT; installing them in parallel races - name: Pack run: | @@ -180,7 +193,7 @@ jobs: esac done - - uses: actions/upload-artifact@v4 + - uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 with: name: nupkg-cli-root path: .artifacts/package-output/*.nupkg @@ -198,18 +211,21 @@ jobs: timeout-minutes: 15 steps: - - uses: actions/checkout@v6 + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: + persist-credentials: false fetch-depth: 0 - run: git fetch --prune --tags shell: bash - - uses: actions/setup-dotnet@v5 + - uses: jdx/mise-action@b44d12e7d0d8ee7461bb893e1b1993500433185b # v5.2.7 with: - global-json-file: global.json + cache: false # this workflow publishes what these jobs build; never restore a cache a PR could have written + env: + MISE_JOBS: "1" # dotnet versions share one DOTNET_ROOT; installing them in parallel races - - uses: actions/download-artifact@v4 + - uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0 with: pattern: nupkg-cli-* path: ${{ runner.temp }}/feed @@ -226,6 +242,7 @@ jobs: if [[ "$RUNNER_OS" == "Windows" ]]; then temp="$(cygpath -u "$RUNNER_TEMP")"; cdp="cdp.cmd"; fi feed="$temp/feed" ls "$feed" + # shellcheck disable=SC2012 # package file names are plain ASCII root="$(ls "$feed" | sed -n 's/^Nullean\.Cdp\.Cli\.\([0-9][^/]*\)\.nupkg$/\1/p')" [ -n "$root" ] || { echo "no root package in the feed"; exit 1; } echo "version $root" @@ -249,11 +266,17 @@ jobs: id-token: write # trusted publishing: exchange the workflow's OIDC token for a short-lived key steps: - - uses: actions/setup-dotnet@v5 + # No checkout here, so no mise.toml: the action writes one with the SDK the push needs. + - uses: jdx/mise-action@b44d12e7d0d8ee7461bb893e1b1993500433185b # v5.2.7 with: - dotnet-version: 10.0.x + cache: false # a release never restores a cache PR builds could have written + mise_toml: | + [tools] + dotnet = "10" + env: + MISE_JOBS: "1" - - uses: actions/download-artifact@v4 + - uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0 with: pattern: nupkg-* path: packages @@ -273,7 +296,7 @@ jobs: - name: Log in to nuget.org (trusted publishing) id: nuget-login - uses: NuGet/login@v1 + uses: NuGet/login@8d196754b4036150537f80ac539e15c2f1028841 # v1.2.0 with: user: ${{ secrets.NUGET_USER }} @@ -323,12 +346,16 @@ jobs: working-directory: js/journeys steps: - - uses: actions/checkout@v6 + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + persist-credentials: false - - uses: actions/setup-node@v7 + # Kept on setup-node: its registry-url writes the .npmrc that npm's trusted publishing is set up against. + - uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0 with: node-version: 24 registry-url: https://registry.npmjs.org + package-manager-cache: false # never restore a cache into a publishing job # Trusted publishing needs npm 11.5.1 or later. - name: Check npm supports trusted publishing @@ -363,3 +390,9 @@ jobs: case "$GITHUB_REF_NAME" in *-*) tag=next ;; esac # Provenance is automatic with trusted publishing from a public repository. npm publish --access public --tag "$tag" + + # Static analysis of these workflows (nullean/.github). + zizmor: + uses: nullean/.github/.github/workflows/zizmor.yml@83ef343759c443afe1964e9c33327527f8677b05 # v1.3.0 + permissions: + contents: read diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index 4c510a8..d8766db 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -21,11 +21,13 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 15 steps: - - uses: actions/checkout@v6 + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + persist-credentials: false # The design-system layout is behind a feature flag, read from the environment only. - name: Build documentation - uses: elastic/docs-builder@main + uses: elastic/docs-builder@036a375759d876e2df67955ebec0382cd6b09249 # v1 env: FEATURE_NAVIGATION_PREVIEW: true @@ -34,7 +36,7 @@ jobs: # Pull requests can download this to look at the site; main deploys it. - name: Upload the site - uses: actions/upload-pages-artifact@v5.0.0 + uses: actions/upload-pages-artifact@fc324d3547104276b827a68afc52ff2a11cc49c9 # v5.0.0 with: path: .artifacts/docs/html @@ -51,4 +53,4 @@ jobs: steps: - name: Deploy id: deployment - uses: actions/deploy-pages@v4 + uses: actions/deploy-pages@d6db90164ac5ed86f2b6aed7e0febac5b3c0c03e # v4.0.5 diff --git a/AGENTS.md b/AGENTS.md index 1c96808..568de93 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -5,13 +5,28 @@ A Chrome DevTools Protocol client for .NET, the journey language on top of it, a ## Build and test +`mise install` provides the toolchain: the .NET 11 SDK pinned in `global.json`, the net10.0 runtime the projects and +tests target, and the Node CI builds `js/journeys` with. The everyday tasks have the same names as in every nullean +repository, and run the commands CI runs: + +```sh +mise run build # build the solution +mise run test # build, then run the tests +mise run pack # build and pack the libraries (CI packs the native AOT CLI per RID) +mise run ci # what CI runs on every push: build, test, pack, and the js/journeys job +mise run docs # build the docs and serve them (needs docs-builder, see scripts/docs.sh) +mise run check # workflow security checks (zizmor) +``` + +Without mise: + ```sh dotnet build -c Release dotnet test -c Release dotnet test -c Release --project tests/Nullean.Cdp.Tests --treenode-filter "/*/*/ChromeLocatorTests/*" ``` -Requires the .NET 10 SDK (pinned in `global.json`). Tests run on Microsoft.Testing.Platform with TUnit. Tests that need +Requires the .NET 11 SDK (pinned in `global.json`). Tests run on Microsoft.Testing.Platform with TUnit. Tests that need a real Chrome skip with a reason when none is found; CI sets `CDP_BROWSER_REQUIRED=1` so they fail instead. The CLI: `dotnet run --project src/Nullean.Cdp.Cli -- run --base-url `. diff --git a/global.json b/global.json index df32a2e..269797b 100644 --- a/global.json +++ b/global.json @@ -1,6 +1,6 @@ { "sdk": { - "version": "10.0.100", + "version": "11.0.100", "rollForward": "latestFeature", "allowPrerelease": false }, diff --git a/mise.toml b/mise.toml new file mode 100644 index 0000000..ed43e19 --- /dev/null +++ b/mise.toml @@ -0,0 +1,62 @@ +# Bootstraps the toolchain and is the one entry point: `mise run `, the same task names in every nullean repo. +# The .NET SDK version lives only in global.json: the first dotnet entry reads it from there (sdk.version is the first +# "version" key). The net10.0 runtime is listed after it because every project and test targets net10.0. Node is the +# version CI builds and tests @nullean/journeys (js/journeys) with. +# +# The tasks run the commands CI runs; there is no build project. Browser tests need a local Chrome: without one they +# skip (CI sets CDP_BROWSER_REQUIRED=1 on Linux so they fail instead). + +[env] +DOTNET_NOLOGO = "1" +DOTNET_CLI_TELEMETRY_OPTOUT = "1" +DOTNET_SKIP_FIRST_TIME_EXPERIENCE = "1" + +[tools] +dotnet = ["""{{ read_file(path='global.json') | split(pat='"version"') | nth(n=1) | split(pat='"') | nth(n=1) }}""", "10"] +node = "24" +gh = "latest" +zizmor = "1" + +[tasks.build] +description = "Build the solution" +run = "dotnet build -c Release" + +[tasks.test] +description = "Build, then run the tests" +run = ["dotnet build -c Release", "dotnet test -c Release --no-build"] + +[tasks.check] +description = "Fail on workflow findings (zizmor)" +run = "zizmor --min-severity medium ." + +[tasks.pack] +description = "Build and pack the libraries, as CI's build job does (the CLI is a native AOT tool CI packs per RID)" +run = [ + "dotnet build -c Release", + ''' + for project in src/*/*.csproj; do + case "$project" in *Nullean.Cdp.Cli*) continue ;; esac + dotnet pack "$project" -c Release --no-build -o .artifacts/package-output + done + ls .artifacts/package-output + ''', +] + +[tasks.docs] +description = "Build the documentation and serve it locally (needs docs-builder; see scripts/docs.sh)" +run = "scripts/docs.sh" + +[tasks.ci] +description = "What CI runs on every push: the build job (build, test, pack the libraries) and the journeys-js job" +run = [ + "dotnet build -c Release", + "dotnet test -c Release --no-build", + ''' + for project in src/*/*.csproj; do + case "$project" in *Nullean.Cdp.Cli*) continue ;; esac + dotnet pack "$project" -c Release --no-build -o .artifacts/package-output + done + ls .artifacts/package-output + ''', + "cd js/journeys && npm ci && npm run typecheck && npm run build && npm pack --dry-run && npm test && npm run test:live", +] diff --git a/src/Nullean.Cdp.Journeys/Safety.cs b/src/Nullean.Cdp.Journeys/Safety.cs index 6128945..6de8580 100644 --- a/src/Nullean.Cdp.Journeys/Safety.cs +++ b/src/Nullean.Cdp.Journeys/Safety.cs @@ -73,7 +73,7 @@ public sealed partial class JourneySecrets public const int MinimumLength = 4; private readonly Func _resolve; - private readonly Dictionary _values = new(StringComparer.Ordinal); + private readonly Dictionary _values = [with(StringComparer.Ordinal)]; internal JourneySecrets(Func resolve) => _resolve = resolve; diff --git a/src/Nullean.Cdp/Accessibility/AccessibilityAudit.cs b/src/Nullean.Cdp/Accessibility/AccessibilityAudit.cs index b29a2e9..2099aa5 100644 --- a/src/Nullean.Cdp/Accessibility/AccessibilityAudit.cs +++ b/src/Nullean.Cdp/Accessibility/AccessibilityAudit.cs @@ -28,7 +28,7 @@ private sealed record Rule(string Id, string Impact, string Help); private static readonly Rule OneMain = new("landmark-one-main", "moderate", "A page has exactly one main landmark"); private static readonly HashSet FieldRoles = - new(StringComparer.Ordinal) { "textbox", "searchbox", "combobox", "listbox", "checkbox", "radio", "slider", "spinbutton", "switch" }; + [with(StringComparer.Ordinal), "textbox", "searchbox", "combobox", "listbox", "checkbox", "radio", "slider", "spinbutton", "switch"]; // Document, ARIA, id and contrast rules, on the DOM. Each finding: [rule, impact, help, node description]. private const string DomRules = """