mirror of
				https://github.com/XRPLF/clio.git
				synced 2025-11-04 03:45:50 +00:00 
			
		
		
		
	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:
		@@ -4,4 +4,3 @@
 | 
			
		||||
 | 
			
		||||
source .githooks/check-format
 | 
			
		||||
source .githooks/check-docs
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -38,6 +38,8 @@ runs:
 | 
			
		||||
          password: ${{ env.GITHUB_TOKEN }}
 | 
			
		||||
 | 
			
		||||
      - uses: docker/setup-qemu-action@29109295f81e9208d7d86ff1c6c12d2833863392 #v3.6.0
 | 
			
		||||
        with:
 | 
			
		||||
          cache-image: false
 | 
			
		||||
      - uses: docker/setup-buildx-action@b5ca514318bd6ebac0fb2aedd5d36ec1b5c232a2 #v3.10.0
 | 
			
		||||
 | 
			
		||||
      - uses: docker/metadata-action@902fa8ec7d6ecbf8d84d538b9b233a880e428804 #v5.7.0
 | 
			
		||||
@@ -63,4 +65,3 @@ runs:
 | 
			
		||||
          repository: ${{ inputs.image_name }}
 | 
			
		||||
          short-description: ${{ inputs.description }}
 | 
			
		||||
          readme-filepath: ${{ inputs.directory }}/README.md
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										2
									
								
								.github/actions/prepare_runner/action.yml
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								.github/actions/prepare_runner/action.yml
									
									
									
									
										vendored
									
									
								
							@@ -70,5 +70,3 @@ runs:
 | 
			
		||||
      run: |
 | 
			
		||||
        mkdir -p $CCACHE_DIR
 | 
			
		||||
        mkdir -p $CONAN_USER_HOME/.conan
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										2
									
								
								.github/actions/save_cache/action.yml
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								.github/actions/save_cache/action.yml
									
									
									
									
										vendored
									
									
								
							@@ -55,5 +55,3 @@ runs:
 | 
			
		||||
      with:
 | 
			
		||||
        path: ${{ inputs.ccache_dir }}
 | 
			
		||||
        key: clio-ccache-${{ runner.os }}-${{ inputs.build_type }}${{ inputs.code_coverage == 'true' && '-code_coverage' || '' }}-${{ inputs.conan_profile }}-develop-${{ steps.git_common_ancestor.outputs.commit }}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										2
									
								
								.github/actions/setup_conan/action.yml
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								.github/actions/setup_conan/action.yml
									
									
									
									
										vendored
									
									
								
							@@ -48,5 +48,3 @@ runs:
 | 
			
		||||
        else
 | 
			
		||||
            echo "Conan-non-prod is available"
 | 
			
		||||
        fi
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										5
									
								
								.github/workflows/build.yml
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										5
									
								
								.github/workflows/build.yml
									
									
									
									
										vendored
									
									
								
							@@ -163,8 +163,3 @@ jobs:
 | 
			
		||||
          fi
 | 
			
		||||
          rm -f ${configDescriptionFile}
 | 
			
		||||
          exit 0
 | 
			
		||||
                    
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										39
									
								
								.github/workflows/pre-commit-autoupdate.yml
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										39
									
								
								.github/workflows/pre-commit-autoupdate.yml
									
									
									
									
										vendored
									
									
										Normal 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
									
								
							
							
						
						
									
										25
									
								
								.github/workflows/pre-commit.yml
									
									
									
									
										vendored
									
									
										Normal 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
 | 
			
		||||
							
								
								
									
										25
									
								
								.pre-commit-config.yaml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										25
									
								
								.pre-commit-config.yaml
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,25 @@
 | 
			
		||||
---
 | 
			
		||||
# pre-commit is a tool to perform a predefined set of tasks manually and/or
 | 
			
		||||
# automatically before git commits are made.
 | 
			
		||||
#
 | 
			
		||||
# Config reference: https://pre-commit.com/#pre-commit-configyaml---top-level
 | 
			
		||||
#
 | 
			
		||||
# Common tasks
 | 
			
		||||
#
 | 
			
		||||
# - Run on all files:   pre-commit run --all-files
 | 
			
		||||
# - Register git hooks: pre-commit install --install-hooks
 | 
			
		||||
#
 | 
			
		||||
# See https://pre-commit.com for more information
 | 
			
		||||
# See https://pre-commit.com/hooks.html for more hooks
 | 
			
		||||
repos:
 | 
			
		||||
    # `pre-commit sample-config` default hooks
 | 
			
		||||
  - repo: https://github.com/pre-commit/pre-commit-hooks
 | 
			
		||||
    rev: v5.0.0
 | 
			
		||||
    hooks:
 | 
			
		||||
      - id: check-added-large-files
 | 
			
		||||
      - id: check-executables-have-shebangs
 | 
			
		||||
      - id: check-shebang-scripts-are-executable
 | 
			
		||||
      - id: end-of-file-fixer
 | 
			
		||||
        exclude: ^docs/doxygen-awesome-theme/
 | 
			
		||||
      - id: trailing-whitespace
 | 
			
		||||
        exclude: ^docs/doxygen-awesome-theme/
 | 
			
		||||
@@ -5,4 +5,3 @@ Copyright (c) 2022, the clio developers
 | 
			
		||||
Permission to use, copy, modify, and distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.
 | 
			
		||||
 | 
			
		||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -59,4 +59,3 @@ case $1 in
 | 
			
		||||
esac
 | 
			
		||||
 | 
			
		||||
popd > /dev/null
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -42,6 +42,3 @@ If `is_full` is false, it means the cache is still loading. Normally, the Clio c
 | 
			
		||||
 | 
			
		||||
## Receive error message `Too many requests`
 | 
			
		||||
If client sees the error message `Too many requests`, this means that the client is blocked by Clio's DosGuard protection. You may want to add the client's IP to the whitelist in the configuration file, Or update other your DosGuard settings.
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -92,4 +92,3 @@ We have some example migrators under `tests/integration/migration/cassandra` fol
 | 
			
		||||
- ExampleTransactionsMigrator
 | 
			
		||||
 | 
			
		||||
    This migrator shows how to migrate transactions related data. It uses `TransactionsScanner` to proceed the `transactions` table full scan in parallel. It creates an index table `tx_index_example` which tracks the transaction hash and its according transaction type.
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										0
									
								
								tools/cassandra_delete_range/cassandra_delete_range.go
									
									
									
									
									
										
										
										Executable file → Normal file
									
								
							
							
						
						
									
										0
									
								
								tools/cassandra_delete_range/cassandra_delete_range.go
									
									
									
									
									
										
										
										Executable file → Normal file
									
								
							
		Reference in New Issue
	
	Block a user