Skip to content
Open
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
24 changes: 24 additions & 0 deletions .github/actions/setup-docker-env/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Setup Docker Environment
description: Build dev image and create required host directories

runs:
using: composite
steps:
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Build development Image
uses: docker/build-push-action@v6
with:
context: "${{ github.workspace }}/docker/development"
push: false
tags: openbsw-development:local
outputs: type=docker
cache-from: type=gha
cache-to: type=gha,mode=max,ignore-error=true

- name: Create Bazel cache directories
shell: bash
run: |
mkdir -p "${BAZEL_CACHE_DIR:-${XDG_CACHE_HOME:-${HOME}/.cache}/bazel}"
mkdir -p "${BAZELISK_CACHE_DIR:-${XDG_CACHE_HOME:-${HOME}/.cache}/bazelisk}"
74 changes: 74 additions & 0 deletions .github/workflows/bazel.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
name: Bazel Build and Test

on:
workflow_call:
push:
branches:
- main
pull_request:

jobs:
bazel-ci:
runs-on: ubuntu-latest

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

- name: Setup Docker Environment
uses: ./.github/actions/setup-docker-env

# Fails if bazel --version fails in the docker container
- name: Bazel smoke test
run: >-
DOCKER_UID=$(id -u) DOCKER_GID=$(id -g) DOCKER_HISTORY=/dev/null
docker compose run --rm development
bazel version

# Fails if MODULE.bazel.lock is stale (invalid versions, yanked modules, extension errors).
# Fix locally with: bazel mod tidy --lockfile_mode=update
- name: Check Bazel lockfile
run: >-
DOCKER_UID=$(id -u) DOCKER_GID=$(id -g) DOCKER_HISTORY=/dev/null
docker compose run --rm development
bazel mod deps --lockfile_mode=error

# Fails if any BUILD/.bzl file is not formatted correctly.
# Fix locally with: bazel run //:format_fix
- name: Check Bazel formatting
run: >-
DOCKER_UID=$(id -u) DOCKER_GID=$(id -g) DOCKER_HISTORY=/dev/null
docker compose run --rm development
bazel run //:format_check

# Parses all BUILD files and resolves the dependency graph without compiling.
# Catches syntax errors, invalid labels, missing targets, and dependency cycles.
- name: Query all targets
run: >-
DOCKER_UID=$(id -u) DOCKER_GID=$(id -g) DOCKER_HISTORY=/dev/null
docker compose run --rm development
bazel query //...

# Compiles all targets for the host platform (Linux/posix).
# Targets with incompatible platform constraints are skipped automatically.
- name: Build all targets (host platform)
run: >-
DOCKER_UID=$(id -u) DOCKER_GID=$(id -g) DOCKER_HISTORY=/dev/null
docker compose run --rm development
bazel build //...

# Cross-compiles all targets for the example embedded platform using arm-none-eabi-gcc.
- name: Build all targets (s32k148 platform)
run: >-
DOCKER_UID=$(id -u) DOCKER_GID=$(id -g) DOCKER_HISTORY=/dev/null
docker compose run --rm development
bazel build --config=s32k148 //...

# Builds and runs all test targets. Exit code 4 ("no tests found") needs to be treated as
# success until at least a single test exists.
- name: Run all tests
run: >-
DOCKER_UID=$(id -u) DOCKER_GID=$(id -g) DOCKER_HISTORY=/dev/null
docker compose run --rm development
bazel test //... || exit_code=$?;
[ "${exit_code:-0}" -eq 0 ] || [ "${exit_code}" -eq 4 ] || exit "${exit_code}"
15 changes: 2 additions & 13 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -84,19 +84,8 @@ jobs:
- name: Checkout repository
uses: actions/checkout@v4

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Build development Image
id: build-docker-development
uses: docker/build-push-action@v6
with:
context: "{{defaultContext}}:docker/development"
push: false
tags: openbsw-development:local
outputs: type=docker
cache-from: type=gha
cache-to: type=gha,mode=max,ignore-error=true
- name: Setup Docker Environment
uses: ./.github/actions/setup-docker-env

- name: Run the build.py inside the docker container
run: >-
Expand Down
17 changes: 2 additions & 15 deletions .github/workflows/clang-tidy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,21 +52,8 @@ jobs:
--event-path "${GITHUB_EVENT_PATH}" --output-file .clang-tidy-diff-files.txt
--github-output "${GITHUB_OUTPUT}"

- name: Set up Docker Buildx
if: ${{ steps.scope.outputs.mode == 'full' || steps.scope.outputs.has_changes == 'true' }}
uses: docker/setup-buildx-action@v3

- name: Build development Image
if: ${{ steps.scope.outputs.mode == 'full' || steps.scope.outputs.has_changes == 'true' }}
id: build-docker-development
uses: docker/build-push-action@v6
with:
context: "{{defaultContext}}:docker/development"
push: false
tags: openbsw-development:local
outputs: type=docker
cache-from: type=gha
cache-to: type=gha,mode=max,ignore-error=true
- name: Setup Docker Environment
uses: ./.github/actions/setup-docker-env

- name: Run the ${{ matrix.platform }} ${{ matrix.config }} build inside the docker container
if: ${{ steps.scope.outputs.mode == 'full' || steps.scope.outputs.has_changes == 'true' }}
Expand Down
15 changes: 2 additions & 13 deletions .github/workflows/code-coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,8 @@ jobs:
- name: Checkout repository
uses: actions/checkout@v4

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Build development Image
id: build-docker-development
uses: docker/build-push-action@v6
with:
context: "{{defaultContext}}:docker/development"
push: false
tags: openbsw-development:local
outputs: type=docker
cache-from: type=gha
cache-to: type=gha,mode=max,ignore-error=true
- name: Setup Docker Environment
uses: ./.github/actions/setup-docker-env

- name: Run the code_coverage.py inside the docker container
run: >-
Expand Down
14 changes: 2 additions & 12 deletions .github/workflows/format.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,8 @@ jobs:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Build development Image
uses: docker/build-push-action@v6
with:
context: "{{defaultContext}}:docker/development"
push: false
tags: openbsw-development:local
outputs: type=docker
cache-from: type=gha
cache-to: type=gha,mode=max,ignore-error=true
- name: Setup Docker Environment
uses: ./.github/actions/setup-docker-env

- name: Run the format.py inside the docker container
run: DOCKER_UID=$(id -u) DOCKER_GID=$(id -g) DOCKER_HISTORY=/dev/null docker compose run --rm development python3 .ci/format.py
15 changes: 2 additions & 13 deletions .github/workflows/puncover_tool.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,8 @@ jobs:
- name: Checkout repository
uses: actions/checkout@v4

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Build development Image
id: build-docker-development
uses: docker/build-push-action@v6
with:
context: "{{defaultContext}}:docker/development"
push: false
tags: openbsw-development:local
outputs: type=docker
cache-from: type=gha
cache-to: type=gha,mode=max,ignore-error=true
- name: Setup Docker Environment
uses: ./.github/actions/setup-docker-env

- name: Cache CMake files
id: cache-cmake
Expand Down
14 changes: 2 additions & 12 deletions .github/workflows/rim.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,8 @@ jobs:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Build development Image
uses: docker/build-push-action@v6
with:
context: "{{defaultContext}}:docker/development"
push: false
tags: openbsw-development:local
outputs: type=docker
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Setup Docker Environment
uses: ./.github/actions/setup-docker-env

- name: Run the third party libraries check via RIM inside the docker container
run: DOCKER_UID=$(id -u) DOCKER_GID=$(id -g) DOCKER_HISTORY=/dev/null docker compose run --rm development rim status -w -d --verify-clean
14 changes: 2 additions & 12 deletions .github/workflows/run-pytest-on-posix.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,18 +29,8 @@ jobs:
- name: Checkout repository
uses: actions/checkout@v4

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Build development Image
uses: docker/build-push-action@v6
with:
context: "{{defaultContext}}:docker/development"
push: false
tags: openbsw-development:local
outputs: type=docker
cache-from: type=gha
cache-to: type=gha,mode=max,ignore-error=true
- name: Setup Docker Environment
uses: ./.github/actions/setup-docker-env

- name: Set up virtual ethernet interface
run: |
Expand Down
14 changes: 14 additions & 0 deletions .treefmt.toml
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,17 @@ includes = [ "*.c", "*.cc", "*.cpp", "*.h", "*.hh", "*.hpp" ]
command = "cmake-format"
options = [ "-i" ]
includes = [ "**/CMakeLists.txt", "*.cmake", "CMakeLists.txt" ]

[formatter.buildifier]
command = "buildifier"
options = ["-lint=fix"]
includes = [
"*.bzl",
"*.sky",
"BUILD",
"BUILD.bazel",
"MODULE.bazel",
"REPO.bazel",
"WORKSPACE",
"WORKSPACE.bazel",
]
18 changes: 18 additions & 0 deletions BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
load("@buildifier_prebuilt//:rules.bzl", "buildifier")

buildifier(
name = "format_check",
diff_command = "diff",
# Exclude vendored googletest instance from format checks
exclude_patterns = ["./libs/3rdparty/googletest/**"],
lint_mode = "warn",
mode = "diff",
)

buildifier(
name = "format_fix",
# Exclude vendored googletest instance from format checks
exclude_patterns = ["./libs/3rdparty/googletest/**"],
lint_mode = "fix",
mode = "fix",
)
2 changes: 2 additions & 0 deletions MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ bazel_dep(name = "platforms", version = "1.0.0")
bazel_dep(name = "rules_cc", version = "0.2.17")
bazel_dep(name = "bazel_skylib", version = "1.9.0")

bazel_dep(name = "buildifier_prebuilt", version = "8.5.1.1", dev_dependency = True)

register_toolchains(
"//bazel/toolchain:cc_toolchain_arm_none_eabi_gcc",
)
Loading
Loading