Update build.yml #15
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: | |
pull_request_target: | |
types: | |
- opened | |
- synchronize | |
push: | |
branches: | |
- master | |
permissions: | |
contents: read | |
jobs: | |
authorize: | |
name: Authorize | |
environment: ${{ github.event_name == 'pull_request_target' && github.event.pull_request.head.repo.full_name != github.repository && 'external' || 'internal' }} | |
runs-on: ubuntu-latest | |
steps: | |
- run: true | |
build-and-test: | |
needs: authorize # Require approval before running on forked pull requests | |
name: Build and Test | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11"] | |
steps: | |
- name: Update network connectivity | |
run: | | |
sudo ethtool -K eth0 tx off rx off | |
install bwrap unshare | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
- name: Configure Python ${{ matrix.python-version }} | |
uses: actions/setup-python@v4 | |
with: | |
python-version: "${{ matrix.python-version }}" | |
- name: Install dependencies | |
run: | | |
python3 -m pip install --upgrade pip | |
python3 -m pip install pytest pytest-cov flake8 pyupgrade isort black pre-commit | |
if [ -f requirements.txt ]; then python3 -m pip install -r requirements.txt; fi | |
if [ -f requirements-dev.txt ]; then python3 -m pip install -r requirements.txt-dev; fi | |
- name: Run tests | |
run: | | |
bwrap --bind / / --dev /dev --unshare-net python3 -m coverage run -m unittest | |
- name: Run linting | |
run: pre-commit run --all-files | |
- if: ${{ matrix.python-version == '3.10' }} | |
name: Upload coverage | |
uses: codecov/codecov-action@eaaf4bedf32dbdc6b720b63067d99c4d77d6047d # pin@3.1.4 | |
with: | |
directory: ./coverage/reports/ | |
env_vars: OS,PYTHON | |
fail_ci_if_error: true | |
files: ./coverage.xml | |
flags: unittests | |
name: codecov-umbrella | |
verbose: true | |
- if: ${{ matrix.python-version == '3.10' }} | |
name: Build documentation | |
run: sphinx-build ./docs/source ./docs/build --keep-going -n -a -b html |