Skip to content

Commit 05c7134

Browse files
authored
feat: worker idle timeout (#62)
## Proposed changes [//]: # 'Describe the big picture of your changes here to communicate to the maintainers why we should accept this pull request. If it fixes a bug or resolves a feature request, be sure to link to that issue.' ## Types of changes [//]: # 'What types of changes does your code introduce to WebdriverIO?' [//]: # '_Put an `x` in the boxes that apply_' - [ ] Polish (an improvement for an existing feature) - [ ] Bugfix (non-breaking change which fixes an issue) - [x] New feature (non-breaking change which adds functionality) - [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected) - [ ] Documentation update (improvements to the project's docs) - [ ] Internal updates (everything related to internal scripts, governance documentation and CI files) ## Checklist [//]: # "_Put an `x` in the boxes that apply. You can also fill these out after creating the PR. If you're unsure about any of them, don't hesitate to ask. We're here to help! This is simply a reminder of what we are going to look for before merging your code._" - [x] I have read the [CONTRIBUTING](https://github.com/webdriverio/vscode-webdriverio/blob/main/CONTRIBUTING.md) doc - [x] I have added tests that prove my fix is effective or that my feature works - [x] I have added the necessary documentation (if appropriate) - [x] I have added proper type definitions for new commands (if appropriate) ## Further comments [//]: # 'If this is a relatively large or complex change, kick off the discussion by explaining why you chose the solution you did and what alternatives you considered, etc...' ### Reviewers: @webdriverio/project-committers
1 parent 1cf776e commit 05c7134

72 files changed

Lines changed: 1632 additions & 372 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
name: 'vscode-webdriverio Set screen resolution'
2+
description: 'Set screen resolution'
3+
inputs:
4+
width:
5+
description: 'screen width'
6+
default: '1920'
7+
height:
8+
description: 'screen height'
9+
default: '1080'
10+
runs:
11+
using: 'composite'
12+
steps:
13+
# https://github.com/actions/runner-images/issues/2935
14+
- name: Set display resolution on Windows
15+
if: runner.os == 'Windows'
16+
shell: pwsh
17+
run: |
18+
Set-DisplayResolution -Width ${{ inputs.width }} -Height ${{ inputs.height }} -Force
19+
20+
# I don't know the details, but it appears that it needs to be maximized at the Webdriver level
21+
# because it does not launch in full screen on Linux.
22+
# However, as the following Issue states, Electron(base of vscode) can not be muximize by webdriver protocol.
23+
# https://github.com/electron/electron/issues/33942
24+
# Therefore, GUI-based methods are used to maximize the screen.
25+
# The process of maximizing screen size using xdotool is done in the before hook of wdio.conf.ts.
26+
- name: Set display resolution on Linux
27+
if: runner.os == 'Linux'
28+
shell: bash
29+
run: |
30+
pnpm --filter @vscode-wdio/xvfb-patch run patch -w ${{ inputs.width }} -h ${{ inputs.height }}
31+
echo "::group::apt install -y xdotool"
32+
sudo apt install -y xdotool
33+
echo "::endgroup::"
34+
35+
# already use FHD resolution
36+
- name: Set display resolution on MacOS
37+
if: runner.os == 'macOS'
38+
shell: bash
39+
run: |
40+
brew install displayplacer
41+
displayplacer list

.github/workflows/ci-e2e.yml

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,14 @@ env:
1515
VSCODE_WDIO_E2E_COMPATIBILITY_MODE: ${{ inputs.compatibility-mode }}
1616

1717
jobs:
18-
unit:
19-
name: E2E Tests (${{ matrix.os }}.${{ matrix.node-version }})
18+
e2e:
19+
name: E2E Tests - ${{ matrix.scenario }} (${{ matrix.os }}.${{ matrix.node-version }})
2020
strategy:
2121
fail-fast: false
2222
matrix:
2323
node-version: ['20']
2424
os: ['ubuntu-latest', 'windows-latest', 'macos-latest']
25+
scenario: ['basic', 'workspace']
2526
runs-on: ${{ matrix.os }}
2627
steps:
2728
- name: 👷 Checkout
@@ -46,16 +47,21 @@ jobs:
4647
with:
4748
path: e2e/.wdio-vscode-service
4849

50+
- name: 🖥️ Set screen resolution
51+
uses: ./.github/workflows/actions/set-screen-resolution
52+
4953
- name: 🧪 Run the e2e test
50-
run: pnpm run test:e2e
54+
env:
55+
E2E_SCENARIO: ${{ matrix.scenario }}
56+
run: pnpm --filter @vscode-wdio/e2e run test:e2e:${E2E_SCENARIO}
5157
shell: bash
5258

5359
- name: 📦 Upload Test Logs on Failure
5460
uses: ./.github/workflows/actions/upload-archive
5561
if: failure()
5662
with:
57-
name: ${{ inputs.compatibility-mode == 'yes' && 'compatibility' || 'e2e' }}-logs-${{ matrix.os }}
58-
output: ${{ inputs.compatibility-mode == 'yes' && 'compatibility' || 'e2e' }}-logs-${{ matrix.os }}.zip
63+
name: ${{ inputs.compatibility-mode == 'yes' && 'compatibility' || 'e2e' }}-${{ matrix.scenario }}-logs-${{ matrix.os }}
64+
output: ${{ inputs.compatibility-mode == 'yes' && 'compatibility' || 'e2e' }}-${{ matrix.scenario }}-logs-${{ matrix.os }}.zip
5965
paths: e2e/logs
6066

6167
- name: 🐛 Debug Build

.github/workflows/ci-lint.yml

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Lint
1+
name: Static code analysis
22

33
on:
44
workflow_call:
@@ -11,12 +11,7 @@ env:
1111
jobs:
1212
lint:
1313
name: Lint
14-
strategy:
15-
fail-fast: false
16-
matrix:
17-
node-version: ['20']
18-
os: ['ubuntu-latest']
19-
runs-on: ${{ matrix.os }}
14+
runs-on: 'ubuntu-latest'
2015
steps:
2116
- name: 👷 Checkout
2217
uses: actions/[email protected]
@@ -26,14 +21,7 @@ jobs:
2621
- name: 🛠️ Setup workspace
2722
uses: ./.github/workflows/actions/setup-workspace
2823
with:
29-
node-version: ${{ matrix.node-version }}
30-
31-
- name: ⬇️ Download Build Archive
32-
uses: ./.github/workflows/actions/download-archive
33-
with:
34-
name: vscode-webdriverio
35-
path: .
36-
filename: vscode-webdriverio-build.zip
24+
node-version: '20'
3725

3826
- name: 📃 Run the lint
3927
run: pnpm run style:fix

.github/workflows/ci-smoke.yml

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,16 @@ on:
44
workflow_call:
55
# Make this a reusable workflow, no value needed
66
# https://docs.github.com/en/actions/using-workflows/reusing-workflows
7+
inputs:
8+
scenario:
9+
description: 'Smoke scenario'
10+
type: string
711

812
env:
913
TURBO_TELEMETRY_DISABLED: 1
1014

1115
jobs:
12-
unit:
16+
smoke:
1317
name: Smoke Tests (${{ matrix.os }}.${{ matrix.node-version }})
1418
strategy:
1519
fail-fast: false
@@ -40,16 +44,21 @@ jobs:
4044
with:
4145
path: e2e/.wdio-vscode-service
4246

47+
- name: 🖥️ Set screen resolution
48+
uses: ./.github/workflows/actions/set-screen-resolution
49+
4350
- name: 🚂 Run the smoke test
44-
run: pnpm run test:smoke
51+
env:
52+
E2E_SCENARIO: ${{ inputs.scenario }}
53+
run: pnpm --filter @vscode-wdio/e2e run test:smoke:${E2E_SCENARIO}
4554
shell: bash
4655

4756
- name: 📦 Upload Test Logs on Failure
4857
uses: ./.github/workflows/actions/upload-archive
4958
if: failure()
5059
with:
51-
name: smoke-logs-${{ matrix.os }}
52-
output: smoke-logs-${{ matrix.os }}.zip
60+
name: smoke-${{ inputs.scenario }}--logs-${{ matrix.os }}
61+
output: smoke-${{ inputs.scenario }}-logs-${{ matrix.os }}.zip
5362
paths: e2e/logs
5463

5564
- name: 🐛 Debug Build

.github/workflows/ci.yml

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,33 +21,41 @@ jobs:
2121
os: 'ubuntu-latest'
2222

2323
lint:
24-
name: Lint
25-
needs: [build]
24+
name: Static code analysis
2625
uses: ./.github/workflows/ci-lint.yml
2726

2827
typecheck:
2928
name: Typecheck
30-
needs: [build]
29+
needs: [lint, build]
3130
uses: ./.github/workflows/ci-typecheck.yml
3231

3332
unit:
3433
name: Unit
35-
needs: [build]
34+
needs: [lint, build]
3635
uses: ./.github/workflows/ci-unit.yml
3736

3837
e2e:
3938
name: E2E
40-
needs: [build]
39+
needs: [lint, build]
4140
uses: ./.github/workflows/ci-e2e.yml
4241

4342
compatibility:
4443
name: Compatibility
45-
needs: [build]
44+
needs: [lint, build]
4645
uses: ./.github/workflows/ci-e2e.yml
4746
with:
4847
compatibility-mode: 'yes'
4948

50-
smoke:
51-
name: Smoke
52-
needs: [build, e2e]
49+
smoke-config:
50+
name: Smoke - Update Config
51+
needs: [lint, build, e2e]
5352
uses: ./.github/workflows/ci-smoke.yml
53+
with:
54+
scenario: 'config'
55+
56+
smoke-timeout:
57+
name: Smoke - Worker idle timeout
58+
needs: [lint, build, e2e]
59+
uses: ./.github/workflows/ci-smoke.yml
60+
with:
61+
scenario: 'timeout'

CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ This Extension consists of several packages. Eventually, these packages will be
132132
<br>
133133
**Service Layer**<br>
134134
@vscode-wdio/config (constants, logger, utils)<br>
135-
└── @vscode-wdio/api (constants, logger, utils)<br>
135+
└── @vscode-wdio/server (constants, logger, utils)<br>
136136
<br>
137137
**Integration Layer**<br>
138138
├── @vscode-wdio/worker (constants, utils)<br>

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ This extension contributes the following settings:
8080

8181
- `webdriverio.nodeExecutable`: The path to the Node.js executable. If not assigned, WebdriverIO try to resolve the node path from environment valuables of `PATH`.
8282
- `webdriverio.configFilePattern`: Glob pattern for WebdriverIO configuration file
83+
- `webdriverio.workerIdleTimeout`: If no processing is performed in the Worker for the set amount of time(defined by seconds), the Worker is terminated. If processing is requested again, it will be started automatically.
8384
- `webdriverio.logLevel`: Set the logLevel
8485
- `webdriverio.showOutput`: Show WebdriverIO output in the test result when set `true` this option
8586

assets/build.png

179 Bytes
Loading

e2e/assertions/index.ts

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import type { MatcherContext } from 'expect'
2-
import type { TreeItem } from 'wdio-vscode-service'
2+
import type { BottomBarPanel, TreeItem, Workbench } from 'wdio-vscode-service'
33
import type { STATUS } from '../helpers/index.ts'
44

55
export interface ExpectedTreeItem {
@@ -92,8 +92,38 @@ try {
9292
async toMatchTreeStructure(tree: TreeItem[], expectedStructure: ExpectedTreeItem[]) {
9393
return await expectTreeToMatchStructure.call(this as unknown as MatcherContext, tree, expectedStructure)
9494
},
95+
async hasExpectedLog(workbench: Workbench, expectedLog: RegExp | string) {
96+
const bottomBar = workbench.getBottomBar()
97+
98+
const outputView = await bottomBar.openOutputView()
99+
await outputView.selectChannel('WebdriverIO')
100+
await clickGlobalAction(bottomBar, bottomBar.locators.maximize)
101+
const logs = await outputView.getText()
102+
103+
const regexp = typeof expectedLog === 'string' ? new RegExp(expectedLog) : expectedLog
104+
105+
const pass = logs.some((log) => regexp.test(log))
106+
107+
await clickGlobalAction(bottomBar, bottomBar.locators.restore)
108+
const message = pass ? 'The log outputs include expected text.' : 'The expected text is not included'
109+
return { pass, message: () => message }
110+
},
95111
})
96112
}
97113
} catch (error) {
98114
console.warn('Failed to extend expect:', error)
99115
}
116+
117+
async function clickGlobalAction(bottomBar: BottomBarPanel, label: string) {
118+
let action
119+
try {
120+
action = (await bottomBar.elem
121+
.$(bottomBar.locators.globalActions)
122+
.$(`.//a[contains(@aria-label, '${label}') and @role='checkbox']`)) as WebdriverIO.Element
123+
} catch {
124+
// the panel is already maximized
125+
}
126+
if (action) {
127+
await action.click({})
128+
}
129+
}

e2e/assertions/wdio.shim.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ declare global {
44
namespace ExpectWebdriverIO {
55
interface Matchers<R, T> {
66
toMatchTreeStructure(expectedStructure: ExpectedTreeItem[]): R
7+
hasExpectedLog(expectedLog: RegExp | string): R
78
}
89
}
910
}

0 commit comments

Comments
 (0)