Skip to content

Commit 2a83440

Browse files
authored
chore(ci): add coverage (#13)
* chore: add mobile actions * chore(ci): add coverage * chore: coverage * chore: lcov coverage * docs: readme * chore: lcov * chore: codecov * chore: token * chore: coverage v8 * chore: env token * chore: env * chore: token * chore: provider
1 parent 91c1665 commit 2a83440

File tree

8 files changed

+201
-6
lines changed

8 files changed

+201
-6
lines changed

.github/workflows/test.yml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,12 @@ jobs:
3232
- name: Run typecheck
3333
run: pnpm run typecheck
3434
- name: Run test
35-
run: pnpm run test
35+
run: pnpm run coverage
36+
- name: Upload coverage data
37+
uses: codecov/codecov-action@v5
38+
with:
39+
fail_ci_if_error: true
40+
disable_search: true
41+
files: ./coverage/lcov.info
42+
token: ${{ secrets.CODECOV_TOKEN }}
43+
verbose: false

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@ out
66
.eslintcache
77
.env
88
test-results/
9+
coverage/

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ We recommend using HuggingFace Inference Endpoints for fast deployment. We provi
7777

7878
<img src="./images/settings_model.png" width="500px" />
7979

80-
If you use Ollama, you can use the following command to start the server:
80+
If you use Ollama, you can use the following settings to start the server:
8181

8282
```yaml
8383
VLM Provider: ollama

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
"package": "electron-forge package",
2323
"clean": "rimraf dist out",
2424
"test": "vitest",
25+
"coverage": "vitest run --coverage",
2526
"pretest:e2e": "npm run build:dist && cross-env CI=e2e npm run package",
2627
"test:e2e": "playwright test",
2728
"build:deps": "pnpm --filter \"!ui-tars-desktop,ui-tars-desktop...\" build && cd packages/visualizer && pnpm install --ignore-workspace",
@@ -109,6 +110,7 @@
109110
"@typescript-eslint/eslint-plugin": "^5.0.0",
110111
"@typescript-eslint/parser": "^5.0.0",
111112
"@vitejs/plugin-react": "^4.3.1",
113+
"@vitest/coverage-istanbul": "^3.0.3",
112114
"clsx": "2.1.1",
113115
"copy-to-clipboard": "3.3.3",
114116
"cross-env": "^7.0.3",

packages/action-parser/src/index.test.ts

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,4 +111,42 @@ describe('actionParser', () => {
111111
String.raw`doubao.com\n`,
112112
);
113113
});
114+
115+
describe('Mobile action parser', () => {
116+
it('Click on the search bar at the top of the screen', () => {
117+
const result = actionParser({
118+
prediction:
119+
"Thought: Click on the search bar at the top of the screen\nAction: click(start_box='(395,74)')",
120+
factor: 1000,
121+
});
122+
expect(result).toEqual({
123+
parsed: [
124+
{
125+
reflection: '',
126+
thought: 'Click on the search bar at the top of the screen',
127+
action_type: 'click',
128+
action_inputs: { start_box: '[0.395,0.074,0.395,0.074]' },
129+
},
130+
],
131+
});
132+
});
133+
134+
it('swipe', () => {
135+
const result = actionParser({
136+
prediction:
137+
"Thought: swipe(start_box='(693,685)', end_box='(724,300)')\n\nAction: scroll(direction='left')",
138+
factor: 1000,
139+
});
140+
expect(result).toEqual({
141+
parsed: [
142+
{
143+
reflection: '',
144+
thought: "swipe(start_box='(693,685)', end_box='(724,300)')",
145+
action_type: 'scroll',
146+
action_inputs: { direction: 'left' },
147+
},
148+
],
149+
});
150+
});
151+
});
114152
});

pnpm-lock.yaml

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

src/main/utils/image.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ export async function preprocessResizeImage(
221221
const currentPixels = metadata.width * metadata.height;
222222
if (currentPixels > maxPixels) {
223223
const resizeFactor = Math.sqrt(maxPixels / currentPixels);
224-
logger.info(
224+
logger.debug(
225225
'[resizeFactor] maxPixels',
226226
maxPixels,
227227
'currentPixels',
@@ -242,7 +242,7 @@ export async function preprocessResizeImage(
242242
})
243243
.toBuffer();
244244

245-
logger.info(
245+
logger.debug(
246246
'[preprocessResizeImage]',
247247
'width:',
248248
newWidth,

vitest.config.mts

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import { defineConfig } from 'vitest/config';
2+
3+
function cwdPlugin(name) {
4+
return {
5+
name: `vitest:test:workspace-${name}`,
6+
configResolved() {
7+
process.env[`${name}_CWD_CONFIG`] = process.cwd();
8+
},
9+
configureServer() {
10+
process.env[`${name}_CWD_SERVER`] = process.cwd();
11+
},
12+
};
13+
}
14+
15+
export default defineConfig({
16+
envPrefix: ['VITE_', 'CUSTOM_', 'ROOT_'],
17+
plugins: [cwdPlugin('ROOT')],
18+
test: {
19+
coverage: {
20+
enabled: true,
21+
include: ['src/**/*.ts', 'packages/**/*.ts', '!packages/visualizer'],
22+
provider: 'istanbul',
23+
all: true,
24+
reporter: ['text', 'json', 'html', 'lcov'],
25+
},
26+
reporters: ['default'],
27+
env: {
28+
CONFIG_VAR: 'root',
29+
CONFIG_OVERRIDE: 'root',
30+
},
31+
provide: {
32+
globalConfigValue: true,
33+
},
34+
},
35+
});

0 commit comments

Comments
 (0)