Pull out black, ruff, mypy to individual CI actions

This allows them to run in parallel.

Topic: ci_parallel_actions_linter
This commit is contained in:
Hayk Martiros 2023-03-26 21:30:39 +00:00
parent 0e6d7436f4
commit 9e785d651f
8 changed files with 62 additions and 30 deletions

15
.github/workflows/black.yml vendored Normal file
View File

@ -0,0 +1,15 @@
name: Black Format
on:
push:
branches:
- 'main'
pull_request:
types: [opened, synchronize, reopened, ready_for_review]
jobs:
run:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: psf/black@stable

View File

@ -1,4 +1,4 @@
name: CI
name: Python Test
run-name: ${{ github.actor }} is running Riffusion CI
on:
@ -9,7 +9,7 @@ on:
types: [opened, synchronize, reopened, ready_for_review]
jobs:
riffusion-ci:
run:
runs-on: ubuntu-latest
strategy:
@ -30,14 +30,13 @@ jobs:
sudo apt-get update
sudo apt-get install -y ffmpeg libsndfile1
- name: Install pip packages from requirements.txt
- name: Upgrade pip
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
- name: Install pip packages from dev_requirements.txt
- name: Install pip packages
run: |
pip install -r dev_requirements.txt
pip install -r requirements_all.txt
- name: Test with unittest
run: |

21
.github/workflows/mypy.yml vendored Normal file
View File

@ -0,0 +1,21 @@
name: MyPy Type Check
on:
push:
branches:
- 'main'
pull_request:
types: [opened, synchronize, reopened, ready_for_review]
jobs:
run:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
submodules: recursive
- uses: jpetrucciani/mypy-check@master
with:
mypy_flags: '--config-file pyproject.toml'
requirements_file: 'requirements_all.txt'

15
.github/workflows/ruff.yml vendored Normal file
View File

@ -0,0 +1,15 @@
name: Ruff Lint
on:
push:
branches:
- 'main'
pull_request:
types: [opened, synchronize, reopened, ready_for_review]
jobs:
run:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: jpetrucciani/ruff-check@main

View File

@ -66,6 +66,10 @@ ignore_missing_imports = true
module = "diffusers.*"
ignore_missing_imports = true
[[tool.mypy.overrides]]
module = "huggingface_hub.*"
ignore_missing_imports = true
[[tool.mypy.overrides]]
module = "numpy.*"
ignore_missing_imports = true

2
requirements_all.txt Normal file
View File

@ -0,0 +1,2 @@
-r requirements.txt
-r requirements_dev.txt

View File

@ -1,24 +0,0 @@
import subprocess
from pathlib import Path
from .test_case import TestCase
class LinterTest(TestCase):
"""
Test that ruff, black, and mypy run cleanly.
"""
HOME = Path(__file__).parent.parent
def test_ruff(self) -> None:
code = subprocess.check_call(["ruff", str(self.HOME)])
self.assertEqual(code, 0)
def test_black(self) -> None:
code = subprocess.check_call(["black", "--check", str(self.HOME)])
self.assertEqual(code, 0)
def test_mypy(self) -> None:
code = subprocess.check_call(["mypy", str(self.HOME)])
self.assertEqual(code, 0)