Skip to content

Fix CI: use cross-platform pip cache paths #3

Fix CI: use cross-platform pip cache paths

Fix CI: use cross-platform pip cache paths #3

Workflow file for this run

name: CI
on:
push:
branches: [ main, develop ]
pull_request:
branches: [ main, develop ]
jobs:
test:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
python-version: ['3.8', '3.9', '3.10', '3.11']
fail-fast: false
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install system dependencies (Ubuntu)
if: runner.os == 'Linux'
run: |
sudo apt-get update
sudo apt-get install -y ffmpeg
- name: Install system dependencies (macOS)
if: runner.os == 'macOS'
run: |
brew install ffmpeg
- name: Install system dependencies (Windows)
if: runner.os == 'Windows'
run: |
choco install ffmpeg -y
- name: Cache pip packages
uses: actions/cache@v3
with:
path: |
~/.cache/pip
~/Library/Caches/pip
~\AppData\Local\pip\Cache
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip-
- name: Install Python dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
- name: Verify ffmpeg installation
run: ffmpeg -version
- name: Run tests with pytest
run: |
pytest test_normal_modes.py -v --tb=short
- name: Run tests with coverage
run: |
pytest test_normal_modes.py --cov=. --cov-report=xml --cov-report=html --cov-report=term
- name: Upload coverage to artifacts
uses: actions/upload-artifact@v4
if: matrix.os == 'ubuntu-latest' && matrix.python-version == '3.11'
with:
name: coverage-report
path: htmlcov/
- name: Test script execution (basic smoke test)
run: |
python normal_modes.py --num-masses 3 --mode 1 --duration 0.5 --outfile test_ci.mp4
- name: Verify output file created
run: |
python -c "import os; assert os.path.exists('test_ci.mp4'), 'Output file not created'"
- name: Upload test video artifact
uses: actions/upload-artifact@v4
if: matrix.os == 'ubuntu-latest' && matrix.python-version == '3.11'
with:
name: test-video
path: test_ci.mp4
lint:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.11'
- name: Install linting tools
run: |
python -m pip install --upgrade pip
pip install flake8 pylint
- name: Run flake8
run: |
# Stop the build if there are Python syntax errors or undefined names
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
# Exit-zero treats all errors as warnings
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=100 --statistics
continue-on-error: true
- name: Run pylint
run: |
pylint normal_modes.py --exit-zero
continue-on-error: true
security:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.11'
- name: Install security tools
run: |
python -m pip install --upgrade pip
pip install bandit safety
- name: Run bandit security check
run: |
bandit -r . -f json -o bandit-report.json || true
bandit -r . || true
continue-on-error: true
- name: Run safety check
run: |
pip install -r requirements.txt
safety check --json || true
continue-on-error: true
docs:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Verify README exists
run: |
test -f README.md || exit 1
- name: Check README formatting
run: |
# Check for basic markdown structure
grep -q "# Normal Modes" README.md || exit 1
grep -q "## Installation" README.md || exit 1
grep -q "## Usage" README.md || exit 1
- name: Verify CLAUDE.md exists
run: |
test -f CLAUDE.md || exit 1
- name: Check for LICENSE
run: |
echo "Note: Add a LICENSE file to your repository"
continue-on-error: true