Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use docker base image in CI #327

Merged
merged 14 commits into from
Nov 20, 2024
6 changes: 6 additions & 0 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,12 @@ jobs:
steps:
- uses: actions/checkout@v4

- uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

# build base (if inputs.build-base)
- uses: docker/metadata-action@v5
id: base-meta
Expand Down
13 changes: 6 additions & 7 deletions .github/workflows/linter.yml
Original file line number Diff line number Diff line change
@@ -1,26 +1,25 @@
name: cpp-linter

on: pull_request
on:
pull_request:
workflow_dispatch:

jobs:
cpp-linter:
if: github.repository_owner == 'viamrobotics'
runs-on: ubuntu-latest
container:
image: ghcr.io/viamrobotics/canon:amd64
container: ghcr.io/viamrobotics/cpp-base:bullseye-amd64
steps:
- name: Checkout Code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: install clang-format
run: sudo apt install -y clang-format
- name: verify no uncommitted changes
run: |
chown $(whoami) .
git init
git add .
chown -R testbot .
sudo -u testbot bash -lc 'sh ./bin/run-clang-format.sh'
./bin/run-clang-format.sh
GEN_DIFF=$(git status -s)

if [ -n "$GEN_DIFF" ]; then
Expand Down
40 changes: 22 additions & 18 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,34 +3,38 @@ name: Test
on:
pull_request:
workflow_dispatch:
inputs:
no-tidy:
type: boolean
description: set to true to build without clang-tidy (2x faster)

jobs:
run-tests:
if: github.repository_owner == 'viamrobotics'
runs-on: ubuntu-latest
container:
image: ghcr.io/viamrobotics/canon:amd64
container: ghcr.io/viamrobotics/cpp-base:bullseye-amd64
strategy:
matrix:
include:
- BUILD_SHARED: ON
- BUILD_SHARED: OFF
steps:
- uses: actions/checkout@v4
###########################################
# necessary installs for building #
###########################################
- name: build-docker-test
- name: cmake
run: |
docker build -t cpp . -f etc/docker/base-images/Dockerfile.debian.bullseye
docker build -t cpp-test . -f etc/docker/Dockerfile.sdk-build \
--build-arg BASE_TAG=cpp \
--build-arg REPO_SETUP=copy \
--build-arg BUILD_SHARED=${{ matrix.BUILD_SHARED }} \
--build-arg BUILD_TESTS=ON \
--build-arg BUILD_EXAMPLES=ON \
--build-arg "EXTRA_CMAKE_ARGS=\
-DVIAMCPPSDK_CLANG_TIDY=ON \
-DVIAMCPPSDK_SANITIZED_BUILD=${{ matrix.BUILD_SHARED }}"

docker run -w /viam-cpp-sdk/build -t --entrypoint /viam-cpp-sdk/etc/docker/tests/run_test.sh cpp-test /bin/bash
mkdir build
cd build
cmake .. -G Ninja \
-DBUILD_SHARED_LIBS=${{ matrix.BUILD_SHARED }} \
-DVIAMCPPSDK_OFFLINE_PROTO_GENERATION=ON \
-DVIAMCPPSDK_BUILD_TESTS=ON \
-DVIAMCPPSDK_BUILD_EXAMPLES=ON \
-DVIAMCPPSDK_CLANG_TIDY=${{ inputs.no-tidy && 'OFF' || 'ON' }} \
-DVIAMCPPSDK_SANITIZED_BUILD=${{ matrix.BUILD_SHARED }}
- name: build
run: |
cmake --build build --target install
cmake --install build
- name: test
working-directory: build
run: ../etc/docker/tests/run_test.sh
3 changes: 2 additions & 1 deletion etc/docker/base-images/Dockerfile.debian.bookworm
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,5 @@ RUN apt-get update

RUN apt-get -y --no-install-recommends install -t llvm-toolchain-bookworm-15 \
clang-15 \
clang-tidy-15
clang-tidy-15 \
clang-format
5 changes: 3 additions & 2 deletions etc/docker/base-images/Dockerfile.debian.bullseye
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
FROM debian:bullseye

ENV HOME /root
ENV HOME=/root
ARG DEBIAN_FRONTEND=noninteractive

RUN apt-get update
Expand Down Expand Up @@ -39,7 +39,8 @@ RUN apt-get update

RUN apt-get -y --no-install-recommends install -t llvm-toolchain-bullseye-15 \
clang-15 \
clang-tidy-15
clang-tidy-15 \
clang-format

RUN apt-get -y --no-install-recommends install -t bullseye-backports \
cmake
3 changes: 2 additions & 1 deletion etc/docker/base-images/Dockerfile.debian.sid
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,5 @@ RUN apt-get update

RUN apt-get -y --no-install-recommends install -t llvm-toolchain-15 \
clang-15 \
clang-tidy-15
clang-tidy-15 \
clang-format
3 changes: 2 additions & 1 deletion etc/docker/base-images/Dockerfile.ubuntu.focal
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ RUN apt-get update

RUN apt-get -y --no-install-recommends install -t llvm-toolchain-focal-15 \
clang-15 \
clang-tidy-15
clang-tidy-15 \
clang-format

RUN apt-get -y install cmake

Expand Down
3 changes: 2 additions & 1 deletion etc/docker/base-images/Dockerfile.ubuntu.jammy
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ RUN apt-get update

RUN apt-get -y --no-install-recommends install -t llvm-toolchain-jammy-15 \
clang-15 \
clang-tidy-15
clang-tidy-15 \
clang-format

RUN apt-get -y install cmake