Skip to content

Commit

Permalink
ci: set up reusable _lint workflow (#13)
Browse files Browse the repository at this point in the history
Fixes #9
  • Loading branch information
afuetterer authored Jul 12, 2024
1 parent b64267b commit 1b5eb3b
Show file tree
Hide file tree
Showing 3 changed files with 90 additions and 0 deletions.
33 changes: 33 additions & 0 deletions .github/workflows/_lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# This is a reusable workflow.
#
# Usage: Use the workflow in calling workflows like this:
# "uses: rdmorganiser/.github/.github/workflows/_lint.yml@main"
# Pin it to a branch, tag or commit hash.
#
# Ref: https://docs.github.com/en/actions/using-workflows/reusing-workflows

name: Lint

on:
workflow_call: # reusable workflow

permissions: {} # Set permissions at the job level

env:
PYTHONDONTWRITEBYTECODE: 1
FORCE_COLOR: 1 # enforce colored output

jobs:

lint:
name: Lint
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.12'
- name: Run linters via pre-commit (e.g. typos)
uses: pre-commit/action@2c7b3805fd2a0fd8c1884dcaebf91fc102a13ecd # v3.0.1
with:
extra_args: --all-files --color=always
19 changes: 19 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: Lint

on:
push:
branches:
- main
pull_request:
workflow_dispatch: # run manually from actions tab

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

permissions: {} # Set permissions at the job level

jobs:

lint:
uses: ./.github/workflows/_lint.yml
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
# Ref: https://pre-commit.com/#usage
# More hooks: https://pre-commit.com/hooks.html
# ------------------------------------------------------------------------------

repos:

- repo: meta
hooks:
- id: check-hooks-apply

# Check all files for generic issues, e.g. trailing whitespace
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.6.0
hooks:
- id: check-yaml
- id: end-of-file-fixer
- id: trailing-whitespace

# Pretty-format YAML files
- repo: https://github.com/macisamuele/language-formatters-pre-commit-hooks
rev: v2.13.0
hooks:
- id: pretty-format-yaml
args: [--autofix, --indent, '2']

# Check JSON Schema
- repo: https://github.com/python-jsonschema/check-jsonschema
rev: 0.29.0
hooks:
- id: check-dependabot
- id: check-github-workflows

# Check for typos
- repo: https://github.com/crate-ci/typos
rev: v1.23.2
hooks:
- id: typos

0 comments on commit 1b5eb3b

Please sign in to comment.