style: Use pre-commit tool and add simple config (#2029)

I started with really simple pre-commit hooks and will add more on top.

Important files:
- `.pre-commit-config.yaml` - the config for pre-commit
- `.github/workflows/pre-commit.yml` - runs pre-commit hooks in branches
and `develop`
- `.github/workflows/pre-commit-autoupdate.yml` - autoupdates pre-commit
hooks once in a month
This commit is contained in:
Ayaz Salikhov
2025-04-24 17:59:43 +01:00
committed by GitHub
parent 99580a2602
commit 9c92a2b51b
66 changed files with 805 additions and 733 deletions

View File

@@ -23,7 +23,7 @@ jobs:
run: |
./.githooks/check-format --diff
shell: bash
check_docs:
name: Check documentation
runs-on: ubuntu-latest
@@ -132,10 +132,10 @@ jobs:
name: Check Config Description
needs: build
runs-on: heavy
container:
container:
image: rippleci/clio_ci:latest
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v4
- uses: actions/download-artifact@v4
with:
name: clio_server_Linux_Release_gcc
@@ -163,8 +163,3 @@ jobs:
fi
rm -f ${configDescriptionFile}
exit 0

View File

@@ -75,7 +75,7 @@ on:
jobs:
build:
name: Build ${{ inputs.container != '' && 'in container' || 'natively' }}
runs-on: ${{ inputs.runs_on }}
runs-on: ${{ inputs.runs_on }}
container: ${{ inputs.container != '' && fromJson(inputs.container) || null }}
steps:
@@ -137,7 +137,7 @@ jobs:
- name: Strip unit_tests
if: ${{ inputs.unit_tests && !inputs.code_coverage && inputs.sanitizer == 'false' }}
run: strip build/clio_tests
- name: Strip integration_tests
if: ${{ inputs.integration_tests && !inputs.code_coverage }}
run: strip build/clio_integration_tests
@@ -148,14 +148,14 @@ jobs:
with:
name: clio_server_${{ runner.os }}_${{ inputs.build_type }}_${{ steps.conan.outputs.conan_profile }}
path: build/clio_server
- name: Upload clio_tests
if: ${{ inputs.unit_tests && !inputs.code_coverage }}
uses: actions/upload-artifact@v4
with:
name: clio_tests_${{ runner.os }}_${{ inputs.build_type }}_${{ steps.conan.outputs.conan_profile }}
path: build/clio_tests
- name: Upload clio_integration_tests
if: ${{ inputs.integration_tests && !inputs.code_coverage }}
uses: actions/upload-artifact@v4
@@ -184,7 +184,7 @@ jobs:
uses: ./.github/actions/code_coverage
upload_coverage_report:
if: ${{ inputs.code_coverage }}
if: ${{ inputs.code_coverage }}
name: Codecov
needs: build
uses: ./.github/workflows/upload_coverage_report.yml

View File

@@ -25,14 +25,14 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v4
with:
with:
lfs: true
- name: Build docs
run: |
mkdir -p build_docs && cd build_docs
cmake ../docs && cmake --build . --target docs
- name: Setup Pages
uses: actions/configure-pages@v5
@@ -41,7 +41,7 @@ jobs:
with:
path: build_docs/html
name: docs-develop
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4

View File

@@ -54,13 +54,13 @@ jobs:
build_type: Release
container:
image: rippleci/clio_ci:latest
integration_tests: true
integration_tests: true
- os: heavy
conan_profile: gcc
build_type: Debug
container:
image: rippleci/clio_ci:latest
integration_tests: true
integration_tests: true
runs-on: [self-hosted, "${{ matrix.os }}"]
container: ${{ matrix.container }}
@@ -68,9 +68,9 @@ jobs:
scylladb:
image: ${{ (matrix.integration_tests) && 'scylladb/scylla' || '' }}
options: >-
--health-cmd "cqlsh -e 'describe cluster'"
--health-interval 10s
--health-timeout 5s
--health-cmd "cqlsh -e 'describe cluster'"
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
@@ -86,7 +86,7 @@ jobs:
run: |
chmod +x ./clio_tests
./clio_tests
- uses: actions/download-artifact@v4
with:
name: clio_integration_tests_${{ runner.os }}_${{ matrix.build_type }}_${{ matrix.conan_profile }}
@@ -94,7 +94,7 @@ jobs:
# To be enabled back once docker in mac runner arrives
# https://github.com/XRPLF/clio/issues/1400
- name: Run clio_integration_tests
if: matrix.integration_tests
if: matrix.integration_tests
run: |
chmod +x ./clio_integration_tests
./clio_integration_tests --backend_host=scylladb

View File

@@ -0,0 +1,39 @@
name: Pre-commit auto-update
on:
# every first day of the month
schedule:
- cron: "0 0 1 * *"
# on demand
workflow_dispatch:
jobs:
auto-update:
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: 3.x
- run: pip install pre-commit
- run: pre-commit autoupdate
- run: pre-commit run --all-files
- uses: peter-evans/create-pull-request@271a8d0340265f705b14b6d32b9829c1cb33d45e # v7.0.8
if: always()
env:
GH_REPO: ${{ github.repository }}
GH_TOKEN: ${{ github.token }}
with:
branch: update/pre-commit-hooks
title: Update pre-commit hooks
commit-message: "style: update pre-commit hooks"
body: Update versions of pre-commit hooks to latest version.
reviewers: "godexsoft,kuznetsss,PeterChen13579,mathbunnyru"

25
.github/workflows/pre-commit.yml vendored Normal file
View File

@@ -0,0 +1,25 @@
name: Run pre-commit hooks
on:
pull_request:
push:
branches:
- develop
workflow_dispatch:
jobs:
run-hooks:
runs-on: ubuntu-latest
steps:
- name: Checkout Repo ⚡️
uses: actions/checkout@v4
- name: Set Up Python 🐍
uses: actions/setup-python@v5
with:
python-version: 3.x
- name: Install pre-commit 📦
run: |
pip install --upgrade pip
pip install --upgrade pre-commit
- name: Run pre-commit ✅
run: pre-commit run --all-files

View File

@@ -27,7 +27,7 @@ jobs:
with:
action: codecov/codecov-action@v4
with: |
files: build/coverage_report.xml
files: build/coverage_report.xml
fail_ci_if_error: false
verbose: true
token: ${{ secrets.CODECOV_TOKEN }}