Skip to content

Commit b0f4174

Browse files
authored
chore: Use tooling provided by pre-commit (#5753)
1 parent 3865dde commit b0f4174

File tree

2 files changed

+17
-74
lines changed

2 files changed

+17
-74
lines changed

.github/workflows/check-format.yml

Lines changed: 2 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -17,41 +17,10 @@ jobs:
1717
runs-on: ubuntu-latest
1818
container: ghcr.io/xrplf/ci/tools-rippled-pre-commit
1919
steps:
20-
# The $GITHUB_WORKSPACE and ${{ github.workspace }} might not point to the
21-
# same directory for jobs running in containers. The actions/checkout step
22-
# is *supposed* to checkout into $GITHUB_WORKSPACE and then add it to
23-
# safe.directory (see instructions at https://github.com/actions/checkout)
24-
# but that is apparently not happening for some container images. We
25-
# therefore preemptively add both directories to safe.directory. See also
26-
# https://github.com/actions/runner/issues/2058 for more details.
27-
- name: Configure git safe.directory
28-
run: |
29-
git config --global --add safe.directory $GITHUB_WORKSPACE
30-
git config --global --add safe.directory ${{ github.workspace }}
3120
- name: Checkout repository
3221
uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4.3.0
33-
- name: Check configuration
34-
run: |
35-
echo 'Checking path.'
36-
echo ${PATH} | tr ':' '\n'
37-
38-
echo 'Checking environment variables.'
39-
env | sort
40-
41-
echo 'Checking pre-commit version.'
42-
pre-commit --version
43-
44-
echo 'Checking clang-format version.'
45-
clang-format --version
46-
47-
echo 'Checking NPM version.'
48-
npm --version
49-
50-
echo 'Checking Node.js version.'
51-
node --version
52-
53-
echo 'Checking prettier version.'
54-
prettier --version
22+
- name: Prepare runner
23+
uses: XRPLF/actions/.github/actions/prepare-runner@638e0dc11ea230f91bd26622fb542116bb5254d5
5524
- name: Format code
5625
run: pre-commit run --show-diff-on-failure --color=always --all-files
5726
- name: Check for differences

.pre-commit-config.yaml

Lines changed: 15 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,61 +1,35 @@
11
# To run pre-commit hooks, first install pre-commit:
22
# - `pip install pre-commit==${PRE_COMMIT_VERSION}`
3-
# - `pip install pre-commit-hooks==${PRE_COMMIT_HOOKS_VERSION}`
4-
#
5-
# Depending on your system, you can use `brew install` or `apt install` as well
6-
# for installing the pre-commit package, but `pip` is needed to install the
7-
# hooks; you can also use `pipx` if you prefer.
8-
# Next, install the required formatters:
9-
# - `pip install clang-format==${CLANG_VERSION}`
10-
# - `npm install prettier@${PRETTIER_VERSION}`
11-
#
12-
# See https://github.com/XRPLF/ci/blob/main/.github/workflows/tools-rippled.yml
13-
# for the versions used in the CI pipeline. You will need to have the exact same
14-
# versions of the tools installed on your system to produce the same results as
15-
# the pipeline.
163
#
174
# Then, run the following command to install the git hook scripts:
185
# - `pre-commit install`
196
# You can run all configured hooks against all files with:
207
# - `pre-commit run --all-files`
218
# To manually run a specific hook, use:
229
# - `pre-commit run <hook_id> --all-files`
23-
# To run the hooks against only the files changed in the current commit, use:
10+
# To run the hooks against only the staged files, use:
2411
# - `pre-commit run`
2512
repos:
26-
- repo: local
13+
- repo: https://github.com/pre-commit/pre-commit-hooks
14+
rev: 3e8a8703264a2f4a69428a0aa4dcb512790b2c8c # frozen: v6.0.0
2715
hooks:
28-
- id: clang-format
29-
name: clang-format
30-
language: system
31-
entry: clang-format -i
32-
files: '\.(cpp|hpp|h|ipp|proto)$'
3316
- id: trailing-whitespace
34-
name: trailing-whitespace
35-
entry: trailing-whitespace-fixer
36-
language: system
37-
types: [text]
38-
- id: end-of-file
39-
name: end-of-file
40-
entry: end-of-file-fixer
41-
language: system
42-
types: [text]
17+
- id: end-of-file-fixer
4318
- id: mixed-line-ending
44-
name: mixed-line-ending
45-
entry: mixed-line-ending
46-
language: system
47-
types: [text]
4819
- id: check-merge-conflict
49-
name: check-merge-conflict
50-
entry: check-merge-conflict --assume-in-merge
51-
language: system
52-
types: [text]
53-
- repo: local
20+
args: [--assume-in-merge]
21+
22+
- repo: https://github.com/pre-commit/mirrors-clang-format
23+
rev: 7d85583be209cb547946c82fbe51f4bc5dd1d017 # frozen: v18.1.8
24+
hooks:
25+
- id: clang-format
26+
args: [--style=file]
27+
"types_or": [c++, c, proto]
28+
29+
- repo: https://github.com/rbubley/mirrors-prettier
30+
rev: 5ba47274f9b181bce26a5150a725577f3c336011 # frozen: v3.6.2
5431
hooks:
5532
- id: prettier
56-
name: prettier
57-
language: system
58-
entry: prettier --ignore-unknown --write
5933

6034
exclude: |
6135
(?x)^(

0 commit comments

Comments
 (0)