|
| 1 | +name: CI |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: ["main"] |
| 6 | + pull_request: |
| 7 | + branches: ["main"] |
| 8 | + workflow_dispatch: |
| 9 | + workflow_call: |
| 10 | + |
| 11 | +permissions: |
| 12 | + contents: read |
| 13 | + |
| 14 | +env: |
| 15 | + FORCE_COLOR: "1" # Make tools pretty. |
| 16 | + PYTHON_LATEST: "3.11" |
| 17 | + POETRY_VIRTUALENVS_CREATE: false |
| 18 | + |
| 19 | + |
| 20 | +jobs: |
| 21 | + linting: |
| 22 | + name: Linting |
| 23 | + runs-on: ubuntu-latest |
| 24 | + |
| 25 | + steps: |
| 26 | + - uses: actions/checkout@v3 |
| 27 | + - uses: actions/setup-python@v4 |
| 28 | + with: |
| 29 | + python-version: ${{ env.PYTHON_LATEST }} |
| 30 | + - uses: snok/install-poetry@v1 |
| 31 | + with: |
| 32 | + version: 1.3.0 |
| 33 | + virtualenvs-create: true |
| 34 | + - name: Install dependencies |
| 35 | + run: | |
| 36 | + poetry self add "poetry-dynamic-versioning[plugin]" |
| 37 | + poetry install --only=dev |
| 38 | +
|
| 39 | + - name: black |
| 40 | + run: python -m black --check --diff . |
| 41 | + |
| 42 | + - name: flake8 |
| 43 | + run: python -m flake8 . |
| 44 | + |
| 45 | + - name: isort |
| 46 | + run: python -m isort --check-only -v --profile black . |
| 47 | + |
| 48 | + typing: |
| 49 | + name: Typing |
| 50 | + runs-on: ubuntu-latest |
| 51 | + |
| 52 | + steps: |
| 53 | + - uses: actions/checkout@v3 |
| 54 | + - uses: actions/setup-python@v4 |
| 55 | + with: |
| 56 | + python-version: ${{ env.PYTHON_LATEST }} |
| 57 | + - uses: snok/install-poetry@v1 |
| 58 | + with: |
| 59 | + version: 1.3.0 |
| 60 | + virtualenvs-create: true |
| 61 | + - name: Install dependencies |
| 62 | + run: | |
| 63 | + poetry self add "poetry-dynamic-versioning[plugin]" |
| 64 | + poetry install |
| 65 | +
|
| 66 | + - name: mypy |
| 67 | + run: python -m mypy . |
| 68 | + |
| 69 | + |
| 70 | + tests: |
| 71 | + name: tests on ${{ matrix.python-version }} |
| 72 | + runs-on: ubuntu-22.04 |
| 73 | + strategy: |
| 74 | + fail-fast: false |
| 75 | + matrix: |
| 76 | + python-version: ["3.10", "3.11"] |
| 77 | + |
| 78 | + steps: |
| 79 | + - uses: actions/checkout@v3 |
| 80 | + - uses: actions/setup-python@v4 |
| 81 | + with: |
| 82 | + python-version: ${{ matrix.python-version }} |
| 83 | + - uses: snok/install-poetry@v1 |
| 84 | + with: |
| 85 | + version: 1.3.0 |
| 86 | + virtualenvs-create: true |
| 87 | + - name: Install dependencies |
| 88 | + run: | |
| 89 | + poetry self add "poetry-dynamic-versioning[plugin]" |
| 90 | + poetry install |
| 91 | +
|
| 92 | + - name: Setup Git |
| 93 | + run: | |
| 94 | + git config --global user.email "[email protected]" |
| 95 | + git config --global user.name "Your Name" |
| 96 | +
|
| 97 | + - run: poetry run pytest --cov=foxops_client |
| 98 | + env: |
| 99 | + COVERAGE_FILE: .coverage.${{ matrix.python-version }} |
| 100 | + |
| 101 | + - name: Upload coverage data |
| 102 | + uses: actions/upload-artifact@v3 |
| 103 | + with: |
| 104 | + name: coverage-data |
| 105 | + path: .coverage.* |
| 106 | + if-no-files-found: ignore |
| 107 | + |
| 108 | + |
| 109 | + coverage: |
| 110 | + name: Combine & check coverage |
| 111 | + runs-on: ubuntu-latest |
| 112 | + needs: [tests] |
| 113 | + |
| 114 | + steps: |
| 115 | + - uses: actions/checkout@v3 |
| 116 | + - uses: actions/setup-python@v4 |
| 117 | + with: |
| 118 | + python-version: ${{env.PYTHON_LATEST}} |
| 119 | + - run: python -m pip install --upgrade coverage[toml] |
| 120 | + - uses: actions/download-artifact@v3 |
| 121 | + with: |
| 122 | + name: coverage-data |
| 123 | + - name: Combine coverage & fail if it's <70%. |
| 124 | + run: | |
| 125 | + python -m coverage combine |
| 126 | + python -m coverage html --skip-covered --skip-empty |
| 127 | + python -m coverage report --fail-under=70 |
| 128 | + - name: Upload HTML report |
| 129 | + uses: actions/upload-artifact@v3 |
| 130 | + with: |
| 131 | + name: html-report |
| 132 | + path: htmlcov |
| 133 | + |
| 134 | + |
| 135 | + package: |
| 136 | + name: Build & verify package |
| 137 | + runs-on: ubuntu-latest |
| 138 | + |
| 139 | + steps: |
| 140 | + - uses: actions/checkout@v3 |
| 141 | + - uses: actions/setup-python@v4 |
| 142 | + with: |
| 143 | + python-version: ${{ env.PYTHON_LATEST }} |
| 144 | + |
| 145 | + - run: python -m pip install build twine check-wheel-contents |
| 146 | + - run: python -m build --sdist --wheel . |
| 147 | + - run: ls -l dist |
| 148 | + - run: check-wheel-contents dist/*.whl |
| 149 | + - name: Check long_description |
| 150 | + run: python -m twine check dist/* |
| 151 | + |
| 152 | + |
| 153 | + install-dev: |
| 154 | + name: Verify dev env |
| 155 | + runs-on: ${{ matrix.os }} |
| 156 | + strategy: |
| 157 | + fail-fast: false |
| 158 | + matrix: |
| 159 | + os: [ubuntu-latest, macos-latest, windows-latest] |
| 160 | + |
| 161 | + steps: |
| 162 | + - uses: actions/checkout@v3 |
| 163 | + - uses: actions/setup-python@v4 |
| 164 | + with: |
| 165 | + python-version: ${{ env.PYTHON_LATEST }} |
| 166 | + - run: python -m pip install -e . |
| 167 | + - run: python -c 'import foxops_client; print(foxops_client.__version__)' |
0 commit comments