no longer include the test folder in the build #120
This file contains hidden or 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
# Workflow to test the USBIP client | |
name: USBIP CDC Client | |
on: [ push, pull_request ] | |
permissions: | |
contents: read | |
jobs: | |
build: | |
permissions: | |
contents: write | |
strategy: | |
matrix: | |
python-version: [ 3.11, 3.12 ] | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up Python ${{ matrix.python-version }} | |
uses: actions/setup-python@v5 | |
with: | |
python-version: ${{ matrix.python-version }} | |
architecture: "x64" | |
- name: Get pip cache dir | |
id: pip-cache | |
run: echo "dir=$(pip cache dir)" >> $GITHUB_OUTPUT | |
- name: Setup caching | |
uses: actions/cache@v4 | |
with: | |
path: ${{ steps.pip-cache.outputs.dir }} | |
key: pip-${{ matrix.python-version }} | |
restore-keys: | | |
pip-${{ matrix.python-version }} | |
- name: Install poetry | |
run: | | |
pip install poetry==1.8.0 | |
- name: Configure poetry | |
run: | | |
poetry config virtualenvs.in-project true | |
- name: Install dependencies | |
run: | | |
poetry install --with tests | |
- name: lint | |
run: | | |
poetry run pylint serial_usbipclient/* | |
- name: mypy type checking | |
run: | | |
poetry run mypy serial_usbipclient | |
- name: radon code analysis | |
run: | | |
# run complexity check on specific files since we can't exclude files/folders/etc. | |
poetry run radon cc serial_usbipclient/protocol serial_usbipclient/usbip_client.py serial_usbipclient/socket_wrapper.py -a | |
- name: xenon code analysis | |
run: | | |
# Xenon will run radon and fail if threshold is exceeded. | |
poetry run xenon -m B -b B serial_usbipclient/protocol serial_usbipclient/usbip_client.py serial_usbipclient/socket_wrapper.py | |
- name: Test & generate coverage | |
run: | | |
chmod +x run_pytest.sh | |
./run_pytest.sh | |
- name: Generate Coverage badge | |
if: github.ref_name != 'master' && matrix.python-version == '3.12' | |
uses: tj-actions/coverage-badge-py@v2 | |
- name: Verify Changed files | |
uses: tj-actions/verify-changed-files@v20 | |
id: verify-changed-files | |
with: | |
# If this file has changed, we want to re-commit to the store | |
files: coverage.svg | |
- name: Commit files | |
if: steps.verify-changed-files.outputs.files_changed == 'true' | |
run: | | |
git config --local user.email "github-actions[bot]@users.noreply.git" | |
git config --local user.name "github-actions[bot]" | |
git add coverage.svg | |
git commit -am "Updated coverage.svg" | |
- name: Push changes | |
if: steps.verify-changed-files.outputs.files_changed == 'true' | |
uses: ad-m/github-push-action@master | |
with: | |
github_token: ${{ secrets.github_token }} | |
branch: ${{ github.ref }} | |
- name: Coveralls Parallel | |
env: | |
COVERALLS_FLAG_NAME: ${{ matrix.test-number }} | |
COVERALLS_PARALLEL: true | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
COVERALLS_SERVICE_NAME: github | |
run: | | |
pip install coveralls | |
coveralls | |
coveralls: | |
needs: build | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/setup-python@v5 | |
with: | |
python-version: 3.x | |
- name: Coveralls Finished | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
COVERALLS_SERVICE_NAME: github | |
run: | | |
pip install coveralls | |
coveralls --finish |