Skip to content

Commit

Permalink
Merge pull request #55 from allenai/henryh/add-linting-workflow
Browse files Browse the repository at this point in the history
Henryh/add linting workflow
  • Loading branch information
favyen2 authored Oct 22, 2024
2 parents 0fdd2c3 + eb7f07f commit 0bb6b73
Show file tree
Hide file tree
Showing 67 changed files with 12,912 additions and 3,338 deletions.
33 changes: 33 additions & 0 deletions .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Lint (type checking, security, code quality, ruff)

on:
push:
branches:
- "henryh/add-linting-workflow"
pull_request:
branches:
- "master"

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
linting:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
with:
lfs: false

- name: Set up Python 3.10
uses: actions/setup-python@v4
with:
python-version: 3.10.10
pip-version: 24

- name: Linting
run: |
pip install pre-commit interrogate
pre-commit run --all-files
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
.env
wandb/
rslp/__pycache__/
rslp/__pycache__/
95 changes: 92 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,10 +1,99 @@
exclude_types: ["*.geojson"]
exclude: ^(one_off_projects|landsat|platforms|sentinel2_postprocess_revamp|amazon_conservation|convert_satlas_webmercator_to_rslearn)/ # Exlcluding projects that have not been migrated to rslp
ci:
autofix_prs: false
autoupdate_branch: ""
autoupdate_commit_msg: "[pre-commit.ci] pre-commit autoupdate"
autoupdate_schedule: weekly
skip: [end-of-file-fixer, equirements-txt-fixer]
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
- id: check-json
- id: mixed-line-ending
- id: requirements-txt-fixer
- id: pretty-format-json
args: ["--autofix"]
- id: check-case-conflict
- id: check-docstring-first
- id: check-added-large-files
exclude: wheels/*
- id: check-ast
- id: check-byte-order-marker
- id: check-executables-have-shebangs
- id: check-merge-conflict
- id: check-toml
- id: debug-statements
- id: detect-aws-credentials
args: [--allow-missing-credentials]
- id: detect-private-key

- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.1.1
hooks:
- id: mypy
args: [
--install-types,
--ignore-missing-imports,
--disallow-untyped-defs,
--ignore-missing-imports,
--non-interactive,
# --no-namespace-packages,
--namespace-packages,
]
additional_dependencies:
- "pydantic>=2.7.1,<3"
- "types-protobuf"
exclude: ./.*_pb2_.*.py
- repo: https://github.com/PyCQA/bandit
rev: "1.7.5"
hooks:
- id: bandit
exclude: ^tests/
args:
- -s
- B101,B311,B324,B108,B104
- repo: local
hooks:
- id: interrogate
name: interrogate
language: system
entry: interrogate
types: [python]
args:
[
--ignore-init-method,
--ignore-init-module,
-p,
-vv,
rslp,
--fail-under=80,
]
- repo: https://github.com/astral-sh/ruff-pre-commit
# Ruff version.
rev: v0.4.4
hooks:
# Run the linter.
- id: ruff
args: [ --fix ]
# Run the formatter.
- id: ruff-format
# - repo: https://github.com/hadolint/hadolint
# rev: v2.7.0
# hooks:
# - id: hadolint-docker
# name: Lint Dockerfiles
# description: Runs hadolint Docker image to lint Dockerfiles
# language: docker_image
# types: ["dockerfile"]
# entry: ghcr.io/hadolint/hadolint hadolint
# args: ["--ignore", "DL3008"]
# - repo: local
# hooks:
# - id: convert-list
# name: Convert List to list (note case)
# entry: python3 convert_List_to_list.py
# language: system
# types: [python] # Ensures it only runs on Python files
# files: \.py$ # Ensures it only runs on files with a .py extension
Loading

0 comments on commit 0bb6b73

Please sign in to comment.