Skip to content

Commit

Permalink
👷 ci: use ruff and update ci workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
SigureMo committed Mar 17, 2024
1 parent e88e769 commit 9afaa80
Show file tree
Hide file tree
Showing 6 changed files with 217 additions and 196 deletions.
15 changes: 0 additions & 15 deletions .github/workflows/black-fmt.yml

This file was deleted.

52 changes: 52 additions & 0 deletions .github/workflows/lint-and-fmt.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: Lint and Format

on:
push:
branches: [main]
pull_request:
merge_group:
workflow_dispatch:

jobs:
lint-and-fmt:
runs-on: ubuntu-latest
strategy:
matrix:
# Only run linter and formatter on minimum supported Python version
python-version: ["3.8"]
architecture: ["x64"]
name: lint and fmt - Python ${{ matrix.python-version }} on ${{ matrix.architecture }}
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Install prettier
run: |
npm install -g prettier
- name: Install poetry
run: pipx install poetry

- name: Install python
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
architecture: ${{ matrix.architecture }}
cache: "poetry"

- name: Install just
uses: extractions/setup-just@v2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Install dependencies
run: |
just ci-install
- name: lint
run: |
just ci-lint
- name: format check
run: |
just ci-fmt-check
21 changes: 15 additions & 6 deletions .github/workflows/unit-test.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,20 @@
name: Unit Test

on: [push, pull_request, workflow_dispatch]
on:
push:
branches: [main]
pull_request:
merge_group:
workflow_dispatch:

jobs:
unit-test:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12-dev"]
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
architecture: ["x64"]
name: Python ${{ matrix.python-version }} on ${{ matrix.architecture }} test
name: unittest - Python ${{ matrix.python-version }} on ${{ matrix.architecture }}
steps:
- name: Checkout
uses: actions/checkout@v4
Expand All @@ -24,11 +29,15 @@ jobs:
architecture: ${{ matrix.architecture }}
cache: "poetry"

- name: Install just
uses: extractions/setup-just@v2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Install dependencies
if: steps.poetry-cache.outputs.cache-hit != 'true'
run: |
poetry install -E rst-parser
just ci-install
- name: unit test
run: |
poetry run pytest
just ci-test
27 changes: 22 additions & 5 deletions justfile
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
VERSION := `poetry run python -c "import sys; from dochooks import __version__ as version; sys.stdout.write(version)"`

install:
poetry install -E rst-parser

test:
poetry run pytest
just clean

fmt:
poetry run isort .
poetry run black .

fmt-docs:
prettier --write '**/*.md'
poetry run ruff format .

lint:
poetry run pyright dochooks tests
poetry run ruff check .

fmt-docs:
prettier --write '**/*.md'

build:
poetry build
Expand All @@ -37,3 +40,17 @@ clean-builds:

hooks-update:
poetry run pre-commit autoupdate

ci-install:
poetry install --no-interaction --no-root -E rst-parser

ci-fmt-check:
poetry run ruff format --check --diff .
prettier --check '**/*.md'

ci-lint:
just lint

ci-test:
poetry run pytest --reruns 3 --reruns-delay 1
just clean
Loading

0 comments on commit 9afaa80

Please sign in to comment.