Update linting workflows for frontend and Python code (#2171)
* chore: Update pre-commit hooks and dependencies * chore: Add linting workflow for frontend code * chore: Update linting workflow for Python code and include tests in pull requests * chore: Add Ruff style check workflow for Python code
This commit is contained in:
parent
df634de53f
commit
a9cb7b0f5e
5 changed files with 115 additions and 36 deletions
51
.github/workflows/lint-js.yml
vendored
Normal file
51
.github/workflows/lint-js.yml
vendored
Normal file
|
|
@ -0,0 +1,51 @@
|
||||||
|
name: Lint Frontend
|
||||||
|
|
||||||
|
on:
|
||||||
|
pull_request:
|
||||||
|
paths:
|
||||||
|
- "src/frontend/**"
|
||||||
|
|
||||||
|
env:
|
||||||
|
NODE_VERSION: "21"
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
run-linters:
|
||||||
|
name: Run linters
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Checkout code
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Setup Node.js
|
||||||
|
uses: actions/setup-node@v4
|
||||||
|
id: setup-node
|
||||||
|
with:
|
||||||
|
node-version: ${{ env.NODE_VERSION }}
|
||||||
|
|
||||||
|
- name: Cache Node.js dependencies
|
||||||
|
uses: actions/cache@v4
|
||||||
|
id: npm-cache
|
||||||
|
with:
|
||||||
|
path: ~/.npm
|
||||||
|
key: ${{ runner.os }}-node-${{ hashFiles('src/frontend/package-lock.json') }}
|
||||||
|
restore-keys: |
|
||||||
|
${{ runner.os }}-node-
|
||||||
|
|
||||||
|
- name: Install Node.js dependencies
|
||||||
|
run: |
|
||||||
|
cd src/frontend
|
||||||
|
npm ci
|
||||||
|
if: ${{ steps.setup-node.outputs.cache-hit != 'true' }}
|
||||||
|
|
||||||
|
- name: Run linters
|
||||||
|
uses: wearerequired/lint-action@v1
|
||||||
|
with:
|
||||||
|
github_token: ${{ secrets.github_token }}
|
||||||
|
auto_fix: true
|
||||||
|
git_email: "gabriel@langflow.org"
|
||||||
|
# Enable linters
|
||||||
|
eslint: true
|
||||||
|
prettier: true
|
||||||
|
prettier_args: '--write \"{tests,src}/**/*.{js,jsx,ts,tsx,json,md}\" --ignore-path .prettierignore'
|
||||||
|
|
||||||
|
|
@ -1,17 +1,12 @@
|
||||||
name: lint
|
name: Lint Python
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
|
||||||
branches: [main]
|
|
||||||
paths:
|
|
||||||
- "poetry.lock"
|
|
||||||
- "pyproject.toml"
|
|
||||||
- "src/backend/**"
|
|
||||||
pull_request:
|
pull_request:
|
||||||
paths:
|
paths:
|
||||||
- "poetry.lock"
|
- "poetry.lock"
|
||||||
- "pyproject.toml"
|
- "pyproject.toml"
|
||||||
- "src/backend/**"
|
- "src/backend/**"
|
||||||
|
- "tests/**"
|
||||||
|
|
||||||
env:
|
env:
|
||||||
POETRY_VERSION: "1.8.2"
|
POETRY_VERSION: "1.8.2"
|
||||||
|
|
@ -45,6 +40,12 @@ jobs:
|
||||||
path: |
|
path: |
|
||||||
./.mypy_cache
|
./.mypy_cache
|
||||||
key: ${{ runner.os }}-mypy-${{ hashFiles('**/pyproject.toml') }}
|
key: ${{ runner.os }}-mypy-${{ hashFiles('**/pyproject.toml') }}
|
||||||
- name: Lint check
|
- name: Run linters
|
||||||
run: |
|
uses: wearerequired/lint-action@v1
|
||||||
make lint
|
with:
|
||||||
|
github_token: ${{ secrets.github_token }}
|
||||||
|
# Enable linters
|
||||||
|
git_email: "gabriel@langflow.org"
|
||||||
|
mypy: true
|
||||||
|
mypy_args: '--namespace-packages -p "langflow"'
|
||||||
|
|
||||||
14
.github/workflows/matchers/ruff.json
vendored
Normal file
14
.github/workflows/matchers/ruff.json
vendored
Normal file
|
|
@ -0,0 +1,14 @@
|
||||||
|
{
|
||||||
|
"problemMatcher": [
|
||||||
|
{
|
||||||
|
"owner": "ruff",
|
||||||
|
"pattern": [
|
||||||
|
{
|
||||||
|
"regexp": "^(Would reformat): (.+)$",
|
||||||
|
"message": 1,
|
||||||
|
"file": 2
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
39
.github/workflows/style-check-py.yml
vendored
Normal file
39
.github/workflows/style-check-py.yml
vendored
Normal file
|
|
@ -0,0 +1,39 @@
|
||||||
|
name: Ruff Style Check
|
||||||
|
|
||||||
|
on:
|
||||||
|
pull_request:
|
||||||
|
paths:
|
||||||
|
- "poetry.lock"
|
||||||
|
- "pyproject.toml"
|
||||||
|
- "src/backend/**"
|
||||||
|
- "tests/**"
|
||||||
|
|
||||||
|
env:
|
||||||
|
POETRY_VERSION: "1.8.2"
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
lint:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
python-version:
|
||||||
|
- "3.12"
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
- name: Set up Python ${{ matrix.python-version }} + Poetry ${{ env.POETRY_VERSION }}
|
||||||
|
uses: "./.github/actions/poetry_caching"
|
||||||
|
with:
|
||||||
|
python-version: ${{ matrix.python-version }}
|
||||||
|
poetry-version: ${{ env.POETRY_VERSION }}
|
||||||
|
cache-key: ${{ runner.os }}-poetry-${{ env.POETRY_VERSION }}-${{ hashFiles('**/poetry.lock') }}
|
||||||
|
- name: Install Python dependencies
|
||||||
|
run: |
|
||||||
|
poetry env use ${{ matrix.python-version }}
|
||||||
|
poetry install
|
||||||
|
- name: Register problem matcher
|
||||||
|
run: echo "::add-matcher::.github/workflows/matchers/ruff.json"
|
||||||
|
- name: Run Ruff
|
||||||
|
run: poetry run ruff check --output-format=github .
|
||||||
|
- name: Run Ruff format
|
||||||
|
run: poetry run ruff format --check .
|
||||||
|
|
||||||
|
|
@ -1,18 +1,5 @@
|
||||||
fail_fast: true
|
fail_fast: true
|
||||||
repos:
|
repos:
|
||||||
- repo: https://github.com/pre-commit/mirrors-eslint
|
|
||||||
rev: "v9.1.1"
|
|
||||||
hooks:
|
|
||||||
- id: eslint
|
|
||||||
files: \.[jt]sx?$ # *.js, *.jsx, *.ts and *.tsx
|
|
||||||
types: [file]
|
|
||||||
args: ["--fix", "--no-warn-ignored"]
|
|
||||||
additional_dependencies:
|
|
||||||
- eslint@9.1.1
|
|
||||||
- eslint-plugin-prettier
|
|
||||||
- eslint-config-prettier
|
|
||||||
- prettier
|
|
||||||
- eslint-plugin-react@latest
|
|
||||||
- repo: https://github.com/pre-commit/pre-commit-hooks
|
- repo: https://github.com/pre-commit/pre-commit-hooks
|
||||||
rev: v4.1.0
|
rev: v4.1.0
|
||||||
hooks:
|
hooks:
|
||||||
|
|
@ -25,16 +12,3 @@ repos:
|
||||||
args:
|
args:
|
||||||
- --fix=lf
|
- --fix=lf
|
||||||
- id: trailing-whitespace
|
- id: trailing-whitespace
|
||||||
- repo: https://github.com/astral-sh/ruff-pre-commit
|
|
||||||
# Ruff version.
|
|
||||||
rev: v0.4.2
|
|
||||||
hooks:
|
|
||||||
# Run the linter.
|
|
||||||
- id: ruff
|
|
||||||
# Python
|
|
||||||
files: \.py$
|
|
||||||
types: [file]
|
|
||||||
# Run the formatter.
|
|
||||||
- id: ruff-format
|
|
||||||
files: \.py$
|
|
||||||
types: [file]
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue