From cf10b95f4c22f4db4e4f6afd8387da64517b1ecd Mon Sep 17 00:00:00 2001 From: Derek G Foster Date: Mon, 29 Jan 2024 17:53:41 -0800 Subject: [PATCH] Refine p4cp github lint workflows (#398) - Rename lintdocs.yml to linters.yml. - Move py_bandit_check and clang_format_check to linters.yml. - Expand py_bandit_check to apply to all .py files. Signed-off-by: Derek G Foster Signed-off-by: Satish Pitchikala --- .../workflows/{lintdocs.yml => linters.yml} | 52 ++++++++++++++++++- .github/workflows/pipeline.yml | 52 ++----------------- README.md | 2 +- 3 files changed, 55 insertions(+), 51 deletions(-) rename .github/workflows/{lintdocs.yml => linters.yml} (65%) diff --git a/.github/workflows/lintdocs.yml b/.github/workflows/linters.yml similarity index 65% rename from .github/workflows/lintdocs.yml rename to .github/workflows/linters.yml index 681fff9b..baade59b 100644 --- a/.github/workflows/lintdocs.yml +++ b/.github/workflows/linters.yml @@ -1,4 +1,4 @@ -name: "Lint P4CP Documentation" +name: "P4CP lint checks" on: push: @@ -10,6 +10,11 @@ on: - main - ipdk_v* +concurrency: + # If workflow is currently running, stop it and start a new one. + group: lint-${{ github.ref }} + cancel-in-progress: true + permissions: read-all jobs: @@ -106,3 +111,48 @@ jobs: if: steps.changed.outputs.any_changed == 'true' run: | rstcheck ${{ steps.changed.outputs.all_changed_files }} + + #--------------------------------------------------------------------- + # 4-py_bandit_check + #--------------------------------------------------------------------- + py_bandit_check: + timeout-minutes: 5 + runs-on: ubuntu-latest + steps: + - name: Clone networking-recipe + uses: actions/checkout@v4 + + - name: Check Python files + uses: tj-actions/bandit@v5.5 + with: + targets: | # or a single string "." + **/**.py + clients/p4rt-ctl/p4rt-ctl.in + options: "-v" + + #--------------------------------------------------------------------- + # 5-clang_format_check + #--------------------------------------------------------------------- + clang_format_check: + runs-on: ubuntu-latest + timeout-minutes: 5 + + steps: + - name: Check out repository + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Get list of changed files + id: changed + uses: tj-actions/changed-files@v41 + with: + files: | + **.c + **.cc + **.h + + - name: Check for formatting errors + if: steps.changed.outputs.any_changed == 'true' + run: | + clang-format -n -Werror ${{ steps.changed.outputs.all_changed_files }} diff --git a/.github/workflows/pipeline.yml b/.github/workflows/pipeline.yml index bf9b252d..63fae80c 100644 --- a/.github/workflows/pipeline.yml +++ b/.github/workflows/pipeline.yml @@ -1,4 +1,4 @@ -name: "P4 Control Plane CI Pipeline" +name: "P4CP build checks" on: push: @@ -11,7 +11,7 @@ on: - ipdk_v* concurrency: - # If workflow for PR or push is already running, stop it and start a new one. + # If workflow is currently running, stop it and start a new one. group: build-${{ github.ref }} cancel-in-progress: true @@ -126,26 +126,7 @@ jobs: cmake --build build --target krnlmon-test #--------------------------------------------------------------------- - # 3-py_bandit_check - #--------------------------------------------------------------------- - py_bandit_check: - timeout-minutes: 5 - runs-on: ubuntu-latest - steps: - - name: Clone networking-recipe - uses: actions/checkout@v4 - with: - path: recipe - - - name: Check p4rt-ctl - uses: tj-actions/bandit@v5.5 - with: - targets: | # or a single string "." - ./recipe/clients/p4rt-ctl/p4rt-ctl.in - options: "-v" - - #--------------------------------------------------------------------- - # 4-build_p4runtime_protos + # 3-build_p4runtime_protos #--------------------------------------------------------------------- build_p4runtime_protos: runs-on: ubuntu-latest @@ -212,30 +193,3 @@ jobs: cmake -B build cmake --build build cmake --install build --prefix install - - #--------------------------------------------------------------------- - # 5-clang_format_check - #--------------------------------------------------------------------- - clang_format_check: - runs-on: ubuntu-latest - timeout-minutes: 5 - - steps: - - name: Check out repository - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - - name: Get list of changed files - id: changed - uses: tj-actions/changed-files@v42 - with: - files: | - **.c - **.cc - **.h - - - name: Check for formatting errors - if: steps.changed.outputs.any_changed == 'true' - run: | - clang-format -n -Werror ${{ steps.changed.outputs.all_changed_files }} diff --git a/README.md b/README.md index 4de48c9d..1e83e921 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ -[![P4 Control Plane CI Pipeline](https://github.com/ipdk-io/networking-recipe/actions/workflows/pipeline.yml/badge.svg)](https://github.com/ipdk-io/networking-recipe/actions/workflows/pipeline.yml) +[![P4CP build checks](https://github.com/ipdk-io/networking-recipe/actions/workflows/pipeline.yml/badge.svg)](https://github.com/ipdk-io/networking-recipe/actions/workflows/pipeline.yml) # P4 Control Plane