Test Structure Reorganization and CI Improvements (#5)

* Add GitHub Actions CI/CD workflows and status badges

* Fix CI workflow dependency installation

* Fix CI workflow: remove pip caching and add explicit requirements.txt

* Fix CI workflow: add system dependencies for PyGObject and pycairo

* Refactor code for improved readability and consistency

- Cleaned up whitespace and formatting in audio_feedback.py, config_manager.py, keyboard_shortcuts.py, tray_indicator.py, run_basic_tests.py, and test_basic.py.
- Enhanced the structure of the code by aligning comments and ensuring consistent indentation.
- Updated function definitions and calls to maintain a uniform style across the codebase.
- Improved logging messages for better clarity during debugging.
- Ensured all files end with a newline for better compatibility with various tools.

* Refactor imports for consistency and clarity across multiple modules

* Fix test imports by setting PYTHONPATH and adding conftest.py

* Update CI workflow to use Python 3.12 and ensure proper import path in tests

* Fix CI: Add GObject Introspection development dependencies

* Update CI: Use virtual environment like local setup

* Fix CI

* Update README and setup.py: Change Python version to 3.8 and correct author email

* Restructure tests for better organization and maintainability

* Fix formatting

* Update CI workflow to remove redundant test step

* Fix CI tests by properly mocking VOSK model loading

* Update CI and Tests

* Simplify
This commit is contained in:
Jatin K Malik
2025-04-16 20:23:40 -05:00
committed by GitHub
parent 7590332598
commit 3645c692fd
20 changed files with 996 additions and 682 deletions
+108
View File
@@ -0,0 +1,108 @@
name: Vocalinux CI
on:
push:
branches: [ main, master ]
paths-ignore:
- '**.md'
- 'docs/**'
pull_request:
branches: [ main, master ]
paths-ignore:
- '**.md'
- 'docs/**'
jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.10'
cache: 'pip'
cache-dependency-path: 'setup.py'
- name: Install development dependencies
run: |
python -m pip install --upgrade pip
python -m pip install flake8 black isort
- name: Lint with flake8
run: |
# stop the build if there are Python syntax errors or undefined names
flake8 src/ tests/ --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings
flake8 src/ tests/ --count --exit-zero --max-complexity=10 --max-line-length=100 --statistics
- name: Check formatting with black
run: |
black --check src/ tests/
- name: Check import sorting with isort
run: |
isort --check-only --profile black src/ tests/
test:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: [3.8]
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
cache: 'pip'
cache-dependency-path: 'setup.py'
- name: Install system dependencies
run: |
sudo apt-get update
sudo apt-get install -y \
xdotool \
python3-gi \
gir1.2-appindicator3-0.1 \
libcairo2-dev \
pkg-config \
python3-dev \
libgirepository1.0-dev \
gobject-introspection \
libcairo-gobject2 \
gir1.2-gtk-3.0
- name: Cache apt packages
uses: actions/cache@v3
with:
path: /var/cache/apt/archives
key: ${{ runner.os }}-apt-${{ hashFiles('**/apt-packages.txt') }}
restore-keys: |
${{ runner.os }}-apt-
- name: Set up virtual environment
run: |
python -m venv venv
source venv/bin/activate
python -m pip install --upgrade pip
# Install the package in development mode with dev dependencies
python -m pip install -e ".[dev]"
python -m pip install pytest pytest-cov
echo "VIRTUAL_ENV=$VIRTUAL_ENV" >> $GITHUB_ENV
echo "PATH=$VIRTUAL_ENV/bin:$PATH" >> $GITHUB_ENV
- name: Run pytest suite with coverage
run: |
source venv/bin/activate
# Make sure Python can find the 'src' module
PYTHONPATH=$PWD pytest --cov=src tests/
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
with:
fail_ci_if_error: false