Skip to content
Open
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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
125 changes: 125 additions & 0 deletions .github/workflows/webview2-update.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
name: Update webview2 bindings

# Checks for a new WebView2 SDK release, regenerates pkg/webview2 (bindings,
# generated tests, capability table), records the change in the package
# changelog, runs the full test suite on Windows, and opens a PR against
# master with the result. Generation is incremental, so the PR diff contains
# exactly the real changes.

on:
schedule:
- cron: '17 5 * * 1' # weekly, Monday 05:17 UTC
workflow_dispatch:
inputs:
version:
description: 'SDK version to update to (default: newest stable from the release notes)'
required: false
type: string

permissions:
contents: write
pull-requests: write

jobs:
update:
runs-on: windows-latest
env:
GOWORK: "off"
defaults:
run:
shell: bash
working-directory: v3/internal/webview2/scripts

steps:
- name: Checkout master
uses: actions/checkout@v4
with:
ref: master

- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: '1.24'
cache-dependency-path: v3/internal/webview2/scripts/go.sum

- name: Determine versions
id: versions
run: |
OLD=$(go run ./cmd/webview2gen latest --cached)
NEW="${{ inputs.version }}"
if [ -z "$NEW" ]; then
NEW=$(go run ./cmd/webview2gen latest)
fi
echo "old=$OLD" >> "$GITHUB_OUTPUT"
echo "new=$NEW" >> "$GITHUB_OUTPUT"
if [ "$OLD" = "$NEW" ]; then
echo "changed=false" >> "$GITHUB_OUTPUT"
echo "Already on SDK $OLD — nothing to do."
else
echo "changed=true" >> "$GITHUB_OUTPUT"
echo "SDK update available: $OLD → $NEW"
fi

- name: Download new IDL
if: steps.versions.outputs.changed == 'true'
run: go run ./cmd/webview2gen download --version "${{ steps.versions.outputs.new }}"

- name: Record changelog entry
if: steps.versions.outputs.changed == 'true'
run: go run ./cmd/webview2gen changelog --from "${{ steps.versions.outputs.old }}" --to "${{ steps.versions.outputs.new }}"

- name: Regenerate bindings and tests
if: steps.versions.outputs.changed == 'true'
run: go run ./cmd/webview2gen generate --version "${{ steps.versions.outputs.new }}"

- name: Regenerate capability table (and refresh the notes snapshot)
if: steps.versions.outputs.changed == 'true'
run: go run ./cmd/webview2gen capabilities --save-source test.md --version "${{ steps.versions.outputs.new }}"

- name: Verify regeneration is clean
if: steps.versions.outputs.changed == 'true'
run: go run ./cmd/webview2gen verify --version "${{ steps.versions.outputs.new }}"

- name: Generator tests
if: steps.versions.outputs.changed == 'true'
run: go test ./...

- name: Generated binding tests (amd64)
if: steps.versions.outputs.changed == 'true'
working-directory: v3
run: go test ./internal/webview2/...

- name: Generated binding tests (386)
if: steps.versions.outputs.changed == 'true'
working-directory: v3
env:
GOARCH: "386"
run: go test ./internal/webview2/pkg/webview2/

- name: Extract changelog entry for the PR body
if: steps.versions.outputs.changed == 'true'
working-directory: v3/internal/webview2
run: |
awk '/^## /{n++} n==1' CHANGELOG.md > "$RUNNER_TEMP/pr-body.md"
cat "$RUNNER_TEMP/pr-body.md"

- name: Open pull request
if: steps.versions.outputs.changed == 'true'
uses: peter-evans/create-pull-request@v6
with:
base: master
branch: webview2/sdk-${{ steps.versions.outputs.new }}
title: "chore(webview2): update bindings to WebView2 SDK ${{ steps.versions.outputs.new }}"
commit-message: |
chore(webview2): regenerate bindings for WebView2 SDK ${{ steps.versions.outputs.new }}

Automated update from SDK ${{ steps.versions.outputs.old }} to
${{ steps.versions.outputs.new }}: bindings, generated tests and the
capability table were regenerated with 'webview2gen full'; the diff
was verified clean and the full test suite passed on windows
(amd64 + 386). See v3/internal/webview2/CHANGELOG.md for the API delta.
body-path: ${{ runner.temp }}/pr-body.md
add-paths: |
v3/internal/webview2/**
labels: webview2
delete-branch: true
106 changes: 106 additions & 0 deletions .github/workflows/webview2-verify.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
name: Verify webview2 generator

on:
pull_request:
paths:
- 'v3/internal/webview2/**'
- '.github/workflows/webview2-verify.yml'
push:
branches: [master]
paths:
- 'v3/internal/webview2/**'

jobs:
verify:
runs-on: ubuntu-latest
env:
GOWORK: "off"
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: '1.24'

- name: Generator tests
working-directory: v3/internal/webview2/scripts
run: go test -race ./...

- name: Verify generated bindings are up to date
working-directory: v3/internal/webview2/scripts
run: |
go run ./cmd/webview2gen verify
# capabilities.go is also generator-output; regenerate it from the
# cached release-notes snapshot and fail if it changes.
go run ./cmd/webview2gen capabilities --source test.md
if ! git diff --exit-code -- ../pkg/webview2/capabilities.go; then
echo "::error::pkg/webview2/capabilities.go is out of date — run 'webview2gen capabilities'"
exit 1
fi

- name: Cross-compile generated bindings + tests for Windows
working-directory: v3
run: |
GOOS=windows GOARCH=amd64 go vet ./internal/webview2/pkg/webview2/
GOOS=windows GOARCH=arm64 go vet ./internal/webview2/pkg/webview2/
GOOS=windows GOARCH=386 go vet ./internal/webview2/pkg/webview2/

test-windows:

Check warning

Code scanning / CodeQL

Workflow does not contain permissions Medium

Actions job or workflow does not limit the permissions of the GITHUB_TOKEN. Consider setting an explicit permissions block, using the following as a minimal starting point: {contents: read}
Comment on lines +15 to +50
runs-on: windows-latest
env:
GOWORK: "off"
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: '1.24'
cache-dependency-path: |
v3/internal/webview2/scripts/go.sum
v3/go.sum

- name: Generator tests
working-directory: v3/internal/webview2/scripts
shell: bash
run: go test -race ./...

- name: Binding + generated binding tests (amd64)
working-directory: v3
shell: bash
run: |
# Compile-check the whole webview2 tree (generated bindings, legacy
# pkg/edge, loader, combridge).
go build ./internal/webview2/...
# Test only the generated bindings. pkg/edge's real-WebView2
# integration tests (e.g. TestCookieManager) need an interactive
# environment and are owned by the main v3 CI (build-and-test-v3.yml);
# re-running them here is redundant and flaky.
go test ./internal/webview2/pkg/webview2/

# Live smoke test: create a real CoreWebView2 environment and call a
# generated binding (GetBrowserVersionString) through the live vtable.
# This is the only layer that proves the generator's ABI model matches
# Microsoft's actual DLL; it is opt-in (WEBVIEW2_LIVE=1) because it spawns
# a browser process and pumps a message loop. windows-latest ships the
# Evergreen runtime preinstalled, so the environment can be created.
- name: Live WebView2 environment smoke test (amd64)
working-directory: v3
shell: bash
timeout-minutes: 3
env:
WEBVIEW2_LIVE: "1"
run: go test -v -run TestLiveEnvironmentCreation ./internal/webview2/pkg/webview2/

# Windows runs 32-bit binaries natively, so the 386 marshalling
# branches (two-word doubles/tokens, four-word RECTs) are executed
# for real here, not just compiled.
- name: Generated binding tests (386)
working-directory: v3
shell: bash
env:
GOARCH: "386"
run: go test ./internal/webview2/pkg/webview2/

Check warning

Code scanning / CodeQL

Workflow does not contain permissions Medium

Actions job or workflow does not limit the permissions of the GITHUB_TOKEN. Consider setting an explicit permissions block, using the following as a minimal starting point: {contents: read}
10 changes: 10 additions & 0 deletions v3/internal/webview2/.gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Force LF line endings for all webview2 sources, generated bindings, and
# generator fixtures so Windows checkouts with core.autocrlf=true don't
# silently convert templates to CRLF — which makes text/template emit
# CRLF in the bindings, which then diverges from the LF golden files
# committed in scripts/generator/testfiles/.
* text=auto eol=lf
*.tmpl text eol=lf
*.idl text eol=lf
*.go text eol=lf
*.go.txt text eol=lf
3 changes: 3 additions & 0 deletions v3/internal/webview2/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Compiled webview2gen binary — never commit, build artifact only.
/scripts/webview2gen
/scripts/cmd/webview2gen/webview2gen
Loading
Loading