Update WebdriverBiDi types #883
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 workflow will update the WebdriverBiDi types. | |
name: Update WebdriverBiDi types | |
# Declare default permissions as read only. | |
permissions: read-all | |
on: | |
schedule: | |
# Run daily at 10AM. | |
- cron: '0 10 * * *' | |
workflow_dispatch: | |
inputs: | |
source_ref: | |
description: Ref in spec repo to update from. Default is `main`. | |
default: main | |
required: false | |
type: string | |
repository: | |
description: Repository with the spec to update from. Default is `w3c/webdriver-bidi`. | |
default: w3c/webdriver-bidi | |
required: false | |
type: string | |
jobs: | |
build_main_spec: | |
name: Build main spec cddl types | |
runs-on: ubuntu-latest | |
steps: | |
- name: Install dependencies | |
run: | | |
cargo install [email protected]; | |
npm install parse5 | |
- name: Check out the main spec repository | |
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | |
with: | |
repository: ${{ github.event.inputs.repository || 'w3c/webdriver-bidi' }} | |
ref: ${{ github.event.inputs.source_ref || 'main' }} | |
path: webdriver-bidi | |
- name: Generate WebDriverBidi CDDL | |
run: ./scripts/test.sh | |
working-directory: webdriver-bidi | |
- name: Upload WebDriverBidi CDDL | |
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 | |
with: | |
name: all-cddl | |
path: webdriver-bidi/all.cddl | |
build_permissions: | |
name: Build Permissions CDDL | |
runs-on: ubuntu-latest | |
steps: | |
- name: Install dependencies | |
run: | | |
cargo install [email protected]; | |
npm install parse5 | |
- name: Check out the main spec repository | |
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | |
with: | |
repository: ${{ github.event.inputs.repository || 'w3c/webdriver-bidi' }} | |
ref: ${{ github.event.inputs.source_ref || 'main' }} | |
path: webdriver-bidi | |
- name: Check out w3c/permissions spec repository | |
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | |
with: | |
repository: w3c/permissions | |
ref: main | |
path: permissions | |
- name: Generate WebDriverBidi CDDL for Permissions | |
run: ../webdriver-bidi/scripts/cddl/generate.js ./index.html && mv all.cddl permissions.cddl | |
working-directory: permissions | |
- name: Upload WebDriverBidi CDDL for Permissions | |
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 | |
with: | |
name: permissions-cddl | |
path: permissions/permissions.cddl | |
build_bluetooth_cddl: | |
name: Build Bluetooth CDDL | |
runs-on: ubuntu-latest | |
steps: | |
- name: Install dependencies | |
run: | | |
cargo install [email protected]; | |
npm install parse5 | |
- name: Check out the main spec repository | |
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | |
with: | |
repository: ${{ github.event.inputs.repository || 'w3c/webdriver-bidi' }} | |
ref: ${{ github.event.inputs.source_ref || 'main' }} | |
path: webdriver-bidi | |
- name: Check out WebBluetoothCG/web-bluetooth spec repository | |
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | |
with: | |
repository: WebBluetoothCG/web-bluetooth | |
ref: main | |
path: web-bluetooth | |
- name: Generate WebDriverBidi CDDL for web-bluetooth | |
run: ../webdriver-bidi/scripts/cddl/generate.js ./index.bs && mv all.cddl web-bluetooth.cddl | |
working-directory: web-bluetooth | |
- name: Upload WebDriverBidi CDDL for web-bluetooth | |
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 | |
with: | |
name: web-bluetooth-cddl | |
path: web-bluetooth/web-bluetooth.cddl | |
pr: | |
name: Send PR | |
needs: [build_main_spec, build_permissions, build_bluetooth_cddl] | |
# Run even if some CDDL's are not built. | |
if: always() | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check out mapper repository | |
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | |
- name: Set up Python | |
uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0 | |
with: | |
python-version: '3.11' | |
cache: pip | |
- name: Setup Go | |
uses: actions/setup-go@d35c59abb061a4a6fb18e82ac0862c26744d6ab5 # v5.0.0 | |
with: | |
go-version: '1.21.x' | |
- name: Install cddlconv | |
run: cargo install [email protected] | |
- name: Set up Node.js | |
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0 | |
with: | |
node-version-file: '.nvmrc' | |
cache: npm | |
- uses: google/wireit@f21db1f3a6a4db31f42787a958cf2a18308effed # setup-github-actions-caching/v2.0.3 | |
- name: Install and build npm dependencies | |
run: npm ci | |
- name: Download WebDriverBidi CDDL | |
uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0 | |
with: | |
name: all-cddl | |
# Tolerate missing files. | |
continue-on-error: true | |
- name: Download WebDriverBidi CDDL for Permissions | |
uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0 | |
with: | |
name: permissions-cddl | |
# Tolerate missing files. | |
continue-on-error: true | |
- name: Download WebDriverBidi CDDL for web-bluetooth | |
uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0 | |
with: | |
name: web-bluetooth-cddl | |
# Tolerate missing files. | |
continue-on-error: true | |
- name: Generate TypeScript types for the main spec | |
run: node tools/generate-bidi-types.mjs --cddl-file all.cddl | |
# Tolerate errors during generating types. | |
continue-on-error: true | |
- name: Generate TypeScript types for Permissions spec | |
run: node tools/generate-bidi-types.mjs --cddl-file permissions.cddl --ts-file src/protocol/generated/webdriver-bidi-permissions.ts --zod-file src/protocol-parser/generated/webdriver-bidi-permissions.ts | |
# Tolerate errors during generating types. | |
continue-on-error: true | |
- name: Generate TypeScript types for web-bluetooth spec | |
run: node tools/generate-bidi-types.mjs --cddl-file web-bluetooth.cddl --ts-file src/protocol/generated/webdriver-bidi-bluetooth.ts --zod-file src/protocol-parser/generated/webdriver-bidi-bluetooth.ts | |
# Tolerate errors during generating types. | |
continue-on-error: true | |
- run: git diff | |
# Needed for `npm run format`. | |
- run: python -m pip install pre-commit | |
- run: python -m pip freeze --local | |
- name: Run formatter | |
run: npm run format || npm run format | |
continue-on-error: true | |
- name: Create Pull Request | |
uses: peter-evans/create-pull-request@271a8d0340265f705b14b6d32b9829c1cb33d45e # v7.0.8 | |
with: | |
token: ${{ secrets.BROWSER_AUTOMATION_BOT_TOKEN }} | |
branch: browser-automation-bot/update-bidi-types | |
delete-branch: true | |
committer: Browser Automation Bot <[email protected]> | |
author: Browser Automation Bot <[email protected]> | |
commit-message: 'build(spec): update WebDriverBiDi types' | |
title: 'build(spec): update WebDriverBiDi types' | |
body: Automatically generated by https://github.com/GoogleChromeLabs/chromium-bidi/blob/main/.github/workflows/update-bidi-types.yml | |
push-to-fork: browser-automation-bot/chromium-bidi |