Skip to content

Commit

Permalink
pre-commit: integrate with cndp
Browse files Browse the repository at this point in the history
Install pre-commit for CNDP + its configuration.
Remove old githook.

Signed-off-by: Maryam Tahhan <[email protected]>
  • Loading branch information
maryamtahhan committed Jun 20, 2024
1 parent aeb5b8f commit 8571b66
Show file tree
Hide file tree
Showing 117 changed files with 1,301 additions and 1,095 deletions.
22 changes: 22 additions & 0 deletions .cndpstyle.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Style configuration for CNDP documentation files.
#
# For details on how to configure, see [markdownlint docs][1].
#
# For explanation of the rules themselves, see [markdownlint's RULES.md][2]
#
# [1]: https://github.com/markdownlint/markdownlint/blob/master/docs/creating_styles.md
# [2]: https://github.com/markdownlint/markdownlint/blob/master/docs/RULES.md

tag :whitespace
tag :headers
tag :ul
tag :indentation
tag :bullet

rule "ul-indent", indent: 4

rule "ul-style", style: :dash
rule "no-duplicate-header", allow_different_nesting: true
rule "line-length", :line_length => 165

exclude_rule 'MD010' # Hard tabs
19 changes: 0 additions & 19 deletions .githooks/pre-commit

This file was deleted.

10 changes: 5 additions & 5 deletions .github/workflows/cache-build.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
name: Docker Image Build with cache

on:
on: # yamllint disable-line rule:truthy
push:
branches:
- main
pull_request:
branches: [ main ]
branches: [main]

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
Expand Down Expand Up @@ -50,9 +50,9 @@ jobs:
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache-new

# Temp fix
# https://github.com/docker/build-push-action/issues/252
# https://github.com/moby/buildkit/issues/1896
# Temp fix
# https://github.com/docker/build-push-action/issues/252
# https://github.com/moby/buildkit/issues/1896
- name: Move cache
run: |
rm -rf /tmp/.buildx-cache && \
Expand Down
18 changes: 9 additions & 9 deletions .github/workflows/clang-format.yml
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
name: clang-format

on:
on: # yamllint disable-line rule:truthy
pull_request:
branches: [ main ]
branches: [main]

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- uses: DoozyX/[email protected]
with:
source: '.'
exclude: './examples/vpp-plugin'
extensions: 'c,h,cc,cpp'
clangFormatVersion: 15.0.2
- uses: actions/checkout@v4
- uses: DoozyX/[email protected]
with:
source: '.'
exclude: './examples/vpp-plugin'
extensions: 'c,h,cc,cpp'
clangFormatVersion: 15.0.2
12 changes: 6 additions & 6 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
name: Docker Image Build

on:
on: # yamllint disable-line rule:truthy
pull_request:
branches: [ main ]
branches: [main]

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
Expand All @@ -13,8 +13,8 @@ jobs:
runs-on: ubuntu-latest

steps:
- name: Check out repository code
uses: actions/checkout@v4
- name: Check out repository code
uses: actions/checkout@v4

- name: Build Docker Image
run: make oci-image
- name: Build Docker Image
run: make oci-image
38 changes: 18 additions & 20 deletions .github/workflows/rust-build.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
name: Rust

on:
on: # yamllint disable-line rule:truthy
push:
branches: [ "main" ]
branches: [main]
pull_request:
branches: [ "main" ]
branches: [main]

env:
CARGO_TERM_COLOR: always
Expand All @@ -17,24 +17,22 @@ jobs:
runs-on: ubuntu-latest

steps:
- name: Check out repository code
uses: actions/checkout@v4
- name: Check out repository code
uses: actions/checkout@v4

- name: Install packages
run: |
sudo apt-get update && sudo apt-get install -y\
build-essential libbsd-dev libelf-dev libjson-c-dev\
libnl-3-dev libnl-cli-3-dev libnuma-dev libpcap-dev meson\
pkg-config wget libbpf-dev llvm-dev libclang-dev clang
- name: Install packages
run: |
sudo apt-get update && sudo apt-get install -y\
build-essential libbsd-dev libelf-dev libjson-c-dev\
libnl-3-dev libnl-cli-3-dev libnuma-dev libpcap-dev meson\
pkg-config wget libbpf-dev llvm-dev libclang-dev clang
- name: Build and Install CNDP
run: make; sudo CNE_DEST_DIR=/ make install

- name: update rust
run: rustup update stable

- name: Build and Install CNDP
run: make; sudo CNE_DEST_DIR=/ make install

- name: update rust
run: rustup update stable

- name: Build
working-directory: lang/rs
run: CLANG_PATH=/usr/bin/clang-15 cargo build
- name: Build
working-directory: lang/rs
run: CLANG_PATH=/usr/bin/clang-15 cargo build
62 changes: 31 additions & 31 deletions .github/workflows/smoke.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
name: Smoke Test

on:
on: # yamllint disable-line rule:truthy
pull_request:
branches: [ main ]
branches: [main]

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
Expand All @@ -13,32 +13,32 @@ jobs:
runs-on: ubuntu-latest

steps:
- name: Check out repository code
uses: actions/checkout@v4

- name: Install packages
run: |
sudo apt-get update && sudo apt-get install -y\
build-essential libbsd-dev libelf-dev libjson-c-dev\
libnl-3-dev libnl-cli-3-dev libnuma-dev libpcap-dev meson\
pkg-config wget
- name: Install libbpf
run: |
wget -q -O - https://github.com/libbpf/libbpf/archive/refs/tags/v0.5.0.tar.gz \
| tar -xzC "${GITHUB_WORKSPACE}" \
&& sudo make -j -C "${GITHUB_WORKSPACE}"/libbpf-0.5.0/src install \
&& sudo rm -rf "${GITHUB_WORKSPACE}"/libbpf-0.5.0
- name: Build
run: make

- name: Short test
run: meson test -C builddir --suite short

- name: Upload testlog
uses: actions/upload-artifact@v3
if: success() || failure()
with:
name: testlog.txt
path: ${{ github.workspace }}/builddir/meson-logs/testlog.txt
- name: Check out repository code
uses: actions/checkout@v4

- name: Install packages
run: |
sudo apt-get update && sudo apt-get install -y\
build-essential libbsd-dev libelf-dev libjson-c-dev\
libnl-3-dev libnl-cli-3-dev libnuma-dev libpcap-dev meson\
pkg-config wget
- name: Install libbpf
run: |
wget -q -O - https://github.com/libbpf/libbpf/archive/refs/tags/v0.5.0.tar.gz \
| tar -xzC "${GITHUB_WORKSPACE}" \
&& sudo make -j -C "${GITHUB_WORKSPACE}"/libbpf-0.5.0/src install \
&& sudo rm -rf "${GITHUB_WORKSPACE}"/libbpf-0.5.0
- name: Build
run: make

- name: Short test
run: meson test -C builddir --suite short

- name: Upload testlog
uses: actions/upload-artifact@v3
if: success() || failure()
with:
name: testlog.txt
path: ${{ github.workspace }}/builddir/meson-logs/testlog.txt
6 changes: 3 additions & 3 deletions .github/workflows/super-linter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
# https://github.com/github/super-linter
name: Lint Code Base

on:
on: # yamllint disable-line rule:truthy
push:
branches: [ "main" ]
branches: [main]
pull_request:
branches: [ "main" ]
branches: [main]
jobs:
run-lint:
runs-on: ubuntu-latest
Expand Down
2 changes: 2 additions & 0 deletions .mdlrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
style ".cndpstyle.rb"
ignore_front_matter true
63 changes: 63 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# See https://pre-commit.com for more information
# See https://pre-commit.com/hooks.html for more hooks
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.6.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-added-large-files
- repo: https://github.com/adrienverge/yamllint
rev: v1.35.1
hooks:
- id: yamllint
- repo: https://github.com/pre-commit/mirrors-clang-format
rev: v17.0.6
hooks:
- id: clang-format
name: clang-format
entry: clang-format -i
language: python
'types_or': [c]
args: ["-style=file"]
require_serial: false
minimum_pre_commit_version: '2.9.2'
- repo: https://github.com/golangci/golangci-lint
rev: v1.59.1
hooks:
- id: golangci-lint
- repo: https://github.com/executablebooks/mdformat
# Do this before other tools "fixing" the line endings
rev: 0.7.17
hooks:
- id: mdformat
name: Format Markdown
entry: mdformat # Executable to run, with fixed options
language: python
types: [markdown]
additional_dependencies:
- mdformat-frontmatter
- mdformat-toc
- mdformat-shfmt
- mdformat-tables
- mdformat-config
- mdformat-black
- mdformat-web
- mdformat-gfm
- repo: https://github.com/markdownlint/markdownlint.git
rev: v0.13.0
hooks:
- id: markdownlint_docker
name: Markdownlint Docker
description: Run markdown lint on your Markdown files using the project docker image
language: docker_image
files: \.(md|mdown|markdown)$
entry: markdownlint/markdownlint -c .mdlrc
- repo: https://github.com/codespell-project/codespell
rev: v2.3.0
hooks:
- id: codespell
args: [--toml, cndp-codespell.precommit-toml]
additional_dependencies:
- tomli
# exclude: ^dir-1/.*|^dir2/.*
10 changes: 10 additions & 0 deletions .yamllint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
extends: default
rules:
line-length: disable
document-start: disable
comments:
min-spaces-from-content: 1
ignore:
- builddir/*
- .clang-format
Loading

0 comments on commit 8571b66

Please sign in to comment.