Update ci workflow #69
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", "ci"] | |
pull_request: | |
branches: ["main"] | |
permissions: | |
contents: read | |
env: | |
POETRY_VERSION: 1.8.2 | |
defaults: | |
run: | |
shell: bash | |
jobs: | |
lint-and-test: | |
name: 🎨🚦 Lint & Test | |
runs-on: ${{ matrix.os }} | |
strategy: | |
matrix: | |
os: ["ubuntu-latest", "macos-latest", "windows-latest"] | |
python-version: ["3.9", "3.10", "3.11", "3.12"] | |
steps: | |
- name: ✨ Check out repository | |
uses: actions/checkout@v3 | |
- name: Add Poetry to PATH | |
run: | | |
echo ~/.poetry/bin >> $GITHUB_PATH | |
echo ~/.poetry/Scripts >> $GITHUB_PATH | |
- if: ${{ runner.os == 'Windows' }} | |
name: Use GNU tar | |
shell: cmd | |
run: | | |
echo "Adding GNU tar to PATH" | |
echo C:\Program Files\Git\usr\bin>>"%GITHUB_PATH%" | |
- name: ⚙️ Cache Poetry ${{ env.POETRY_VERSION }} | |
id: cache-poetry | |
uses: actions/cache@v3 | |
with: | |
path: ~/.poetry | |
key: poetry-${{ env.POETRY_VERSION }}-py${{ matrix.python-version }}-${{ runner.os }} | |
- name: ⚙️ Install Poetry ${{ env.POETRY_VERSION }} | |
if: ${{ steps.cache-poetry.outputs.cache-hit != 'true' }} | |
run: | | |
python3 -mvenv ~/.poetry | |
pip install poetry==${POETRY_VERSION} | |
poetry config virtualenvs.in-project true --local | |
poetry --version | |
- name: ⚙️ Set up Python ${{ matrix.python-version }} | |
uses: actions/setup-python@v5 | |
with: | |
python-version: ${{ matrix.python-version }} | |
- name: ⚙️ Cache dependencies | |
id: cache-deps | |
uses: actions/cache@v3 | |
with: | |
path: .venv | |
key: deps-${{ hashFiles('**/poetry.lock') }}-py${{ matrix.python-version }}-${{ runner.os }} | |
- name: 📦 Install dependencies | |
if: ${{ steps.cache-deps.outputs.cache-hit != 'true' }} | |
run: poetry install --no-interaction --no-root | |
- name: 📦 Install project | |
run: poetry install --no-interaction --only-root | |
- name: 🎨 isort | |
run: poetry run isort --check-only --verbose **/*.py | |
- name: 🎨 black | |
run: poetry run black --check . | |
- name: 🎨 pylint | |
run: | |
poetry run pylint surblclient tests | |
# stop the build if there are Python syntax errors or undefined names | |
# poetry run flake8 . --extend-exclude .venv --count --select=E9,F63,F7,F82 --show-source --statistics | |
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide | |
# poetry run flake8 . --extend-exclude .venv --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics | |
- name: 🚦 Test with pytest | |
run: poetry run pytest --cov=surblclient |