From 7733ef217565c1247980ff2ed437501f98ff6c3c Mon Sep 17 00:00:00 2001 From: Yann Stephen Mandza Date: Tue, 31 Mar 2026 13:00:39 -0700 Subject: [PATCH 1/4] add CPP standard CI workflow with cppcheck support Add reusable cpp-standard.yml workflow for C++ projects, mirroring the TwinCAT standard workflow pattern. Add `install-cppcheck` boolean input (default: false) to pre-commit.yml so C++ workflows can ensure cppcheck is available on the runner before running pre-commit hooks. --- .github/workflows/cpp-standard.yml | 19 +++++++++++++++++++ .github/workflows/pre-commit.yml | 10 +++++++++- 2 files changed, 28 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/cpp-standard.yml diff --git a/.github/workflows/cpp-standard.yml b/.github/workflows/cpp-standard.yml new file mode 100644 index 0000000..6b8c5cc --- /dev/null +++ b/.github/workflows/cpp-standard.yml @@ -0,0 +1,19 @@ +name: PCDS CPP Standard Tests + +on: + workflow_call: + inputs: + project-root: + required: false + type: string + default: "." + description: "The root directory of the CPP project" + +jobs: + pre-commit: + name: "pre-commit checks" + uses: ./.github/workflows/pre-commit.yml + secrets: inherit + with: + args: "--all-files" + install-cppcheck: true \ No newline at end of file diff --git a/.github/workflows/pre-commit.yml b/.github/workflows/pre-commit.yml index 12ab8fc..0a3359d 100644 --- a/.github/workflows/pre-commit.yml +++ b/.github/workflows/pre-commit.yml @@ -16,7 +16,11 @@ on: description: "Use the problem matcher to annotate the PR diff" required: false type: boolean - + install-cppcheck: + default: false + description: "Install cppcheck before running pre-commit" + required: false + type: boolean jobs: pre-commit: runs-on: ubuntu-latest @@ -65,6 +69,10 @@ jobs: EOF echo "::add-matcher::$HOME/flake8_problem_matcher.json" + - name: Install cppcheck + if: ${{ inputs.install-cppcheck }} + run: sudo apt-get install -y cppcheck + - name: Install pre-commit run: | python -m pip install pre-commit From 764a9f35abf52783192550ec6782c3b3a9bf1ca4 Mon Sep 17 00:00:00 2001 From: Yann Stephen Mandza Date: Tue, 31 Mar 2026 13:16:54 -0700 Subject: [PATCH 2/4] pre-commit clean ups --- .github/workflows/cpp-standard.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/cpp-standard.yml b/.github/workflows/cpp-standard.yml index 6b8c5cc..f9c788a 100644 --- a/.github/workflows/cpp-standard.yml +++ b/.github/workflows/cpp-standard.yml @@ -16,4 +16,4 @@ jobs: secrets: inherit with: args: "--all-files" - install-cppcheck: true \ No newline at end of file + install-cppcheck: true From 4291f7f339b029b08fab75326fe2edfdd4853db7 Mon Sep 17 00:00:00 2001 From: Yann Stephen Mandza Date: Sat, 4 Apr 2026 08:03:30 -0700 Subject: [PATCH 3/4] Replaced install-cppcheck with generic system-packages input Replaced the C++-specific `install-cppcheck` boolean input with a generic `system-packages` string input in pre-commit.yml.Updated cpp-standard.yml to pass `system-packages: "cppcheck"` accordingly. --- .github/workflows/cpp-standard.yml | 2 +- .github/workflows/pre-commit.yml | 20 ++++++++++++-------- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/.github/workflows/cpp-standard.yml b/.github/workflows/cpp-standard.yml index f9c788a..6a6ecb0 100644 --- a/.github/workflows/cpp-standard.yml +++ b/.github/workflows/cpp-standard.yml @@ -16,4 +16,4 @@ jobs: secrets: inherit with: args: "--all-files" - install-cppcheck: true + system-packages: "cppcheck" \ No newline at end of file diff --git a/.github/workflows/pre-commit.yml b/.github/workflows/pre-commit.yml index 0a3359d..9163e6c 100644 --- a/.github/workflows/pre-commit.yml +++ b/.github/workflows/pre-commit.yml @@ -16,11 +16,12 @@ on: description: "Use the problem matcher to annotate the PR diff" required: false type: boolean - install-cppcheck: - default: false - description: "Install cppcheck before running pre-commit" + system-packages: + default: "" + description: "Space-separated list of system packages to install before running pre-commit" required: false - type: boolean + type: string + jobs: pre-commit: runs-on: ubuntu-latest @@ -29,6 +30,7 @@ jobs: - uses: actions/checkout@v4 with: token: ${{ secrets.CHECKOUT_TOKEN || github.token }} + - name: Configure the matcher to annotate the diff if: ${{ inputs.annotate }} run: | @@ -69,9 +71,11 @@ jobs: EOF echo "::add-matcher::$HOME/flake8_problem_matcher.json" - - name: Install cppcheck - if: ${{ inputs.install-cppcheck }} - run: sudo apt-get install -y cppcheck + - name: Install required system packages + if: inputs.system-packages != '' + run: | + sudo apt-get update + sudo apt-get -y install ${{ inputs.system-packages }} - name: Install pre-commit run: | @@ -99,4 +103,4 @@ jobs: pre-commit run \ --show-diff-on-failure \ --color=always \ - ${{ inputs.args }} + ${{ inputs.args }} \ No newline at end of file From 2088c09005e3f90af442724c9235e4b3d994e6e3 Mon Sep 17 00:00:00 2001 From: Yann Stephen Mandza Date: Sat, 4 Apr 2026 08:07:22 -0700 Subject: [PATCH 4/4] pre-commit cleanups --- .github/workflows/cpp-standard.yml | 2 +- .github/workflows/pre-commit.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/cpp-standard.yml b/.github/workflows/cpp-standard.yml index 6a6ecb0..11a1a36 100644 --- a/.github/workflows/cpp-standard.yml +++ b/.github/workflows/cpp-standard.yml @@ -16,4 +16,4 @@ jobs: secrets: inherit with: args: "--all-files" - system-packages: "cppcheck" \ No newline at end of file + system-packages: "cppcheck" diff --git a/.github/workflows/pre-commit.yml b/.github/workflows/pre-commit.yml index 9163e6c..3b64614 100644 --- a/.github/workflows/pre-commit.yml +++ b/.github/workflows/pre-commit.yml @@ -103,4 +103,4 @@ jobs: pre-commit run \ --show-diff-on-failure \ --color=always \ - ${{ inputs.args }} \ No newline at end of file + ${{ inputs.args }}