|
| 1 | +name: CI Tests |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [main] |
| 6 | + pull_request: |
| 7 | + branches: [main] |
| 8 | + |
| 9 | +permissions: |
| 10 | + contents: read |
| 11 | + |
| 12 | +jobs: |
| 13 | + lint: |
| 14 | + name: Lint |
| 15 | + runs-on: ubuntu-latest |
| 16 | + timeout-minutes: 5 |
| 17 | + |
| 18 | + steps: |
| 19 | + - name: Checkout code |
| 20 | + uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 |
| 21 | + |
| 22 | + - name: Set up Python |
| 23 | + uses: actions/setup-python@e797f83bcb11b83ae66e0230d6156d7c80228e7c # v6.0.0 |
| 24 | + with: |
| 25 | + python-version: '3.12' |
| 26 | + cache: 'pip' |
| 27 | + |
| 28 | + - name: Install ruff |
| 29 | + run: pip install ruff |
| 30 | + |
| 31 | + - name: Run ruff check |
| 32 | + run: ruff check scripts/ tests/ --output-format=github |
| 33 | + |
| 34 | + test: |
| 35 | + name: Test Python ${{ matrix.python-version }} |
| 36 | + runs-on: ubuntu-latest |
| 37 | + timeout-minutes: 15 |
| 38 | + needs: lint |
| 39 | + |
| 40 | + strategy: |
| 41 | + matrix: |
| 42 | + python-version: ['3.11', '3.12', '3.13'] |
| 43 | + fail-fast: false |
| 44 | + |
| 45 | + steps: |
| 46 | + - name: Checkout code |
| 47 | + uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 |
| 48 | + |
| 49 | + - name: Set up Python ${{ matrix.python-version }} |
| 50 | + uses: actions/setup-python@e797f83bcb11b83ae66e0230d6156d7c80228e7c # v6.0.0 |
| 51 | + with: |
| 52 | + python-version: ${{ matrix.python-version }} |
| 53 | + cache: 'pip' |
| 54 | + |
| 55 | + - name: Install dependencies |
| 56 | + run: | |
| 57 | + python -m pip install --upgrade pip |
| 58 | + pip install -r requirements.txt |
| 59 | + if [ -f tests/requirements.txt ]; then pip install -r tests/requirements.txt; fi |
| 60 | + pip install pytest pytest-cov pytest-mock pytest-timeout |
| 61 | +
|
| 62 | + - name: Run tests with coverage |
| 63 | + run: | |
| 64 | + cd scripts && python -m pytest ../tests/ -v --tb=short -x --timeout=120 \ |
| 65 | + --cov=. --cov-report=term-missing --cov-report=xml:../coverage.xml --cov-report=html:../htmlcov |
| 66 | +
|
| 67 | + - name: Upload coverage report |
| 68 | + if: matrix.python-version == '3.12' && always() |
| 69 | + uses: actions/upload-artifact@50769540e7f4bd5e21e526ee35c689e35e0d6874 # v4.4.0 |
| 70 | + with: |
| 71 | + name: coverage-report |
| 72 | + path: htmlcov/ |
| 73 | + retention-days: 14 |
| 74 | + |
| 75 | + - name: Test summary |
| 76 | + if: always() |
| 77 | + run: | |
| 78 | + echo "## Test Results" >> $GITHUB_STEP_SUMMARY |
| 79 | + echo "" >> $GITHUB_STEP_SUMMARY |
| 80 | + echo "**Python Version:** ${{ matrix.python-version }}" >> $GITHUB_STEP_SUMMARY |
| 81 | + echo "**Status:** ${{ job.status }}" >> $GITHUB_STEP_SUMMARY |
0 commit comments