Skip to content

Commit

Permalink
Merge pull request #6894 from aktech/lint-ci
Browse files Browse the repository at this point in the history
Add pre-commit lint action
  • Loading branch information
roseayeon authored Aug 14, 2024
2 parents ddc0056 + bcfb10e commit a01c22a
Show file tree
Hide file tree
Showing 2 changed files with 71 additions and 0 deletions.
33 changes: 33 additions & 0 deletions .github/workflows/ci-lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: pre-commit

on:
pull_request:
push:
branches: [master]

jobs:
pre-commit:
runs-on: ubuntu-latest
steps:
- uses: actions/[email protected]
with:
# Ensure the full history is fetched
# This is required to run pre-commit on a specific set of commits
# TODO: Remove this when all the pre-commit issues are fixed
fetch-depth: 0
- uses: actions/[email protected]
with:
python-version: 3.9
- name: Determine commit range
id: commit_range
run: |
echo "TO_REF=${{ github.sha }}" >> $GITHUB_ENV
if [ "${{ github.event_name }}" == "pull_request" ]; then
echo "FROM_REF=${{ github.event.pull_request.base.sha }}" >> $GITHUB_ENV
else
echo "FROM_REF=${{ github.event.before }}" >> $GITHUB_ENV
fi
- uses: pre-commit/[email protected]
with:
# TODO: Remove this when all the pre-commit issues are fixed
extra_args: --from-ref ${{ env.FROM_REF }} --to-ref ${{ env.TO_REF }}
38 changes: 38 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# pre-commit is a tool to perform a predefined set of tasks manually and/or
# automatically before git commits are made.
#
# Config reference: https://pre-commit.com/#pre-commit-configyaml---top-level
#
# Common tasks
#
# - Register git hooks: pre-commit install --install-hooks
# - Run on all files: pre-commit run --all-files
#
# These pre-commit hooks are run as CI.
#
# NOTE: if it can be avoided, add configs/args in pyproject.toml or below instead of creating a new `.config.file`.
# https://pre-commit.ci/#configuration
ci:
autoupdate_schedule: monthly
autofix_commit_msg: |
[pre-commit.ci] Apply automatic pre-commit fixes
repos:
# general
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.6.0
hooks:
- id: end-of-file-fixer
exclude: '\.svg$'
- id: trailing-whitespace
exclude: '\.svg$'
- id: check-json
- id: check-yaml
args: [--allow-multiple-documents]
- id: check-toml

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.5.6
hooks:
- id: ruff
args: ["--fix"]

0 comments on commit a01c22a

Please sign in to comment.