Skip to content

Commit

Permalink
Improve GitHub workflows to use Ruff
Browse files Browse the repository at this point in the history
Ruff should catch cross-version issues, so we don't need to lint on all
versions.
  • Loading branch information
Athesdrake committed Jun 16, 2024
1 parent 5a5d8a2 commit 77bfa0d
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 49 deletions.
33 changes: 10 additions & 23 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -1,34 +1,21 @@
name: Lint with flake8
name: Lint with ruff

on: [push, pull_request]

jobs:
lint:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ['3.7', '3.8', '3.9', '3.10']
steps:
- uses: actions/checkout@v1
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v1
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Cache dependencies
uses: actions/cache@v2
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip-
${{ runner.os }}-
python-version: "3.12"
- run: python my_script.py
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install flake8
pip install -r requirements.txt
- name: Lint with flake8
run: |
flake8 --count --statistics
- name: Check errors with pylint
run: pylint aiotfm --disable=all --enable=E
pip install -r .[dev]
- name: Lint with ruff
run: ruff check
- name: Format with ruff
run: ruff format --check
48 changes: 22 additions & 26 deletions .github/workflows/pythonpublish.yml
Original file line number Diff line number Diff line change
@@ -1,53 +1,49 @@
name: Upload Python Package

on:
workflow_dispatch:
push:
branches:
- master
paths:
- 'aiotfm/__version__.py'
workflow_dispatch:
push:
branches:
- master
paths:
- "aiotfm/__version__.py"

jobs:
lint:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ['3.7', '3.8', '3.9', '3.10']
steps:
- uses: actions/checkout@v1
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v1
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
python-version: "3.12"
- run: python my_script.py
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install flake8 pylint
pip install -r requirements.txt
# cancel the build if a syntax error or an undefined name is found.
- name: Check errors with flake8
run: flake8 aiotfm --count --select F6,F7,F82,E9
- name: Check errors with pylint
run: pylint aiotfm --disable=all --enable=E
pip install -r .[dev]
# Cancel the build if ruff detects something wrong
- name: Lint with ruff
run: ruff check
- name: Format with ruff
run: ruff format --check
deploy:
needs: lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v1
uses: actions/setup-python@v5
with:
python-version: '3.7'
python-version: "3.12"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install setuptools wheel twine
pip install -r requirements.txt
pip install setuptools wheel twine build
pip install .
- name: Build and publish
env:
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
run: |
python setup.py sdist bdist_wheel
python -m build
twine upload dist/*

0 comments on commit 77bfa0d

Please sign in to comment.