mirror of
https://github.com/dragonflydb/dragonfly.git
synced 2025-05-11 10:25:47 +02:00
ci: added clang pre-commit hook (#461)
Signed-off-by: Leonardo Mello <lsvmello@gmail.com>
This commit is contained in:
parent
2b87088121
commit
e46e5819c9
3 changed files with 57 additions and 29 deletions
68
.github/workflows/ci.yml
vendored
68
.github/workflows/ci.yml
vendored
|
@ -4,13 +4,31 @@ on:
|
||||||
# push:
|
# push:
|
||||||
# branches: [ main ]
|
# branches: [ main ]
|
||||||
pull_request:
|
pull_request:
|
||||||
branches: [ main ]
|
branches: [main]
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
|
|
||||||
env:
|
env:
|
||||||
# Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.)
|
# Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.)
|
||||||
BUILD_TYPE: Debug
|
BUILD_TYPE: Debug
|
||||||
jobs:
|
jobs:
|
||||||
|
pre-commit:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
with:
|
||||||
|
fetch-depth: 2
|
||||||
|
- uses: actions/setup-python@v3
|
||||||
|
- name: Install dependencies
|
||||||
|
run: |
|
||||||
|
python -m pip install pre-commit
|
||||||
|
python -m pip freeze --local
|
||||||
|
- uses: actions/cache@v3
|
||||||
|
with:
|
||||||
|
path: ~/.cache/pre-commit
|
||||||
|
key: pre-commit|${{ env.pythonLocation }}|${{ hashFiles('.pre-commit-config.yaml') }}
|
||||||
|
- name: Run pre-commit checks
|
||||||
|
run: pre-commit run --show-diff-on-failure --color=always --from-ref HEAD^ --to-ref HEAD
|
||||||
|
shell: bash
|
||||||
build:
|
build:
|
||||||
# The CMake configure and build commands are platform agnostic and should work equally
|
# The CMake configure and build commands are platform agnostic and should work equally
|
||||||
# well on Windows or Mac. You can convert this to a matrix build if you need
|
# well on Windows or Mac. You can convert this to a matrix build if you need
|
||||||
|
@ -22,45 +40,45 @@ jobs:
|
||||||
# Test of these containers
|
# Test of these containers
|
||||||
container: ["ubuntu-dev:20", "alpine-dev:latest"]
|
container: ["ubuntu-dev:20", "alpine-dev:latest"]
|
||||||
timeout-minutes: 30
|
timeout-minutes: 30
|
||||||
container:
|
container:
|
||||||
image: ghcr.io/romange/${{ matrix.container }}
|
image: ghcr.io/romange/${{ matrix.container }}
|
||||||
# credentials:
|
# credentials:
|
||||||
# username: ${{ github.repository_owner }}
|
# username: ${{ github.repository_owner }}
|
||||||
# password: ${{ secrets.GITHUB_TOKEN }}
|
# password: ${{ secrets.GITHUB_TOKEN }}
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
with:
|
with:
|
||||||
submodules: true
|
submodules: true
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
run: |
|
run: |
|
||||||
uname -a
|
uname -a
|
||||||
cmake --version
|
cmake --version
|
||||||
mkdir -p ${{github.workspace}}/build
|
mkdir -p ${{github.workspace}}/build
|
||||||
- name: Cache build deps
|
- name: Cache build deps
|
||||||
id: cache-deps
|
id: cache-deps
|
||||||
uses: actions/cache@v3
|
uses: actions/cache@v3
|
||||||
with:
|
with:
|
||||||
path: |
|
path: |
|
||||||
~/.ccache
|
~/.ccache
|
||||||
${{github.workspace}}/build/_deps
|
${{github.workspace}}/build/_deps
|
||||||
key: ${{ runner.os }}-deps-${{ github.base_ref }}-${{ github.sha }}
|
key: ${{ runner.os }}-deps-${{ github.base_ref }}-${{ github.sha }}
|
||||||
restore-keys: |
|
restore-keys: |
|
||||||
${{ runner.os }}-deps-${{ github.base_ref }}-
|
${{ runner.os }}-deps-${{ github.base_ref }}-
|
||||||
|
|
||||||
- name: Configure CMake
|
- name: Configure CMake
|
||||||
# Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make.
|
# Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make.
|
||||||
# See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type
|
# See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type
|
||||||
run: |
|
run: |
|
||||||
cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -GNinja -DCMAKE_CXX_COMPILER_LAUNCHER=ccache
|
cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -GNinja -DCMAKE_CXX_COMPILER_LAUNCHER=ccache
|
||||||
cd ${{github.workspace}}/build && pwd
|
cd ${{github.workspace}}/build && pwd
|
||||||
du -hcs _deps/
|
du -hcs _deps/
|
||||||
- name: Build & Test
|
- name: Build & Test
|
||||||
run: |
|
run: |
|
||||||
cd ${{github.workspace}}/build
|
cd ${{github.workspace}}/build
|
||||||
ninja src/all
|
ninja src/all
|
||||||
ccache --show-stats
|
ccache --show-stats
|
||||||
GLOG_logtostderr=1 GLOG_vmodule=rdb_load=1,rdb_save=1 ctest -V -R rdb_test
|
GLOG_logtostderr=1 GLOG_vmodule=rdb_load=1,rdb_save=1 ctest -V -R rdb_test
|
||||||
echo Run ctest -V -L DFLY
|
echo Run ctest -V -L DFLY
|
||||||
#GLOG_logtostderr=1 GLOG_vmodule=transaction=1,engine_shard_set=1
|
#GLOG_logtostderr=1 GLOG_vmodule=transaction=1,engine_shard_set=1
|
||||||
GLOG_logtostderr=1 GLOG_vmodule=rdb_load=1,rdb_save=2,snapshot=2 ctest -V -L DFLY
|
GLOG_logtostderr=1 GLOG_vmodule=rdb_load=1,rdb_save=2,snapshot=2 ctest -V -L DFLY
|
||||||
# GLOG_logtostderr=1 GLOG_vmodule=transaction=1,engine_shard_set=1 CTEST_OUTPUT_ON_FAILURE=1 ninja server/test
|
# GLOG_logtostderr=1 GLOG_vmodule=transaction=1,engine_shard_set=1 CTEST_OUTPUT_ON_FAILURE=1 ninja server/test
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
default_stages: [commit]
|
||||||
repos:
|
repos:
|
||||||
- repo: local
|
- repo: local
|
||||||
hooks:
|
hooks:
|
||||||
|
@ -10,5 +11,11 @@ repos:
|
||||||
- repo: https://github.com/pre-commit/pre-commit-hooks
|
- repo: https://github.com/pre-commit/pre-commit-hooks
|
||||||
rev: v4.3.0
|
rev: v4.3.0
|
||||||
hooks:
|
hooks:
|
||||||
- id: trailing-whitespace
|
- id: trailing-whitespace
|
||||||
- id: end-of-file-fixer
|
- id: end-of-file-fixer
|
||||||
|
|
||||||
|
- repo: https://github.com/pre-commit/mirrors-clang-format
|
||||||
|
rev: v14.0.6
|
||||||
|
hooks:
|
||||||
|
- id: clang-format
|
||||||
|
name: Clang formatting
|
||||||
|
|
|
@ -23,12 +23,15 @@ cd build-dbg && ninja dragonfly
|
||||||
```sh
|
```sh
|
||||||
cd dragonfly # project root
|
cd dragonfly # project root
|
||||||
|
|
||||||
|
# Make sure you have 'pre-commit' e 'clang-format' installed
|
||||||
|
pip install pre-commit clang-format
|
||||||
|
|
||||||
# IMPORTANT! Enable our pre-commit message hooks
|
# IMPORTANT! Enable our pre-commit message hooks
|
||||||
# This will ensure your commits match our formatting requirements
|
# This will ensure your commits match our formatting requirements
|
||||||
pre-commit install --hook-type commit-msg
|
pre-commit install
|
||||||
```
|
```
|
||||||
|
|
||||||
This step must be done on each machine you wish to develop and contribute from to activate the `commit-msg` hook client-side.
|
This step must be done on each machine you wish to develop and contribute from to activate the `commit-msg` and `commit` hooks client-side.
|
||||||
|
|
||||||
Once you have done these things, we look forward to adding your contributions and improvements to the Dragonfly DB project.
|
Once you have done these things, we look forward to adding your contributions and improvements to the Dragonfly DB project.
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue