Skip to content

Commit

Permalink
Merge branch 'main' into umeshma/dev
Browse files Browse the repository at this point in the history
  • Loading branch information
umeshma committed Jan 29, 2025
2 parents 8f897b4 + 5297a7b commit 6810724
Show file tree
Hide file tree
Showing 26 changed files with 1,415 additions and 867 deletions.
20 changes: 13 additions & 7 deletions .github/workflows/build-ts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,10 @@ jobs:
working-directory: ts
run: |
pnpm install --frozen-lockfile --strict-peer-dependencies
- name: Install Playwright Browsers
if: ${{ runner.os == 'windows' && matrix.version == '22' }}
run: pnpm exec playwright install --with-deps
working-directory: ts/packages/shell
# - name: Install Playwright Browsers
# if: ${{ runner.os == 'windows' && matrix.version == '22' }}
# run: pnpm exec playwright install --with-deps
# working-directory: ts/packages/shell
- name: Build
if: ${{ github.event_name != 'pull_request' || steps.filter.outputs.ts == 'true' }}
working-directory: ts
Expand Down Expand Up @@ -103,12 +103,19 @@ jobs:
# npm run start:dev 'prompt' 'why is the sky blue'
# working-directory: ts/packages/cli
# continue-on-error: true
# - name: Shell Tests - smoke
# - name: Shell Tests - smoke (windows)
# if: ${{ github.event_name != 'merge_group' && runner.os == 'windows' && matrix.version == '22' }}
# timeout-minutes: 60
# run: |
# npx playwright test simple.spec.ts
# rm ../../.env
# - name: Shell Tests - smoke (linux)
# if: ${{ github.event_name != 'merge_group' && runner.os == 'Linux' && matrix.version == '22' }}
# timeout-minutes: 60
# run: |
# Xvfb :99 -screen 0 1600x1200x24 & export DISPLAY=:99
# npx playwright test simple.spec.ts
# rm ../../.env
# working-directory: ts/packages/shell
# continue-on-error: true
# - name: Live Tests
Expand All @@ -117,5 +124,4 @@ jobs:
# run: |
# npm run test:live
# working-directory: ts
# continue-on-error: true

# continue-on-error: true
121 changes: 121 additions & 0 deletions .github/workflows/smoke-tests-pull_request_targets.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.

# This workflow runs live/smoke sanity tests

name: smoke-tests

on:
workflow_dispatch:
pull_request_target:
branches: ["main"]

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

permissions:
pull-requests: read
contents: read
id-token: write

env:
NODE_OPTIONS: --max_old_space_size=8192

jobs:
shell_and_cli:
environment: development-forks # required for federated credentials
strategy:
fail-fast: false
matrix:
#os: ["ubuntu-latest", "windows-latest", "macos-latest"]
os: ["ubuntu-latest"]
version: [20]

runs-on: ${{ matrix.os }}
steps:
- if: runner.os == 'Linux'
run: |
sudo apt install libsecret-1-0
- name: Setup Git LF
run: |
git config --global core.autocrlf false
- uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}
- uses: dorny/paths-filter@v3
id: filter
with:
filters: |
ts:
- "ts/**"
- ".github/workflows/build-ts.yml"
- uses: pnpm/action-setup@v4
name: Install pnpm
with:
package_json_file: ts/package.json

- uses: actions/setup-node@v4
with:
node-version: ${{ matrix.version }}
cache: "pnpm"
cache-dependency-path: ts/pnpm-lock.yaml
- name: Install dependencies
working-directory: ts
run: |
pnpm install --frozen-lockfile --strict-peer-dependencies
- name: Install Playwright Browsers
run: pnpm exec playwright install --with-deps
working-directory: ts/packages/shell

- name: Build
working-directory: ts
run: |
npm run build
- name: Login to Azure
uses: azure/[email protected]
with:
client-id: ${{ secrets.AZUREAPPSERVICE_CLIENTID_5B0D2D6BA40F4710B45721D2112356DD }}
tenant-id: ${{ secrets.AZUREAPPSERVICE_TENANTID_39BB903136F14B6EAD8F53A8AB78E3AA }}
subscription-id: ${{ secrets.AZUREAPPSERVICE_SUBSCRIPTIONID_F36C1F2C4B2C49CA8DD5C52FAB98FA30 }}

- name: Get Keys
run: |
node tools/scripts/getKeys.mjs --vault build-pipeline-kv
working-directory: ts

- name: Test CLI - smoke
run: |
npm run start:dev 'prompt' 'why is the sky blue'
working-directory: ts/packages/cli
continue-on-error: true

- name: Shell Tests - smoke (windows)
if: ${{ runner.os == 'windows' }}
timeout-minutes: 60
run: |
npx playwright test simple.spec.ts
rm ../../.env
- name: Shell Tests - smoke (linux)
if: ${{ runner.os == 'Linux' }}
timeout-minutes: 60
run: |
Xvfb :99 -screen 0 1600x1200x24 & export DISPLAY=:99
npx playwright test simple.spec.ts
rm ../../.env
working-directory: ts/packages/shell
continue-on-error: true

- name: Live Tests
if: ${{ runner.os == 'linux' }}
timeout-minutes: 60
run: |
npm run test:live
working-directory: ts
continue-on-error: true
124 changes: 124 additions & 0 deletions .github/workflows/smoke-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.

# This workflow runs live/smoke sanity tests

name: smoke-tests

on:
workflow_dispatch:
push:
branches: ["main"]
pull_request:
branches: ["main"]
merge_group:
branches: ["main"]

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

permissions:
pull-requests: read
contents: read
id-token: write

env:
NODE_OPTIONS: --max_old_space_size=8192

jobs:
shell_and_cli:
environment: development # required for federated credentials
strategy:
fail-fast: false
matrix:
#os: ["ubuntu-latest", "windows-latest", "macos-latest"]
os: ["ubuntu-latest"]
version: [20]

runs-on: ${{ matrix.os }}
steps:
- if: runner.os == 'Linux'
run: |
sudo apt install libsecret-1-0
- name: Setup Git LF
run: |
git config --global core.autocrlf false
- uses: actions/checkout@v4

- uses: dorny/paths-filter@v3
id: filter
with:
filters: |
ts:
- "ts/**"
- ".github/workflows/build-ts.yml"
- uses: pnpm/action-setup@v4
name: Install pnpm
with:
package_json_file: ts/package.json

- uses: actions/setup-node@v4
with:
node-version: ${{ matrix.version }}
cache: "pnpm"
cache-dependency-path: ts/pnpm-lock.yaml
- name: Install dependencies
working-directory: ts
run: |
pnpm install --frozen-lockfile --strict-peer-dependencies
- name: Install Playwright Browsers
run: pnpm exec playwright install --with-deps
working-directory: ts/packages/shell

- name: Build
working-directory: ts
run: |
npm run build
- name: Login to Azure
uses: azure/[email protected]
with:
client-id: ${{ secrets.AZUREAPPSERVICE_CLIENTID_5B0D2D6BA40F4710B45721D2112356DD }}
tenant-id: ${{ secrets.AZUREAPPSERVICE_TENANTID_39BB903136F14B6EAD8F53A8AB78E3AA }}
subscription-id: ${{ secrets.AZUREAPPSERVICE_SUBSCRIPTIONID_F36C1F2C4B2C49CA8DD5C52FAB98FA30 }}

- name: Get Keys
run: |
node tools/scripts/getKeys.mjs --vault build-pipeline-kv
working-directory: ts

- name: Test CLI - smoke
run: |
npm run start:dev 'prompt' 'why is the sky blue'
working-directory: ts/packages/cli
continue-on-error: true

- name: Shell Tests - smoke (windows)
if: ${{ runner.os == 'windows' }}
timeout-minutes: 60
run: |
npx playwright test simple.spec.ts
rm ../../.env
- name: Shell Tests - smoke (linux)
if: ${{ runner.os == 'Linux' }}
timeout-minutes: 60
run: |
Xvfb :99 -screen 0 1600x1200x24 & export DISPLAY=:99
npx playwright test simple.spec.ts
rm ../../.env
working-directory: ts/packages/shell
continue-on-error: true

- name: Live Tests
if: ${{ runner.os == 'linux' }}
timeout-minutes: 60
run: |
npm run test:live
working-directory: ts
continue-on-error: true
22 changes: 13 additions & 9 deletions ts/packages/agents/browser/src/electron/agentActivation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,13 @@ declare global {
}

let siteAgent: string = "";
let siteAgentInitialized = false;
function setupSiteAgent() {
if (window.browserConnect) {
if (siteAgentInitialized) {
return;
}

const pageUrl = window.location.href;
const host = new URL(pageUrl).host;

Expand Down Expand Up @@ -57,20 +62,19 @@ function setupSiteAgent() {
siteAgent = "browser.instacart";
window.browserConnect.enableSiteAgent("browser.instacart");
}

siteAgentInitialized = true;
} else {
console.log("browserconnect not found by UI events script");
}
}

window.addEventListener("message", (event) => {
if (event.data === "setupSiteAgent") {
setupSiteAgent();
}
if (
event.data === "disableSiteAgent" &&
siteAgent &&
window.browserConnect
) {
document.addEventListener("DOMContentLoaded", () => {
setupSiteAgent();
});

window.addEventListener("beforeunload", (event) => {
if (siteAgent !== undefined && window.browserConnect !== undefined) {
window.browserConnect.disableSiteAgent(siteAgent);
}
});
11 changes: 5 additions & 6 deletions ts/packages/agents/browser/src/extension/contentScript.ts
Original file line number Diff line number Diff line change
Expand Up @@ -530,11 +530,9 @@ async function awaitPageIncrementalUpdates() {
detector
.detect()
.then(() => {
console.log("Page incremental load completed.");
resolve("true");
})
.catch((error: Error) => {
console.error("Failed to detect page load completion:", error);
.catch((_error: Error) => {
resolve("false");
});
});
Expand Down Expand Up @@ -730,9 +728,10 @@ window.addEventListener(
"message",
async (event) => {
if (
event.data.source == "preload" &&
event.data.target == "contentScript" &&
event.data.messageType == "scriptActionRequest"
event.data !== undefined &&
event.data.source === "preload" &&
event.data.target === "contentScript" &&
event.data.messageType === "scriptActionRequest"
) {
await handleScriptAction(event.data.body, (response) => {
window.top?.postMessage(
Expand Down
Loading

0 comments on commit 6810724

Please sign in to comment.