Skip to content

Commit 7e15c84

Browse files
committed
Add pre-commit workflow with basic checks
1 parent 5321bbb commit 7e15c84

File tree

3 files changed

+100
-2
lines changed

3 files changed

+100
-2
lines changed

.github/workflows/pre-commit.yml

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
# Licensed to the Apache Software Foundation (ASF) under one
2+
# or more contributor license agreements. See the NOTICE file
3+
# distributed with this work for additional information
4+
# regarding copyright ownership. The ASF licenses this file
5+
# to you under the Apache License, Version 2.0 (the
6+
# "License"); you may not use this file except in compliance
7+
# with the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing,
12+
# software distributed under the License is distributed on an
13+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
# KIND, either express or implied. See the License for the
15+
# specific language governing permissions and limitations
16+
# under the License.
17+
18+
name: pre-commit
19+
20+
on: [pull_request]
21+
22+
permissions:
23+
contents: read
24+
25+
concurrency:
26+
group: ${{ github.workflow }}-${{ github.ref }}
27+
cancel-in-progress: ${{ github.ref != 'refs/heads/master' }}
28+
29+
jobs:
30+
pre-commit:
31+
name: Run pre-commit # https://pre-commit.com/
32+
runs-on: ubuntu-latest
33+
steps:
34+
- name: 'Checkout ${{ github.ref }} ( ${{ github.sha }} )'
35+
uses: actions/checkout@v5
36+
- uses: actions/setup-python@v6 # https://www.python.org/
37+
with:
38+
python-version: '3.13' # Version range or exact version of a Python version to use, using SemVer's version range syntax
39+
architecture: 'x64' # optional x64 or x86. Defaults to x64 if not specified
40+
- name: Install dependencies # https://pip.pypa.io/en/stable/
41+
run: |
42+
python -m pip install --upgrade pip
43+
pip install pre-commit
44+
- name: set PY
45+
run: echo "PY=$(python -VV | sha256sum | cut -d' ' -f1)" >> "$GITHUB_ENV"
46+
- uses: actions/cache@v4
47+
with:
48+
path: ~/.cache/pre-commit
49+
key: pre-commit|${{ env.PY }}|${{ hashFiles('.pre-commit-config.yaml') }}
50+
- name: Run pre-commit
51+
run: pre-commit run --all-files

.pre-commit-config.yaml

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# Licensed to the Apache Software Foundation (ASF) under one
2+
# or more contributor license agreements. See the NOTICE file
3+
# distributed with this work for additional information
4+
# regarding copyright ownership. The ASF licenses this file
5+
# to you under the Apache License, Version 2.0 (the
6+
# "License"); you may not use this file except in compliance
7+
# with the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing,
12+
# software distributed under the License is distributed on an
13+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
# KIND, either express or implied. See the License for the
15+
# specific language governing permissions and limitations
16+
# under the License.
17+
18+
---
19+
# https://pre-commit.com/#installation
20+
default_stages: [pre-commit, pre-push]
21+
default_language_version:
22+
python: python3
23+
minimum_pre_commit_version: '3.2.0'
24+
repos:
25+
- repo: meta
26+
hooks:
27+
- id: identity
28+
name: run identity check
29+
- id: check-hooks-apply
30+
name: run check hooks apply
31+
- repo: https://github.com/pre-commit/pre-commit-hooks
32+
rev: v6.0.0
33+
hooks:
34+
- id: check-illegal-windows-names
35+
name: run check-illegal-windows-names
36+
description: check for Windows-illegal file names
37+
- id: check-merge-conflict
38+
name: run check-merge-conflict
39+
description: check for merge conflict markers
40+
- id: check-vcs-permalinks
41+
- id: detect-aws-credentials
42+
args: [--allow-missing-credentials]
43+
- id: detect-private-key
44+
exclude: ^source/adminguide/virtual_machines\.rst$
45+
- id: forbid-submodules
46+
- id: requirements-txt-fixer
47+
files: ^requirements\.txt$

requirements.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
docutils==0.20.1
2+
Jinja2==3.1.5
3+
readthedocs-sphinx-ext==2.2.5
24
Sphinx==7.2.6
35
sphinx-rtd-theme==2.0.0
4-
readthedocs-sphinx-ext==2.2.5
5-
Jinja2==3.1.5

0 commit comments

Comments
 (0)