From 60170a4265f500c2520a981c39291c4cfeddf86d Mon Sep 17 00:00:00 2001 From: Robin Jarry Date: Thu, 21 Mar 2024 09:19:15 +0100 Subject: [PATCH 1/5] ci: try to make git work in github actions Signed-off-by: Robin Jarry --- .github/workflows/ci.yml | 20 ++++++++++++++++++-- GNUmakefile | 2 +- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1b94e40d5..153f4a4fe 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -14,16 +14,32 @@ jobs: runs-on: ubuntu-latest container: fedora:latest steps: - - uses: actions/checkout@v4 - run: | dnf install -y \ - make gcc ninja-build meson clang-tools-extra git gcovr scdoc \ + make gcc ninja-build meson git gcovr scdoc \ libasan \ libcmocka-devel \ libedit-devel \ libevent-devel \ numactl-devel \ python3-pyelftools + - uses: actions/checkout@v4 - run: make - run: make coverage + lint: + runs-on: ubuntu-latest + container: debian:testing + env: + DEBIAN_FRONTEND: noninteractive + steps: + - run: | + apt-get update + apt-get install -y make clang-format git + - uses: actions/checkout@v4 + with: + fetch-depth: 0 - run: make lint + - run: | + git config --global --add safe.directory $PWD + git log --oneline --decorate "${{ github.base_ref }}..${{ github.ref }}" + if: ${{ github.base_ref && github.ref }} diff --git a/GNUmakefile b/GNUmakefile index 148cbb094..fcc9f6b4a 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -46,7 +46,7 @@ c_src = `find * .* $(foreach d,$(exclude),$(call prune,$d)) -type f -name '*.[ch all_files = `find * .* $(foreach d,$(exclude),$(call prune,$d)) -type f -print` .PHONY: lint -lint: $(BUILDDIR)/build.ninja +lint: @echo '[clang-format]' $Q clang-format --dry-run --Werror $(c_src) @echo '[license-check]' From c46221fc8fec98ba0498d5592f584747907230f5 Mon Sep 17 00:00:00 2001 From: Robin Jarry Date: Thu, 21 Mar 2024 12:01:07 +0100 Subject: [PATCH 2/5] clang: fix for older versions Signed-off-by: Robin Jarry --- .clang-format | 5 ++--- GNUmakefile | 14 ++++++++------ modules/ip4/datapath/lookup.c | 3 +-- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/.clang-format b/.clang-format index 64efabb58..88f48f9c8 100644 --- a/.clang-format +++ b/.clang-format @@ -32,7 +32,7 @@ BitFieldColonSpacing: Both BraceWrapping: AfterCaseLabel: false AfterClass: false - AfterControlStatement: MultiLine + AfterControlStatement: Never AfterEnum: false AfterExternBlock: false AfterFunction: false @@ -56,7 +56,6 @@ BreakConstructorInitializers: BeforeComma BreakConstructorInitializersBeforeComma: false BreakInheritanceList: BeforeColon BreakStringLiterals: true -BracedInitializerIndentWidth: 8 ColumnLimit: 100 CommentPragmas: '^ IWYU pragma:' CompactNamespaces: false @@ -174,7 +173,7 @@ SpacesInLineCommentPrefix: Maximum: -1 SpacesInParentheses: false SpacesInSquareBrackets: false -Standard: Latest +Standard: c++20 StatementAttributeLikeMacros: - Q_EMIT StatementMacros: diff --git a/GNUmakefile b/GNUmakefile index fcc9f6b4a..918b28c13 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -41,16 +41,17 @@ $(BUILDDIR)/build.ninja: meson setup $(BUILDDIR) $(meson_opts) prune = -path $1 -prune -o -exclude = $(BUILDDIR) subprojects LICENSE .git README.md .lsan-suppressions main/include/stb_ds.h -c_src = `find * .* $(foreach d,$(exclude),$(call prune,$d)) -type f -name '*.[ch]' -print` -all_files = `find * .* $(foreach d,$(exclude),$(call prune,$d)) -type f -print` +exclude = $(BUILDDIR) subprojects LICENSE README.md main/include/stb_ds.h +c_src = find * $(foreach d,$(exclude),$(call prune,$d)) -type f -name '*.[ch]' -print +all_files = find * $(foreach d,$(exclude),$(call prune,$d)) -type f -print .PHONY: lint lint: @echo '[clang-format]' - $Q clang-format --dry-run --Werror $(c_src) + $Q tmp=`mktemp` && trap "rm -f $$tmp" EXIT && $(c_src) > "$$tmp" && \ + clang-format --files="$$tmp" --dry-run --Werror @echo '[license-check]' - $Q ! for f in $(all_files); do \ + $Q ! $(all_files) | while read -r f; do \ if ! grep -qF 'SPDX-License-Identifier: BSD-3-Clause' $$f; then \ echo $$f; \ fi; \ @@ -65,4 +66,5 @@ lint: .PHONY: format format: @echo '[clang-format]' - $Q clang-format -i --verbose $(c_src) + $Q tmp=`mktemp` && trap "rm -f $$tmp" EXIT && $(c_src) > "$$tmp" && \ + clang-format --files="$$tmp" -i --verbose diff --git a/modules/ip4/datapath/lookup.c b/modules/ip4/datapath/lookup.c index ed70c0867..d1275f220 100644 --- a/modules/ip4/datapath/lookup.c +++ b/modules/ip4/datapath/lookup.c @@ -85,8 +85,7 @@ lookup_process(struct rte_graph *graph, struct rte_node *node, void **objs, uint // TODO: optimize with lookup of multiple packets if (rte_fib_lookup_bulk(fib, &dst_addr, &next_hop, 1) < 0 - || next_hop == BR_NO_ROUTE) - { + || next_hop == BR_NO_ROUTE) { next = NO_ROUTE; goto next_packet; } From cd6b94d7b5f67791fd98bbf3975e2e34b3b8ccdb Mon Sep 17 00:00:00 2001 From: Robin Jarry Date: Thu, 21 Mar 2024 12:11:22 +0100 Subject: [PATCH 3/5] wip Signed-off-by: Robin Jarry --- .github/workflows/ci.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 153f4a4fe..a23e1bd94 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -40,6 +40,7 @@ jobs: fetch-depth: 0 - run: make lint - run: | + echo $${{github.event}} git config --global --add safe.directory $PWD - git log --oneline --decorate "${{ github.base_ref }}..${{ github.ref }}" + git log --oneline --decorate "origin/${{ github.base_ref }}..${{ github.ref }}" if: ${{ github.base_ref && github.ref }} From 6c244364206241fed008c4137c7b218aab4f0019 Mon Sep 17 00:00:00 2001 From: Robin Jarry Date: Thu, 21 Mar 2024 12:13:32 +0100 Subject: [PATCH 4/5] wip Signed-off-by: Robin Jarry --- .github/workflows/ci.yml | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a23e1bd94..c987b8e00 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -34,13 +34,12 @@ jobs: steps: - run: | apt-get update - apt-get install -y make clang-format git + apt-get install -y make clang-format git jq - uses: actions/checkout@v4 with: fetch-depth: 0 - run: make lint - run: | - echo $${{github.event}} git config --global --add safe.directory $PWD - git log --oneline --decorate "origin/${{ github.base_ref }}..${{ github.ref }}" - if: ${{ github.base_ref && github.ref }} + git log --oneline --decorate "${{ github.pull_request.base.sha }}..${{ github.pull_request.head.sha }}" + if: ${{ github.pull_request.base.sha && github.pull_request.head.sha }} From d10c3763ccf64708970471f7c306aed72e369146 Mon Sep 17 00:00:00 2001 From: Robin Jarry Date: Thu, 21 Mar 2024 12:28:43 +0100 Subject: [PATCH 5/5] wip Signed-off-by: Robin Jarry --- .github/workflows/ci.yml | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c987b8e00..e63d7320c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -28,18 +28,14 @@ jobs: - run: make coverage lint: runs-on: ubuntu-latest - container: debian:testing - env: - DEBIAN_FRONTEND: noninteractive steps: - - run: | - apt-get update - apt-get install -y make clang-format git jq + - run: sudo apt-get install make clang-format git - uses: actions/checkout@v4 with: fetch-depth: 0 - run: make lint + # TODO: later, check commit messages here - run: | git config --global --add safe.directory $PWD - git log --oneline --decorate "${{ github.pull_request.base.sha }}..${{ github.pull_request.head.sha }}" - if: ${{ github.pull_request.base.sha && github.pull_request.head.sha }} + git log --oneline --decorate "${{ github.event.pull_request.base.sha }}..${{ github.event.pull_request.head.sha }}" + if: ${{ github.event.pull_request.base.sha && github.event.pull_request.head.sha }}