Skip to content

Commit d0be609

Browse files
chore(chrome-extension): CI sync, smoke tests, background worker
Adds Code.gs sync check workflow, release gate, Playwright AUTH_KEY smoke test, empty MV3 service worker for test discovery, and extension assets. Co-authored-by: Cursor <cursoragent@cursor.com>
1 parent a37e15e commit d0be609

14 files changed

Lines changed: 369 additions & 0 deletions
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
name: chrome-extension
2+
3+
on:
4+
pull_request:
5+
paths:
6+
- 'assets/apps_script/Code.gs'
7+
- 'chrome-extension/**'
8+
- '.github/workflows/chrome-extension.yml'
9+
push:
10+
branches:
11+
- main
12+
paths:
13+
- 'assets/apps_script/Code.gs'
14+
- 'chrome-extension/**'
15+
- '.github/workflows/chrome-extension.yml'
16+
17+
permissions:
18+
contents: read
19+
20+
jobs:
21+
bundled-code-sync:
22+
name: bundled Code.gs stays in sync
23+
runs-on: ubuntu-latest
24+
25+
steps:
26+
- name: Check out repository
27+
uses: actions/checkout@v4
28+
29+
- name: Compare Apps Script source with extension fallback
30+
run: |
31+
if ! cmp -s assets/apps_script/Code.gs chrome-extension/Code.gs; then
32+
echo "::error file=chrome-extension/Code.gs::chrome-extension/Code.gs must match assets/apps_script/Code.gs. Update the bundled fallback whenever the canonical Apps Script changes."
33+
diff -u assets/apps_script/Code.gs chrome-extension/Code.gs || true
34+
exit 1
35+
fi
36+
37+
auth-key-smoke-test:
38+
name: auth key smoke test
39+
runs-on: ubuntu-latest
40+
needs: bundled-code-sync
41+
42+
steps:
43+
- name: Check out repository
44+
uses: actions/checkout@v4
45+
46+
- name: Set up Node.js
47+
uses: actions/setup-node@v4
48+
with:
49+
node-version: '20'
50+
51+
- name: Install test dependencies
52+
working-directory: chrome-extension
53+
run: npm install
54+
55+
- name: Install Playwright browser
56+
working-directory: chrome-extension
57+
run: npx playwright install --with-deps chromium
58+
59+
- name: Run extension smoke tests
60+
working-directory: chrome-extension
61+
run: xvfb-run npm run test:smoke

.github/workflows/release.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,23 @@ permissions:
4646
# and more importantly keeps target/ warm via the rust-cache action.
4747

4848
jobs:
49+
verify-chrome-extension-codegs-sync:
50+
name: verify chrome-extension Code.gs sync
51+
runs-on: ubuntu-latest
52+
steps:
53+
- name: Check out repository
54+
uses: actions/checkout@v4
55+
56+
- name: Compare Apps Script source with extension fallback
57+
run: |
58+
if ! cmp -s assets/apps_script/Code.gs chrome-extension/Code.gs; then
59+
echo "::error file=chrome-extension/Code.gs::chrome-extension/Code.gs must match assets/apps_script/Code.gs. Update the bundled fallback whenever the canonical Apps Script changes."
60+
diff -u assets/apps_script/Code.gs chrome-extension/Code.gs || true
61+
exit 1
62+
fi
63+
4964
build:
65+
needs: verify-chrome-extension-codegs-sync
5066
strategy:
5167
fail-fast: false
5268
matrix:

chrome-extension/.gitignore

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# Logs
2+
logs
3+
*.log
4+
npm-debug.log*
5+
yarn-debug.log*
6+
yarn-error.log*
7+
pnpm-debug.log*
8+
lerna-debug.log*
9+
*.codex
10+
node_modules
11+
test-results
12+
playwright-report
13+
dist
14+
dist-ssr
15+
*.local
16+
*.env
17+
*.env.*.local
18+
!.env.example
19+
!.env.*.example
20+
# Editor directories and files
21+
.vscode/*
22+
!.vscode/extensions.json
23+
.idea
24+
.DS_Store
25+
*.suo
26+
*.ntvs*
27+
*.njsproj
28+
*.sln
29+
*.sw?

chrome-extension/assets/logo.webp

60.2 KB
Loading

chrome-extension/background.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
// Intentionally empty service worker.
2+
// Keeps extension runtime discoverable for automated smoke tests.

chrome-extension/manifest.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@
88
"default_title": "__MSG_extName__",
99
"default_popup": "popup.html"
1010
},
11+
"background": {
12+
"service_worker": "background.js"
13+
},
1114
"permissions": ["storage", "clipboardWrite"],
1215
"host_permissions": ["https://script.google.com/*", "https://raw.githubusercontent.com/*", "https://api.github.com/*"]
1316
}

chrome-extension/messages.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
"downloadScript": "Download Code.gs",
1717
"openScript": "Open Apps Script",
1818
"scriptNotice": "The script is loaded from the extension package and includes the same relay protocol used by mhrv-rs.",
19+
"checkScriptVersion": "Check latest Code.gs",
1920
"step3Title": "Step 3: Create config",
2021
"step3Desc": "Paste your Deployment ID and the auth key into your local config.",
2122
"deploymentIdLabel": "Deployment ID",
@@ -36,6 +37,11 @@
3637
"generateKeyFirst": "Generate an auth key first.",
3738
"copyError": "Could not copy {item}.",
3839
"fetchError": "Failed to load Code.gs at all."
40+
,
41+
"scriptUpToDate": "Your bundled Code.gs matches the latest upstream version.",
42+
"scriptOutdated": "Update available: your bundled Code.gs differs from upstream.",
43+
"scriptCheckFailed": "Could not verify Code.gs version.",
44+
"scriptCheckNetworkBlocked": "Could not reach upstream to check Code.gs (network blocked/offline)."
3945
},
4046
"fa": {
4147
"appName": "کمک‌کننده اسکریپت اپس mhrv-rs",
@@ -54,6 +60,7 @@
5460
"downloadScript": "دانلود Code.gs",
5561
"openScript": "باز کردن Apps Script",
5662
"scriptNotice": "اسکریپت از بسته افزونه بارگذاری می‌شود و شامل همان پروتکل رله استفاده شده توسط mhrv-rs است.",
63+
"checkScriptVersion": "بررسی آخرین نسخه Code.gs",
5764
"step3Title": "مرحله ۳: ایجاد پیکربندی",
5865
"step3Desc": "شناسه استقرار و کلید احراز هویت را در پیکربندی محلی خود جای‌گذاری کنید.",
5966
"deploymentIdLabel": "شناسه استقرار",
@@ -74,5 +81,10 @@
7481
"generateKeyFirst": "ابتدا یک کلید احراز هویت تولید کنید.",
7582
"copyError": "کپی {item} امکان‌پذیر نبود.",
7683
"fetchError": "بارگذاری Code.gs به طور کامل ناموفق بود."
84+
,
85+
"scriptUpToDate": "Code.gs داخلی افزونه با آخرین نسخه upstream یکسان است.",
86+
"scriptOutdated": "به‌روزرسانی موجود است: Code.gs داخلی افزونه با upstream متفاوت است.",
87+
"scriptCheckFailed": "امکان بررسی نسخه Code.gs وجود ندارد.",
88+
"scriptCheckNetworkBlocked": "امکان دسترسی به upstream برای بررسی Code.gs نبود (اینترنت/شبکه مسدود یا آفلاین)."
7789
}
7890
}

chrome-extension/package-lock.json

Lines changed: 76 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

chrome-extension/package.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"name": "mhrv-helper-extension-tests",
3+
"private": true,
4+
"scripts": {
5+
"test:smoke": "playwright test --config=playwright.config.js"
6+
},
7+
"devDependencies": {
8+
"@playwright/test": "latest"
9+
}
10+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
const { defineConfig } = require('@playwright/test');
2+
const path = require('path');
3+
4+
module.exports = defineConfig({
5+
testDir: './tests',
6+
timeout: 60_000,
7+
fullyParallel: false,
8+
retries: 0,
9+
reporter: 'list',
10+
use: {
11+
headless: false,
12+
},
13+
projects: [
14+
{
15+
name: 'chromium-extension',
16+
use: {
17+
channel: 'chromium',
18+
launchOptions: {
19+
args: [
20+
`--disable-extensions-except=${path.resolve(__dirname)}`,
21+
`--load-extension=${path.resolve(__dirname)}`,
22+
],
23+
},
24+
},
25+
},
26+
],
27+
});

0 commit comments

Comments
 (0)