CI #795
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: CI | |
on: | |
push: | |
branches: | |
- main | |
- dev | |
pull_request: ~ | |
schedule: | |
- cron: "0 0 * * *" | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} | |
cancel-in-progress: true | |
jobs: | |
prepare: | |
name: Preparation | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
python-version: [3.11, 3.12] | |
outputs: | |
pip_cache_dir: ${{ steps.pip-cache.outputs.dir }} | |
steps: | |
- name: Checkout | |
uses: actions/[email protected] | |
- name: Set up Python ${{ matrix.python-version }} | |
uses: actions/[email protected] | |
with: | |
python-version: ${{ matrix.python-version }} | |
- name: Get pip cache directory path | |
id: pip-cache | |
run: echo "dir=$(pip cache dir)" >> $GITHUB_ENV | |
- name: Cache pip dependencies | |
uses: actions/cache@v4 | |
with: | |
path: ${{ env.dir }} | |
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt', '**/requirements_test.txt') }} | |
restore-keys: | | |
${{ runner.os }}-pip- | |
- name: Install project dependencies | |
run: | | |
pip install -r requirements.txt | |
- name: Install test dependencies | |
run: | | |
pip install -r requirements_test.txt | |
unit-tests: | |
name: Unit Tests | |
needs: prepare | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
python-version: [3.11, 3.12] | |
steps: | |
- name: Checkout | |
uses: actions/[email protected] | |
- name: Set up Python ${{ matrix.python-version }} | |
uses: actions/[email protected] | |
with: | |
python-version: ${{ matrix.python-version }} | |
- name: Get pip cache directory path | |
id: pip-cache | |
run: echo "dir=$(pip cache dir)" >> $GITHUB_ENV | |
- name: Cache pip dependencies | |
uses: actions/cache@v4 | |
with: | |
path: ${{ env.dir }} | |
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt', '**/requirements_test.txt') }} | |
restore-keys: | | |
${{ runner.os }}-pip- | |
- name: Install project dependencies | |
run: | | |
pip install -r requirements.txt | |
- name: Install test dependencies | |
run: | | |
pip install -r requirements_test.txt | |
- name: Run unit tests | |
run: | | |
pytest --cov=asusrouter --cov-report=xml:unit-tests-cov-${{ matrix.python-version }}.xml -k 'not test_devices' | |
- name: Upload coverage to artifacts | |
uses: actions/[email protected] | |
with: | |
name: unit-tests-cov-${{ matrix.python-version }} | |
path: unit-tests-cov-${{ matrix.python-version }}.xml | |
device-tests: | |
name: Device Tests | |
needs: prepare | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
python-version: [3.11, 3.12] | |
steps: | |
- name: Checkout | |
uses: actions/[email protected] | |
- name: Set up Python ${{ matrix.python-version }} | |
uses: actions/[email protected] | |
with: | |
python-version: ${{ matrix.python-version }} | |
- name: Get pip cache directory path | |
id: pip-cache | |
run: echo "dir=$(pip cache dir)" >> $GITHUB_ENV | |
- name: Cache pip dependencies | |
uses: actions/cache@v4 | |
with: | |
path: ${{ env.dir }} | |
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt', '**/requirements_test.txt') }} | |
restore-keys: | | |
${{ runner.os }}-pip- | |
- name: Install project dependencies | |
run: | | |
pip install -r requirements.txt | |
- name: Install test dependencies | |
run: | | |
pip install -r requirements_test.txt | |
- name: Run real-data tests | |
run: | | |
pytest --cov=asusrouter --cov-report=xml:real-data-tests-cov-${{ matrix.python-version }}.xml tests/test_devices.py --log-cli-level=INFO | |
- name: Upload coverage to artifacts | |
uses: actions/[email protected] | |
with: | |
name: real-data-tests-cov-${{ matrix.python-version }} | |
path: real-data-tests-cov-${{ matrix.python-version }}.xml | |
codecov: | |
name: Codecov | |
needs: [unit-tests, device-tests] | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
python-version: [3.11, 3.12] | |
steps: | |
- name: Checkout | |
uses: actions/[email protected] | |
- name: Download unit-tests coverage from artifacts | |
uses: actions/[email protected] | |
with: | |
name: unit-tests-cov-${{ matrix.python-version }} | |
path: . | |
- name: Download real-data-tests coverage from artifacts | |
uses: actions/[email protected] | |
with: | |
name: real-data-tests-cov-${{ matrix.python-version }} | |
path: . | |
- name: Upload coverage to Codecov | |
uses: codecov/[email protected] | |
with: | |
token: ${{ secrets.CODECOV_TOKEN }} | |
fail_ci_if_error: true | |
files: unit-tests-cov-${{ matrix.python-version }}.xml,real-data-tests-cov-${{ matrix.python-version }}.xml |