Skip to content

Library Checks

Library Checks #20

Workflow file for this run

name: "Library Checks"
on:
push:
paths:
- "discord/**"
- "requirements/**"
- "*.toml"
- "*.py"
- ".*"
branches: [master]
pull_request:
paths:
- "discord/**"
- "requirements/**"
- "*.toml"
- "*.py"
- ".*"
workflow_dispatch:
schedule:
- cron: "0 0 * * *"
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
permissions: write-all
jobs:
codespell:
if: ${{ github.event_name != 'schedule' }}
runs-on: ubuntu-latest
steps:
- name: "Checkout Repository"
uses: actions/checkout@v4
- name: "Setup Python"
uses: actions/setup-python@v5
with:
python-version: "3.12"
cache: "pip"
cache-dependency-path: "requirements/dev.txt"
- name: "Install dependencies"
run: |
python -m pip install --upgrade pip
pip install -r requirements/dev.txt
- name: "Run codespell"
run:
codespell --ignore-words-list="groupt,nd,ot,ro,falsy,BU" \
--exclude-file=".github/workflows/codespell.yml"
bandit:
if: ${{ github.event_name != 'schedule' }}
runs-on: ubuntu-latest
steps:
- name: "Checkout Repository"
uses: actions/checkout@v4
- name: "Setup Python"
uses: actions/setup-python@v5
with:
python-version: "3.12"
cache: "pip"
cache-dependency-path: "requirements/dev.txt"
- name: "Install dependencies"
run: |
python -m pip install --upgrade pip
pip install -r requirements/dev.txt
- name: "Run bandit"
run: bandit --recursive --skip B101,B104,B105,B110,B307,B311,B404,B603,B607 .
pylint:
if: ${{ github.event_name != 'schedule' }}
runs-on: ubuntu-latest
steps:
- name: "Checkout Repository"
uses: actions/checkout@v4
- name: "Setup Python"
uses: actions/setup-python@v5
with:
python-version: "3.12"
cache: "pip"
cache-dependency-path: "requirements/dev.txt"
- name: "Install dependencies"
run: |
python -m pip install --upgrade pip
pip install -r requirements/dev.txt
- name: "Setup cache"
id: cache-pylint
uses: actions/cache@v4
with:
path: .pylint.d
key: pylint
- name: "Run pylint"
run: pylint discord/ --exit-zero
mypy:
if: ${{ github.event_name != 'schedule' }}
runs-on: ubuntu-latest
steps:
- name: "Checkout Repository"
uses: actions/checkout@v4
- name: "Setup Python"
uses: actions/setup-python@v5
with:
python-version: "3.12"
cache: "pip"
cache-dependency-path: "requirements/dev.txt"
- name: "Install dependencies"
run: |
python -m pip install --upgrade pip
pip install -r requirements/dev.txt
- name: "Setup cache"
id: cache-mypy
uses: actions/cache@v4
with:
path: .mypy_cache
key: mypy
- name: "Make mypy cache directory"
id: cache-dir-mypy
run: mkdir -p -v .mypy_cache
- name: "Run mypy"
run: mypy --non-interactive discord/
pytest:
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
python-version: ["3.9", "3.10", "3.11", "3.12"]
exclude:
- { python-version: "3.9", os: "macos-latest" }
include:
- { python-version: "3.9", os: "macos-13" }
runs-on: ${{ matrix.os }}
env:
OS: ${{ matrix.os }}
PYTHON: ${{ matrix.python-version }}
steps:
- name: "Checkout Repository"
uses: actions/checkout@v4
- name: "Setup Python"
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
cache: "pip"
cache-dependency-path: "requirements/dev.txt"
check-latest: true
- name: "Install dependencies"
run: |
python -m pip install --upgrade pip
pip install flake8
pip install -r requirements/dev.txt
- name: "Setup cache"
id: cache-pytest
uses: actions/cache@v4
with:
path: .pytest_cache
key: ${{ matrix.os }}-${{ matrix.python-version }}-pytest
- name: "Lint with flake8"
run: |
# stop the build if there are Python syntax errors or undefined names
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings.
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=120 --statistics