Skip to content

Commit

Permalink
Update GitHub tests workflow (#385)
Browse files Browse the repository at this point in the history
  • Loading branch information
Vaskivskyi authored Nov 20, 2023
1 parent 057bdec commit b36b52e
Showing 1 changed file with 101 additions and 6 deletions.
107 changes: 101 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:
- dev
pull_request: ~
schedule:
- cron: '0 0 * * *'
- cron: "0 0 * * *"

env:
DEFAULT_PYTHON: 3.11
Expand All @@ -17,8 +17,10 @@ concurrency:
cancel-in-progress: true

jobs:
test:
prepare:
runs-on: ubuntu-latest
outputs:
pip_cache_dir: ${{ steps.pip-cache.outputs.dir }}
steps:
- name: Checkout
uses: actions/[email protected]
Expand All @@ -30,19 +32,51 @@ jobs:

- name: Get pip cache directory path
id: pip-cache
run: echo "PIP_CACHE_DIR=$(pip cache dir)" >> $GITHUB_ENV
run: echo "dir=$(pip cache dir)" >> $GITHUB_ENV

- name: Cache pip dependencies
uses: actions/[email protected]
with:
path: ${{ env.PIP_CACHE_DIR }}
key: ${{ runner.os }}-pip-${{ hashFiles('**/pyproject.toml') }}
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 .
pip install -r requirements.txt
- name: Install test dependencies
run: |
pip install -r requirements_test.txt
unit-tests:
needs: prepare
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/[email protected]

- name: Set up Python ${{ env.DEFAULT_PYTHON }}
uses: actions/[email protected]
with:
python-version: ${{ env.DEFAULT_PYTHON }}

- name: Get pip cache directory path
id: pip-cache
run: echo "dir=$(pip cache dir)" >> $GITHUB_ENV

- name: Cache pip dependencies
uses: actions/[email protected]
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: |
Expand All @@ -52,10 +86,71 @@ jobs:
run: |
pytest --cov=asusrouter --cov-report=xml:unit-tests-cov.xml -k 'not test_devices'
- name: Upload coverage to artifacts
uses: actions/[email protected]
with:
name: unit-tests-cov
path: unit-tests-cov.xml

device-tests:
needs: prepare
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/[email protected]

- name: Set up Python ${{ env.DEFAULT_PYTHON }}
uses: actions/[email protected]
with:
python-version: ${{ env.DEFAULT_PYTHON }}

- name: Get pip cache directory path
id: pip-cache
run: echo "dir=$(pip cache dir)" >> $GITHUB_ENV

- name: Cache pip dependencies
uses: actions/[email protected]
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.xml tests/test_devices.py --log-cli-level=INFO
- name: Upload coverage to artifacts
uses: actions/[email protected]
with:
name: real-data-tests-cov
path: real-data-tests-cov.xml

codecov:
needs: [unit-tests, device-tests]
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/[email protected]

- name: Download coverage from artifacts
uses: actions/[email protected]
with:
name: unit-tests-cov
path: .
- uses: actions/[email protected]
with:
name: real-data-tests-cov
path: .

- name: Upload coverage to Codecov
uses: codecov/[email protected]
with:
Expand Down

0 comments on commit b36b52e

Please sign in to comment.