Skip to content

Commit

Permalink
chore: Update CI configs to use pre-commit (#22)
Browse files Browse the repository at this point in the history
* ci: Install libsnappy-dev in test workflows
  • Loading branch information
achimnol authored Sep 5, 2023
1 parent a9ee21e commit 4fe1a99
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 105 deletions.
110 changes: 6 additions & 104 deletions .github/workflows/default.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,106 +3,6 @@ name: default
on: [push, pull_request]

jobs:
lint-flake8:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.10.8"
cache: pip
cache-dependency-path: |
setup.py
requirements/lint.txt
- name: Install dependencies
run: |
python -m pip install -U pip setuptools wheel
python -m pip install -U -r requirements/lint.txt
- name: Lint with flake8
run: |
if [ "$GITHUB_EVENT_NAME" == "pull_request" -a -n "$GITHUB_HEAD_REF" ]; then
echo "(skipping matchers for pull request from local branches)"
else
echo "::add-matcher::.github/workflows/flake8-matcher.json"
fi
python -m flake8 src tests setup.py
lint-black:

runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.10.8"
cache: pip
cache-dependency-path: |
setup.py
requirements/lint.txt
- name: Install dependencies
run: |
python -m pip install -U pip setuptools wheel
python -m pip install -U -r requirements/lint.txt
- name: Lint with black
run: |
python -m black --check src tests setup.py
lint-isort:

runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.10.8"
cache: pip
cache-dependency-path: |
setup.py
requirements/lint.txt
- name: Install dependencies
run: |
python -m pip install -U pip setuptools wheel
python -m pip install -U -r requirements/lint.txt
- name: Lint with isort
run: |
python -m isort --check src tests setup.py
typecheck-mypy:

runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.10.8"
cache: pip
cache-dependency-path: |
setup.py
requirements/typecheck.txt
- name: Install dependencies
run: |
python -m pip install -U pip setuptools wheel
python -m pip install -U -r requirements/typecheck.txt
- name: Type check with mypy
run: |
if [ "$GITHUB_EVENT_NAME" == "pull_request" -a -n "$GITHUB_HEAD_REF" ]; then
echo "(skipping matchers for pull request from local branches)"
else
echo "::add-matcher::.github/workflows/mypy-matcher.json"
fi
python -m mypy --no-color-output src/callosum

test-unit:

Expand All @@ -124,13 +24,14 @@ jobs:
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.10.8"
python-version: "3.11.4"
cache: pip
cache-dependency-path: |
setup.py
requirements/test.txt
- name: Install dependencies
run: |
sudo apt install -y libsnappy-dev
python -m pip install -U pip setuptools wheel
python -m pip install -U -e ".[build,test,zeromq,redis,thrift,snappy]"
- name: Run unit tests
Expand Down Expand Up @@ -162,13 +63,14 @@ jobs:
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.10.8"
python-version: "3.11.4"
cache: pip
cache-dependency-path: |
setup.py
requirements/test.txt
- name: Install dependencies
run: |
sudo apt install -y libsnappy-dev
python -m pip install -U pip setuptools wheel
python -m pip install -U -e ".[build,test,zeromq,redis,thrift,snappy]"
- name: Run integration tests
Expand All @@ -179,7 +81,7 @@ jobs:
./scripts/run-integration-tests.sh
deploy-to-pypi:
needs: [lint-flake8, lint-black, lint-isort, typecheck-mypy, test-unit, test-integration]
needs: [test-unit, test-integration]
if: github.event_name == 'push' && contains(github.ref, 'refs/tags/')
runs-on: ubuntu-latest

Expand All @@ -191,7 +93,7 @@ jobs:
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.10.8"
python-version: "3.11.4"
cache: pip
cache-dependency-path: |
setup.py
Expand Down
22 changes: 22 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
ci:
autoupdate_schedule: quarterly
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
hooks:
- id: check-yaml
- id: end-of-file-fixer
- id: trailing-whitespace
- repo: https://github.com/psf/black
rev: 23.7.0
hooks:
- id: black
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.0.287
hooks:
- id: ruff
args: [--fix, --exit-non-zero-on-fix]
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.5.1
hooks:
- id: mypy
2 changes: 1 addition & 1 deletion requirements/dev.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
-e .[build,lint,typecheck,test]
-e .[build,dev,lint,typecheck,test]
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ def read_src_version():

dev_requires: List[str] = [
# 'pytest-sugar',
"pre-commit",
]

lint_requires = [
Expand Down

0 comments on commit 4fe1a99

Please sign in to comment.