Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
87 changes: 60 additions & 27 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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: |
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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"
Expand All @@ -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
Expand All @@ -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 }}

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
10 changes: 6 additions & 4 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -34,7 +36,7 @@ jobs:

# Pull requests can download this to look at the site; main deploys it.
- name: Upload the site
uses: actions/[email protected]
uses: actions/upload-pages-artifact@fc324d3547104276b827a68afc52ff2a11cc49c9 # v5.0.0
with:
path: .artifacts/docs/html

Expand All @@ -51,4 +53,4 @@ jobs:
steps:
- name: Deploy
id: deployment
uses: actions/deploy-pages@v4
uses: actions/deploy-pages@d6db90164ac5ed86f2b6aed7e0febac5b3c0c03e # v4.0.5
17 changes: 16 additions & 1 deletion AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 <journey> --base-url <url or folder>`.
Expand Down
2 changes: 1 addition & 1 deletion global.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"sdk": {
"version": "10.0.100",
"version": "11.0.100",
"rollForward": "latestFeature",
"allowPrerelease": false
},
Expand Down
62 changes: 62 additions & 0 deletions mise.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# Bootstraps the toolchain and is the one entry point: `mise run <task>`, 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",
]
2 changes: 1 addition & 1 deletion src/Nullean.Cdp.Journeys/Safety.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public sealed partial class JourneySecrets
public const int MinimumLength = 4;

private readonly Func<string, string?> _resolve;
private readonly Dictionary<string, string> _values = new(StringComparer.Ordinal);
private readonly Dictionary<string, string> _values = [with(StringComparer.Ordinal)];

internal JourneySecrets(Func<string, string?> resolve) => _resolve = resolve;

Expand Down
2 changes: 1 addition & 1 deletion src/Nullean.Cdp/Accessibility/AccessibilityAudit.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<string> 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 = """
Expand Down
Loading