Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .bazelversion
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
7.4.1
60 changes: 60 additions & 0 deletions .github/workflows/gh_action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
---
name: Lint, build and test SRP-common
on:
push:
branches:
- master
pull_request:
branches:
- master
merge_group:
workflow_dispatch:
jobs:
cpplint:
name: CppLint Check
runs-on: ubuntu-latest
container:
image: ghcr.io/simba-avionic/simba_avionics_dockers/docker-action:latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
submodules: recursive

- name: Run cpplint
run: |
/bin/bash ./tools/cpplint/cpplint.sh

bazel-test:
name: SRP Unit Tests
needs: cpplint
runs-on: ubuntu-latest
container:
image: ghcr.io/simba-avionic/simba_avionics_dockers/docker-action:latest

steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
submodules: recursive

- name: Run Bazel tests
run: |
./tools/ut/unittest.sh --no_cache

build-all:
name: Build All
needs:
- bazel-test
runs-on: ubuntu-latest
container:
image: ghcr.io/simba-avionic/simba_avionics_dockers/docker-action:latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
submodules: recursive

- name: Build All
run: |
./tools/build_all/build_all.sh --no_cache
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,5 @@
*.app
/bazel-*
.DS_Store
MODULE.bazel.lock
MODULE.bazel
13 changes: 6 additions & 7 deletions MODULE.bazel
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
module(
name = "bazel_apogeum",
version = "0.1.0",
)
bazel_dep(name = "eigen", version = "4.0.0-20241125.bcr.2")
bazel_dep(name = "rules_cc", version = "0.0.17")

###############################################################################
# Bazel now uses Bzlmod by default to manage external dependencies.
# Please consider migrating your external dependencies from WORKSPACE to MODULE.bazel.
#
# For more details, please check https://github.com/bazelbuild/bazel/issues/18958
###############################################################################
450 changes: 0 additions & 450 deletions MODULE.bazel.lock

This file was deleted.

1 change: 1 addition & 0 deletions WORKSPACE
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
workspace(name="bazel_apogeum")
13 changes: 13 additions & 0 deletions tools/build_all/build_all.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/bash

if ! command -v bazel &> /dev/null; then
echo "Bazel is not installed"
exit 1
fi


if [[ "$1" == "--no_cache" ]]; then
bazel clean --async
fi

bazel build //...
25 changes: 25 additions & 0 deletions tools/cpplint/cpplint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/bin/bash

if ! command -v cpplint &> /dev/null; then
echo "cpplint is not installed, use apt-get install cpplint to fix this"
exit 1
fi

cpp_files=$(find . -type f \( -name "*.cc" -o -name "*.cpp" -o -name "*.h" -o -name "*.hpp" \) -not -path "./libdoip/*" -not -path "./tools/diag_app_frontend/*")

output=$(cpplint --filter=-build/include_subdir --extensions=cc,cpp,h,hpp --linelength=120 $cpp_files 2>&1)

# Zliczanie błędów z wyjścia
total_errors=$(echo "$output" | grep -o 'Total errors found: [0-9]*' | grep -o '[0-9]*')

# Sprawdzamy, czy wystąpiły błędy
if [[ -z "$total_errors" ]]; then
total_errors=0 # Ustaw na 0, jeśli nie znaleziono błędów
fi

if [[ $total_errors -gt 0 ]]; then
echo "Too many errors ($total_errors), failing the build."
exit 1
else
echo "Acceptable number of errors ($total_errors)."
fi
23 changes: 23 additions & 0 deletions tools/cpplint/user_cpplint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/bin/bash

if ! command -v cpplint &> /dev/null; then
echo "cpplint is not installed, use apt-get install cpplint to fix this"
exit 1
fi

cpp_files=$(find . -type f \( -name "*.cc" -o -name "*.cpp" -o -name "*.h" -o -name "*.hpp" \) -not -path "./libdoip/*" -not -path "./tools/diag_app_frontend/*")

total_errors=0
for file in $cpp_files; do
errors=$(cpplint --filter=-build/include_subdir --extensions=cc,cpp,h,hpp --linelength=120 --recursive --exclude=*/libdoip/* --repository=. --root=src $file | wc -l)
if [[ $errors -gt 1 ]]; then
total_errors=$((total_errors + errors - 1))
fi
done

if [[ $total_errors -gt 0 ]]; then
echo "Too many errors ($total_errors), failing the build."
exit 1
else
echo "Acceptable number of errors ($total_errors)."
fi
15 changes: 15 additions & 0 deletions tools/ut/unittest.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/bash

if ! command -v bazel &> /dev/null; then
echo "Bazel is not installed"
exit 1
fi


CACHE_FLAG=""

if [[ "$1" == "--no_cache" ]]; then
CACHE_FLAG="--nocache_test_results"
fi

bazel test $CACHE_FLAG --test_output=all `bazel query 'kind(cc_test, //...)'`
Loading