Skip to content

Commit 1b5eb3b

Browse files
authored
ci: set up reusable _lint workflow (#13)
Fixes #9
1 parent b64267b commit 1b5eb3b

File tree

3 files changed

+90
-0
lines changed

3 files changed

+90
-0
lines changed

.github/workflows/_lint.yml

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# This is a reusable workflow.
2+
#
3+
# Usage: Use the workflow in calling workflows like this:
4+
# "uses: rdmorganiser/.github/.github/workflows/_lint.yml@main"
5+
# Pin it to a branch, tag or commit hash.
6+
#
7+
# Ref: https://docs.github.com/en/actions/using-workflows/reusing-workflows
8+
9+
name: Lint
10+
11+
on:
12+
workflow_call: # reusable workflow
13+
14+
permissions: {} # Set permissions at the job level
15+
16+
env:
17+
PYTHONDONTWRITEBYTECODE: 1
18+
FORCE_COLOR: 1 # enforce colored output
19+
20+
jobs:
21+
22+
lint:
23+
name: Lint
24+
runs-on: ubuntu-24.04
25+
steps:
26+
- uses: actions/checkout@v4
27+
- uses: actions/setup-python@v5
28+
with:
29+
python-version: '3.12'
30+
- name: Run linters via pre-commit (e.g. typos)
31+
uses: pre-commit/action@2c7b3805fd2a0fd8c1884dcaebf91fc102a13ecd # v3.0.1
32+
with:
33+
extra_args: --all-files --color=always

.github/workflows/ci.yml

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
name: Lint
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
workflow_dispatch: # run manually from actions tab
9+
10+
concurrency:
11+
group: ${{ github.workflow }}-${{ github.ref }}
12+
cancel-in-progress: true
13+
14+
permissions: {} # Set permissions at the job level
15+
16+
jobs:
17+
18+
lint:
19+
uses: ./.github/workflows/_lint.yml

.pre-commit-config.yaml

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# pre-commit
2+
# Ref: https://pre-commit.com/#usage
3+
# More hooks: https://pre-commit.com/hooks.html
4+
# ------------------------------------------------------------------------------
5+
6+
repos:
7+
8+
- repo: meta
9+
hooks:
10+
- id: check-hooks-apply
11+
12+
# Check all files for generic issues, e.g. trailing whitespace
13+
- repo: https://github.com/pre-commit/pre-commit-hooks
14+
rev: v4.6.0
15+
hooks:
16+
- id: check-yaml
17+
- id: end-of-file-fixer
18+
- id: trailing-whitespace
19+
20+
# Pretty-format YAML files
21+
- repo: https://github.com/macisamuele/language-formatters-pre-commit-hooks
22+
rev: v2.13.0
23+
hooks:
24+
- id: pretty-format-yaml
25+
args: [--autofix, --indent, '2']
26+
27+
# Check JSON Schema
28+
- repo: https://github.com/python-jsonschema/check-jsonschema
29+
rev: 0.29.0
30+
hooks:
31+
- id: check-dependabot
32+
- id: check-github-workflows
33+
34+
# Check for typos
35+
- repo: https://github.com/crate-ci/typos
36+
rev: v1.23.2
37+
hooks:
38+
- id: typos

0 commit comments

Comments
 (0)