Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
brucearctor committed Apr 3, 2023
1 parent 3d92e63 commit 6cbe846
Show file tree
Hide file tree
Showing 6 changed files with 181 additions and 0 deletions.
16 changes: 16 additions & 0 deletions .github/workflows/actionlint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: actionlint

on:
push:
paths:
- '.github/workflows/**'
pull_request:
paths:
- '.github/workflows/**'

jobs:
actionlint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: reviewdog/action-actionlint@v1
26 changes: 26 additions & 0 deletions .github/workflows/stale.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Mark and close stale pull requests

on:
schedule:
- cron: '55 17 * * *'

env:
PR_STALE_DAYS: 21
PR_CLOSE_DAYS: 7

jobs:
stale:
runs-on: ubuntu-latest
permissions:
contents: write
issues: read
pull-requests: write
steps:
- uses: actions/stale@v7
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
stale-pr-message: "This pull request has been marked as stale. It will be closed in 14 days if no further activity occurs."
close-pr-message: "This pull request has been closed due to lack of activity."
days-before-pr-stale: ${{ env.PR_STALE_DAYS }}
days-before-pr-close: ${{ env.PR_CLOSE_DAYS }}
delete-branch: true
23 changes: 23 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
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/rhysd/actionlint
rev: v1.6.23
hooks:
- id: actionlint
- repo: https://github.com/psf/black
rev: 23.3.0
hooks:
- id: black
- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: 'v0.0.260'
hooks:
- id: ruff
- repo: https://github.com/RobertCraigie/pyright-python
rev: v1.1.301
hooks:
- id: pyright
37 changes: 37 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: "Ruff GH Action"
description: "A GH Action of Ruff, the extremely fast Python linter."
author: "Austin Bennett and the Ruff Community"
inputs:
args:
description:
"Arguments passed to Ruff. Use `ruff --help` to see available options.
Default: 'check'"
required: false
default: "check"
src:
description: "Source to run ruff. Default: '.'"
required: false
default: "."
version:
description: 'The version of ruff to use, e.g. "0.0.259"'
required: false
default: ""
branding:
color: "black"
icon: "code"
runs:
using: composite
steps:
- run: |
if [ "$RUNNER_OS" == "Windows" ]; then
python $GITHUB_ACTION_PATH/action/main.py
else
python3 $GITHUB_ACTION_PATH/action/main.py
fi
env:
RUFF_FORMAT: github
INPUT_ARGS: ${{ inputs.args }}
INPUT_SRC: ${{ inputs.src }}
INPUT_VERSION: ${{ inputs.version }}
pythonioencoding: utf-8
shell: bash
25 changes: 25 additions & 0 deletions action/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
"""GitHub Action for Ruff."""
import os
import re
import shlex
import sys
from pathlib import Path
from subprocess import run

ACTION_PATH = Path(os.environ["GITHUB_ACTION_PATH"])
ARGS = os.getenv("INPUT_ARGS", default="")
SRC = os.getenv("INPUT_SRC", default="")
VERSION = os.getenv("INPUT_VERSION", default="")

version_specifier = ""
if VERSION != "":
if not re.match(r"v?\d\.\d{1,3}\.\d{1,3}$", VERSION):
print("VERSION does not match expected pattern")
sys.exit(1)
version_specifier = f"=={VERSION}"

req = f"ruff{version_specifier}"

proc = run(["pipx", "run", req, *shlex.split(ARGS), *shlex.split(SRC)])

sys.exit(proc.returncode)
54 changes: 54 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
[tool.ruff]

select = ["A", "ANN", "B", "C90", "D", "E", "F", "I", "N", "COM", "DTZ", "PD", "RUF", "TID", "UP", "W"]
ignore = ["D203", "D212"]

fixable = ["I", "RUF100"]
unfixable = []

# Exclude a variety of commonly ignored directories.
exclude = [
".bzr",
".direnv",
".eggs",
".git",
".hg",
".mypy_cache",
".nox",
".pants.d",
".pytype",
".ruff_cache",
".svn",
".tox",
".venv",
"__pypackages__",
"_build",
"buck-out",
"build",
"dist",
"node_modules",
"venv",
]

line-length = 88

# Allow unused variables when underscore-prefixed.
dummy-variable-rgx = "^(_+|(_+[a-zA-Z0-9_]*[a-zA-Z0-9]+?))$"

target-version = "py311"

[tool.ruff.mccabe]
# Unlike Flake8, default to a complexity level of 10.
max-complexity = 10


[tool.pyright]
typeCheckingMode = "lazy"
defineConstant = { DEBUG = true }

reportMissingImports = false
reportMissingTypeStubs = false
reportInvalidStringEscapeSequence = false

pythonVersion = "3.11"
pythonPlatform = "Linux"

0 comments on commit 6cbe846

Please sign in to comment.