From a8edd04537bb675e70128b113ffeb50f8c9e7112 Mon Sep 17 00:00:00 2001 From: Unam3dd Date: Thu, 13 Jun 2024 17:05:46 +0200 Subject: [PATCH 01/10] =?UTF-8?q?=E2=9A=97=EF=B8=8F=20Add=20clang-tidy=20c?= =?UTF-8?q?onfiguration=20and=20his=20task=20in=20Taskfile=20named=20'norm?= =?UTF-8?q?'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This commit add only clang-tidy configuration and a task no CI/CD implementation --- .clang-tidy | 12 ++++++++++++ Taskfile.yml | 7 +++++++ 2 files changed, 19 insertions(+) create mode 100644 .clang-tidy diff --git a/.clang-tidy b/.clang-tidy new file mode 100644 index 0000000..15e2707 --- /dev/null +++ b/.clang-tidy @@ -0,0 +1,12 @@ +--- +Checks: 'readability-function-size, readability-math-missing-parentheses, readability-duplicate-include' +WarningsAsErrors: '.*' +HeaderFileExtensions: ['h'] +ImplementationFileExtensions: ['c'] +HeaderFilterRegex: 'inc/.*\\.h$' + +CheckOptions: + - key: readability-function-size.LineThreshold + value: '25' + - key: readability-function-size.ParameterThreshold + value: '5' diff --git a/Taskfile.yml b/Taskfile.yml index ca492f3..f69cd3e 100644 --- a/Taskfile.yml +++ b/Taskfile.yml @@ -30,6 +30,13 @@ tasks: silent: true desc: "Build the project in release build in stripped mode" + norm: + preconditions: + - sh: '{{if eq OS "windows"}} powershell.exe -Command Test-Path build {{else}} test -d build {{end}}' + msg: "Norm required compile_commands.json files please build the project before !" + cmds: + - clang-tidy -p ./build src/**/*.c + build-dev: preconditions: - sh: '{{if eq OS "windows"}} powershell.exe -Command Test-Path dist {{else}} test ! -d dist {{end}}' From d58cdc21f5f15fdd2d193d55665f3fc3ab4f82f7 Mon Sep 17 00:00:00 2001 From: Unam3dd Date: Thu, 13 Jun 2024 17:12:52 +0200 Subject: [PATCH 02/10] =?UTF-8?q?=F0=9F=91=B7=20Add=20norm=20on=20CI/CD=20?= =?UTF-8?q?pipeline?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit I add the norm container to pass the norm on the project and verify the rules defined in ISSUE #13 --- .github/workflows/norm.yml | 39 ++++++++++++++++++++++++++++++++++++++ Taskfile.yml | 4 +++- 2 files changed, 42 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/norm.yml diff --git a/.github/workflows/norm.yml b/.github/workflows/norm.yml new file mode 100644 index 0000000..b5f2bf5 --- /dev/null +++ b/.github/workflows/norm.yml @@ -0,0 +1,39 @@ +name: Norm + +on: [push, pull_request] + +permissions: + contents: read + +jobs: + norm: + runs-on: ubuntu-latest + steps: + - name: Checkout repository ${{ github.repository }} on a branch ${{ github.ref_name }} triggered by ${{ github.event_name }} + uses: actions/checkout@v4 + + - run: "echo the ${{ github.repository }} has been cloned in the container !" + + - name: 🔄 Installing task... + uses: arduino/setup-task@v2 + with: + version: 3.x + + - uses: actions/setup-python@v5 + + - name: 🔄 Installing Meson package build system... + run: pip install meson + + - name: 🔄 Installing Dependencies... + run: | + echo "📦 Installing libcriterion-dev, Ninja" + sudo apt-get update && sudo apt-get install -y libcriterion-dev ninja-build + echo "✅ Dependencies installed!" + + - name: Run build release task... + run: | + echo "🏗️ Setting up Meson build system..." + task build + echo "🔄 Check the Norm..." + task norm + echo "🎉 Build completed with Meson!" diff --git a/Taskfile.yml b/Taskfile.yml index f69cd3e..be0a8f2 100644 --- a/Taskfile.yml +++ b/Taskfile.yml @@ -35,7 +35,9 @@ tasks: - sh: '{{if eq OS "windows"}} powershell.exe -Command Test-Path build {{else}} test -d build {{end}}' msg: "Norm required compile_commands.json files please build the project before !" cmds: - - clang-tidy -p ./build src/**/*.c + - clang-tidy -p./build src/**/*.c + silent: true + desc: "Pass the norm on the project" build-dev: preconditions: From 454e43ae0a0a827ce19c6f67998b813014b684e3 Mon Sep 17 00:00:00 2001 From: Unam3dd Date: Thu, 13 Jun 2024 17:15:06 +0200 Subject: [PATCH 03/10] =?UTF-8?q?=F0=9F=A9=B9=20Fix=20Taskfile=20path=20fo?= =?UTF-8?q?r=20norm=20task?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit -p and path must be separated by a whitespace --- Taskfile.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Taskfile.yml b/Taskfile.yml index be0a8f2..6fd0ff2 100644 --- a/Taskfile.yml +++ b/Taskfile.yml @@ -35,7 +35,7 @@ tasks: - sh: '{{if eq OS "windows"}} powershell.exe -Command Test-Path build {{else}} test -d build {{end}}' msg: "Norm required compile_commands.json files please build the project before !" cmds: - - clang-tidy -p./build src/**/*.c + - clang-tidy -p ./build src/**/*.c silent: true desc: "Pass the norm on the project" From a9c5c51868d41628ed262192493399a2c2d129bc Mon Sep 17 00:00:00 2001 From: Unam3dd Date: Thu, 13 Jun 2024 17:17:37 +0200 Subject: [PATCH 04/10] =?UTF-8?q?=F0=9F=92=9A=20Fix=20norm=20action=20cont?= =?UTF-8?q?ainer=20clang-tidy=20is=20not=20version=20supported=20keywords?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fix CI build --- .github/workflows/norm.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/norm.yml b/.github/workflows/norm.yml index b5f2bf5..b1147f6 100644 --- a/.github/workflows/norm.yml +++ b/.github/workflows/norm.yml @@ -27,7 +27,7 @@ jobs: - name: 🔄 Installing Dependencies... run: | echo "📦 Installing libcriterion-dev, Ninja" - sudo apt-get update && sudo apt-get install -y libcriterion-dev ninja-build + sudo apt-get update && sudo apt-get install -y libcriterion-dev ninja-build clang-tidy echo "✅ Dependencies installed!" - name: Run build release task... From aa88fac4de6cd6b59f899063ebc30183b471bc7e Mon Sep 17 00:00:00 2001 From: Unam3dd Date: Thu, 13 Jun 2024 17:19:10 +0200 Subject: [PATCH 05/10] =?UTF-8?q?=F0=9F=92=9A=20Fix=20CI=20build?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit build --- .github/workflows/norm.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/norm.yml b/.github/workflows/norm.yml index b1147f6..82824e0 100644 --- a/.github/workflows/norm.yml +++ b/.github/workflows/norm.yml @@ -36,4 +36,3 @@ jobs: task build echo "🔄 Check the Norm..." task norm - echo "🎉 Build completed with Meson!" From 677e41c7ff4be3c64d179c4d1de03c1d220c4a09 Mon Sep 17 00:00:00 2001 From: Unam3dd Date: Fri, 14 Jun 2024 09:48:36 +0200 Subject: [PATCH 06/10] =?UTF-8?q?=E2=9C=8F=EF=B8=8F=20Just=20fix=20directi?= =?UTF-8?q?ve=20in=20.clang-tidy?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Just fix directive in file ~/.clang-tidy because ImplementationFileExtension is a unrecognized directory --- .clang-tidy | 2 -- 1 file changed, 2 deletions(-) diff --git a/.clang-tidy b/.clang-tidy index 15e2707..249cfed 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -1,8 +1,6 @@ --- Checks: 'readability-function-size, readability-math-missing-parentheses, readability-duplicate-include' WarningsAsErrors: '.*' -HeaderFileExtensions: ['h'] -ImplementationFileExtensions: ['c'] HeaderFilterRegex: 'inc/.*\\.h$' CheckOptions: From bf3f20fa6c933da8088b7e21e53cb823d0208c19 Mon Sep 17 00:00:00 2001 From: Unam3dd Date: Fri, 14 Jun 2024 10:10:14 +0200 Subject: [PATCH 07/10] =?UTF-8?q?=F0=9F=92=9A=20Fix=20Norm=20command=20cla?= =?UTF-8?q?ng-tidy?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When an error is detected by clang-tidy the return code is not a non zero value so it's embarrassing So to remedy the problem I create a command in Taskfile. When an error is occured the return code is non zero value otherwise is just 0 --- Taskfile.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Taskfile.yml b/Taskfile.yml index 6fd0ff2..af2bff6 100644 --- a/Taskfile.yml +++ b/Taskfile.yml @@ -31,11 +31,12 @@ tasks: desc: "Build the project in release build in stripped mode" norm: + platforms: ["linux"] preconditions: - - sh: '{{if eq OS "windows"}} powershell.exe -Command Test-Path build {{else}} test -d build {{end}}' + - sh: 'test -d build' msg: "Norm required compile_commands.json files please build the project before !" cmds: - - clang-tidy -p ./build src/**/*.c + - CLANG_TIDY=$(clang-tidy -p ./build main.c | grep "warning"); [[ ! -z "$CLANG_TIDY" ]] && return 1 || return 0; silent: true desc: "Pass the norm on the project" From c94494083166110b010ae9210b566b00a95fe3f5 Mon Sep 17 00:00:00 2001 From: Unam3dd Date: Fri, 14 Jun 2024 10:12:56 +0200 Subject: [PATCH 08/10] =?UTF-8?q?=E2=9C=8F=EF=B8=8F=20Add=20the=20output?= =?UTF-8?q?=20of=20warning=20treated=20as=20errors=20by=20clang-Tidy?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Taskfile.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Taskfile.yml b/Taskfile.yml index af2bff6..b55997b 100644 --- a/Taskfile.yml +++ b/Taskfile.yml @@ -36,7 +36,7 @@ tasks: - sh: 'test -d build' msg: "Norm required compile_commands.json files please build the project before !" cmds: - - CLANG_TIDY=$(clang-tidy -p ./build main.c | grep "warning"); [[ ! -z "$CLANG_TIDY" ]] && return 1 || return 0; + - CLANG_TIDY=$(clang-tidy -p ./build main.c | grep "warning"); [[ ! -z "$CLANG_TIDY" ]] && echo $CLANG_TIDY && return 1 || return 0; silent: true desc: "Pass the norm on the project" From ba56325fd0cfa4c37541634e2fcc5600dc58dd6d Mon Sep 17 00:00:00 2001 From: Unam3dd Date: Fri, 14 Jun 2024 10:20:58 +0200 Subject: [PATCH 09/10] =?UTF-8?q?=F0=9F=92=9A=20Sorry=20for=20my=20mistake?= =?UTF-8?q?s=20I=20forget=20to=20change=20te=20directory?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Taskfile.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Taskfile.yml b/Taskfile.yml index b55997b..a01eb87 100644 --- a/Taskfile.yml +++ b/Taskfile.yml @@ -36,7 +36,7 @@ tasks: - sh: 'test -d build' msg: "Norm required compile_commands.json files please build the project before !" cmds: - - CLANG_TIDY=$(clang-tidy -p ./build main.c | grep "warning"); [[ ! -z "$CLANG_TIDY" ]] && echo $CLANG_TIDY && return 1 || return 0; + - CLANG_TIDY=$(clang-tidy -p ./build src/**/*.c | grep "warning"); [[ ! -z "$CLANG_TIDY" ]] && echo $CLANG_TIDY && exit 1 || exit 0; silent: true desc: "Pass the norm on the project" From 017c132753d2116c4984a7cdb9c5c69baf123aea Mon Sep 17 00:00:00 2001 From: Unam3dd Date: Fri, 14 Jun 2024 10:26:13 +0200 Subject: [PATCH 10/10] =?UTF-8?q?=E2=9C=8F=EF=B8=8F=20Just=20remove=20Head?= =?UTF-8?q?erfileRegex=20directive=20in=20.clang-tidy?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .clang-tidy | 1 - 1 file changed, 1 deletion(-) diff --git a/.clang-tidy b/.clang-tidy index 249cfed..dde92bf 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -1,7 +1,6 @@ --- Checks: 'readability-function-size, readability-math-missing-parentheses, readability-duplicate-include' WarningsAsErrors: '.*' -HeaderFilterRegex: 'inc/.*\\.h$' CheckOptions: - key: readability-function-size.LineThreshold