Skip to content

Commit e48d5e7

Browse files
authored
Add pre-commit (#22)
* remove trailing whitespace: clean up unnecessary whitespace in documentation, scripts, and configuration files * remove lint-test workflow: delete obsolete workflow file, previously replaced by modular CI orchestrator * refactor workflows: replace inline pre-commit configuration with reusable `stage-pre-commit.yml`, integrate pre-commit checks into CI orchestrator * update workflows: remove redundant `os` input, set `ubuntu-latest` as default runner in pre-commit jobs * update workflows: restructure pre-commit checks to run as a standalone job, update dependencies in CI orchestrator * refactor tests: replace `list` method with `list_avds` in AVD management tests and integrations * docs: add comprehensive development guide and update README/CONTRIBUTING with CI/CD details
1 parent 50435ca commit e48d5e7

File tree

108 files changed

+1809
-966
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

108 files changed

+1809
-966
lines changed

.gitattributes

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,4 @@ Makefile text eol=lf
3333
.pre-commit-config.yaml export-ignore
3434
tests/ export-ignore
3535
docs/ export-ignore
36-
*.md export-ignore
36+
*.md export-ignore

.github/workflows/bench.yml

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ name: OVMobileBench CI
22

33
on:
44
push:
5-
branches: [ main, develop ]
5+
branches: [main, develop]
66
pull_request:
7-
branches: [ main ]
7+
branches: [main]
88
workflow_dispatch:
99
inputs:
1010
device_serial:
@@ -17,7 +17,14 @@ concurrency:
1717
cancel-in-progress: true
1818

1919
jobs:
20+
# Run pre-commit only once on ubuntu-latest
21+
pre-commit:
22+
uses: ./.github/workflows/stage-pre-commit.yml
23+
secrets: inherit
24+
25+
# Run CI matrix for all OS after pre-commit passes
2026
ci-matrix:
27+
needs: pre-commit
2128
strategy:
2229
matrix:
2330
os: [ubuntu-latest, macos-latest, windows-latest]

.github/workflows/ci-orchestrator.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,24 +12,24 @@ on:
1212
default: 'emulator-5554'
1313

1414
jobs:
15-
# Stage 1: Lint and Test
16-
lint-test:
17-
uses: ./.github/workflows/stage-lint-test.yml
15+
# Stage 1: Test
16+
test:
17+
uses: ./.github/workflows/stage-test.yml
1818
with:
1919
os: ${{ inputs.os }}
2020
secrets: inherit
2121

2222
# Stage 2: Build Package (runs in parallel with validation)
2323
build:
24-
needs: lint-test
24+
needs: test
2525
uses: ./.github/workflows/stage-build.yml
2626
with:
2727
os: ${{ inputs.os }}
2828
secrets: inherit
2929

3030
# Stage 3: Validation (runs in parallel with build)
3131
validation:
32-
needs: lint-test
32+
needs: test
3333
uses: ./.github/workflows/stage-validation.yml
3434
with:
3535
os: ${{ inputs.os }}

.github/workflows/stage-device-tests.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,8 @@ jobs:
5757

5858
device-test-adb:
5959
if: |
60-
(github.event_name == 'workflow_dispatch' ||
61-
contains(github.event.head_commit.message, '[device-test-adb]')) &&
60+
(github.event_name == 'workflow_dispatch' ||
61+
contains(github.event.head_commit.message, '[device-test-adb]')) &&
6262
inputs.os == 'ubuntu-latest'
6363
runs-on: self-hosted
6464
steps:
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: Pre-commit
2+
3+
on:
4+
workflow_call:
5+
6+
jobs:
7+
pre-commit:
8+
runs-on: ubuntu-latest
9+
steps:
10+
- uses: actions/checkout@v5
11+
with:
12+
fetch-depth: 0 # Fetch all history for all branches
13+
14+
- name: Set up Python
15+
uses: actions/setup-python@v5
16+
with:
17+
python-version: '3.11'
18+
cache: 'pip'
19+
cache-dependency-path: |
20+
requirements.txt
21+
setup.py
22+
23+
- name: Install dependencies
24+
run: |
25+
pip install --upgrade pip
26+
pip install pre-commit
27+
28+
- name: Run pre-commit
29+
run: pre-commit run --all-files --show-diff-on-failure
Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Lint and Test
1+
name: Test
22

33
on:
44
workflow_call:
@@ -8,7 +8,7 @@ on:
88
type: string
99

1010
jobs:
11-
lint-and-test:
11+
test:
1212
runs-on: ${{ inputs.os }}
1313
steps:
1414
- uses: actions/checkout@v5
@@ -30,15 +30,6 @@ jobs:
3030
pip install -r requirements.txt
3131
pip install -e .
3232
33-
- name: Run Black
34-
run: black --check ovmobilebench tests
35-
36-
- name: Run Ruff
37-
run: ruff check ovmobilebench tests
38-
39-
- name: Run MyPy
40-
run: mypy ovmobilebench --ignore-missing-imports
41-
4233
- name: Run tests
4334
run: pytest tests/ -v --cov=ovmobilebench --cov=scripts --junitxml=junit.xml -o junit_family=legacy
4435

.github/workflows/stage-validation.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ jobs:
3030
3131
- name: Validate example config
3232
run: |
33-
python -c "from ovmobilebench.config.loader import load_experiment; load_experiment('experiments/android_example.yaml')"
33+
python -c "from ovmobilebench.config.loader import load_experiment; \
34+
load_experiment('experiments/android_example.yaml')"
3435
3536
- name: CLI help test
3637
run: |

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,3 +136,5 @@ experiments/results/
136136
ovmb_cache
137137
artifacts
138138
junit.xml
139+
140+
*.DS_Store*

.markdownlint.json

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"default": true,
3+
"MD013": false,
4+
"MD033": {
5+
"allowed_elements": ["br", "sup", "sub", "details", "summary", "img", "API", "arch", "target"]
6+
},
7+
"MD041": false,
8+
"MD024": {
9+
"siblings_only": true
10+
},
11+
"MD040": false,
12+
"MD025": false,
13+
"MD036": false,
14+
"MD028": false,
15+
"MD051": false,
16+
"MD046": false,
17+
"MD001": false
18+
}

.pre-commit-config.yaml

Lines changed: 30 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,12 @@ repos:
1818
- id: name-tests-test
1919
args: ['--pytest-test-first']
2020

21+
- repo: https://github.com/asottile/pyupgrade
22+
rev: v3.19.1
23+
hooks:
24+
- id: pyupgrade
25+
args: ['--py311-plus']
26+
2127
- repo: https://github.com/psf/black
2228
rev: 24.4.2
2329
hooks:
@@ -35,28 +41,43 @@ repos:
3541
rev: v1.10.0
3642
hooks:
3743
- id: mypy
38-
additional_dependencies: [types-all]
44+
additional_dependencies: [types-PyYAML, types-paramiko]
3945
args: ['--ignore-missing-imports']
40-
exclude: '^tests/'
46+
files: '^ovmobilebench/(?!android/installer/).*\.py$'
4147

4248
- repo: https://github.com/pycqa/isort
4349
rev: 5.13.2
4450
hooks:
4551
- id: isort
4652
args: ['--profile', 'black', '--line-length', '100']
4753

48-
- repo: https://github.com/pycqa/docformatter
49-
rev: v1.7.5
50-
hooks:
51-
- id: docformatter
52-
args: ['--in-place', '--wrap-summaries', '100', '--wrap-descriptions', '100']
53-
5454
- repo: https://github.com/commitizen-tools/commitizen
5555
rev: v3.27.0
5656
hooks:
5757
- id: commitizen
5858
stages: [commit-msg]
5959

60+
- repo: https://github.com/adrienverge/yamllint
61+
rev: v1.35.1
62+
hooks:
63+
- id: yamllint
64+
args: ['--strict']
65+
66+
- repo: https://github.com/igorshubovych/markdownlint-cli
67+
rev: v0.43.0
68+
hooks:
69+
- id: markdownlint
70+
args: ['--fix']
71+
72+
- repo: https://github.com/codespell-project/codespell
73+
rev: v2.3.0
74+
hooks:
75+
- id: codespell
76+
args: ['--skip=*.json,*.yaml,*.yml,*.txt,*.csv,*.lock', '--ignore-words-list=nd,teh,hist']
77+
6078
ci:
6179
autofix_prs: false
62-
autoupdate_schedule: monthly
80+
autoupdate_schedule: weekly
81+
autoupdate_commit_msg: '[pre-commit.ci] pre-commit autoupdate'
82+
skip: []
83+
submodules: false

0 commit comments

Comments
 (0)