Compare commits

...

8 Commits

Author SHA1 Message Date
b0a2528514 Merge pull request 'test: Add ctest code coverage' (#5) from test/coverage into main
All checks were successful
ci / docker-build-and-test (push) Successful in 4m58s
Reviewed-on: #5
2024-03-04 01:01:07 -08:00
Brock Allen
54978e7e31 test: Add ctest code coverage
All checks were successful
ci / docker-build-and-test (pull_request) Successful in 3m9s
2024-03-04 08:55:50 +00:00
Brock Allen
9f9122a402 ops: Fix CICD docker usage
All checks were successful
ci / docker-build-and-test (push) Successful in 3m11s
2024-03-04 07:45:21 +00:00
Brock Allen
47f7e5a4cc Revert "ops: load docker image from tarball"
Some checks failed
ci / docker-build (push) Successful in 32s
ci / build-and-test (push) Failing after 33s
This reverts commit 0bc03b3ed3.
2024-02-03 01:41:09 +00:00
Brock Allen
0bc03b3ed3 ops: load docker image from tarball
Some checks failed
ci / docker-build (push) Successful in 32s
ci / build-and-test (push) Failing after 31s
2024-02-03 00:53:17 +00:00
Brock Allen
b6f7fcbd24 test: Enable ctest to run ceedling unit tests
Some checks failed
ci / docker-build (pull_request) Successful in 8m7s
ci / build-and-test (pull_request) Successful in 8m53s
ci / docker-build (push) Successful in 32s
ci / build-and-test (push) Failing after 33s
2024-01-28 22:40:49 +00:00
Brock Allen
c826a4ecd8 chore: Update README
All checks were successful
ci / docker-build (push) Successful in 7m40s
ci / build-and-test (push) Successful in 10m38s
2024-01-28 07:50:12 +00:00
dce7d3492d ops: Add gitea actions CI (#1)
All checks were successful
ci / docker-build (push) Successful in 8m10s
ci / build-and-test (push) Successful in 9m44s
Co-authored-by: Brock Allen <brock.d.allen@gmail.com>
Reviewed-on: #1
2024-01-27 23:18:47 -08:00
15 changed files with 89 additions and 123 deletions

View File

@@ -7,8 +7,7 @@
},
"workspaceMount": "",
"runArgs": [
"--volume=${localWorkspaceFolder}:/workspaces/${localWorkspaceFolderBasename}:Z",
"--platform=linux/amd64"
"--volume=${localWorkspaceFolder}:/workspaces/${localWorkspaceFolderBasename}:Z"
],
"customizations": {
"vscode": {

57
.gitea/workflows/ci.yml Normal file
View File

@@ -0,0 +1,57 @@
name: ci
on:
pull_request:
push:
branches:
- main
schedule:
- cron: '0 1 * * 0'
jobs:
docker-build-and-test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: docker/setup-buildx-action@v2
-
name: Build docker builder-image
uses: docker/build-push-action@v4
with:
context: .
file: builder.Dockerfile
tags: cproject-builder:latest
push: false
load: true
-
name: Build library
uses: https://github.com/addnab/docker-run-action@v3
with:
image: cproject-builder:latest
options: --volumes-from ${{ env.JOB_CONTAINER_NAME }}
run: |
/bin/bash -c "cd ${{ github.workspace }}; rm -rf build; cmake -B build; cmake --build build"
-
name: Test library
uses: https://github.com/addnab/docker-run-action@v3
with:
image: cproject-builder:latest
options: --volumes-from ${{ env.JOB_CONTAINER_NAME }}
run: |
/bin/bash -c "cd ${{ github.workspace }}/tests/unittest; ceedling clobber; ceedling gcov:all; ceedling utils:gcov"
-
name: Archive coverage results
shell: bash
run: |
staging="reports-${{github.run_number}}"
mkdir -p "$staging"
cp -r tests/unittest/build/artifacts/gcov "$staging"
tar czf "$staging.tar.gz" "$staging"
echo "ASSET=$staging.tar.gz" >> $GITHUB_ENV
-
name: Archive artifacts
uses: actions/upload-artifact@v3
with:
name: reports-${{github.run_number}}
path: ${{ env.ASSET }}
retention-days: 3

View File

@@ -1,94 +0,0 @@
name: ci
on:
pull_request:
push:
branches:
- main
schedule:
- cron: '0 1 * * 0'
# https://docs.docker.com/build/ci/github-actions/share-image-jobs/
# just using caches instead of artifact upload.
jobs:
docker-build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: docker/setup-buildx-action@v2
-
name: Create docker cache folder
run: mkdir -p /tmp/docker
-
name: Restore docker image
id: cache-docker
uses: actions/cache@v3
with:
path: /tmp/docker
key: ${{ runner.os }}-docker-${{ hashFiles('builder.Dockerfile') }}
-
name: Build docker builder-image
if: steps.cache-docker.outputs.cache-hit != 'true'
uses: docker/build-push-action@v4
with:
context: .
file: builder.Dockerfile
tags: cproject-builder:latest
outputs: type=docker,dest=/tmp/docker/${{ runner.os }}-builder-image.tar
build-and-test:
runs-on: ubuntu-latest
needs: docker-build
steps:
- uses: actions/checkout@v3
- uses: docker/setup-buildx-action@v2
-
name: Restore docker image
id: cache-docker
uses: actions/cache@v3
with:
path: /tmp/docker
key: ${{ runner.os }}-docker-${{ hashFiles('builder.Dockerfile') }}
-
name: Load image
run: |
docker load --input /tmp/docker/${{ runner.os }}-builder-image.tar
docker image ls -a
-
name: Build library
run: |
docker run \
--rm \
--platform linux/amd64 \
--workdir /builder/mnt \
-v ${{ github.workspace }}:/builder/mnt \
cproject-builder:latest \
/bin/bash -c "rm -rf build; cmake -B build; cmake --build build"
-
name: Test library
run: |
docker run \
--rm \
--platform linux/amd64 \
--workdir /builder/mnt/tests/unittest \
-v ${{ github.workspace }}:/builder/mnt \
cproject-builder:latest \
/bin/bash -c "ceedling clobber; ceedling gcov:all; ceedling utils:gcov"
-
name: Archive coverage results
shell: bash
run: |
staging="reports-${{github.run_number}}"
mkdir -p "$staging"
cp -r tests/unittest/build/artifacts/gcov "$staging"
tar czf "$staging.tar.gz" "$staging"
echo "ASSET=$staging.tar.gz" >> $GITHUB_ENV
-
name: Archive artifacts
uses: actions/upload-artifact@v3
with:
name: reports-${{github.run_number}}
path: ${{ env.ASSET }}
retention-days: 3
# TODO: delete cache on merge.

View File

@@ -23,3 +23,16 @@ target_include_directories(
PUBLIC
include
)
enable_testing()
add_test(
NAME coverage
COMMAND bash -c "ceedling clobber; ceedling gcov:all; ceedling utils:gcov"
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/tests/unittest
)
add_test(
NAME ceedling
COMMAND bash -c "ceedling clobber; ceedling test:all"
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/tests/unittest
)

View File

@@ -7,7 +7,6 @@ builder-run :
docker run \
--rm \
-it \
--platform linux/amd64 \
--workdir /builder/mnt \
-v .:/builder/mnt \
$(project_name)-builder:latest \

View File

@@ -1,6 +1,4 @@
[![Build status](https://github.com/lmapii/cproject/workflows/ci/badge.svg)](https://github.com/lmapii/cproject/actions)
# Example repository for a C development environment
This is the example repository for a [post on the Interrupt blog](https://interrupt.memfault.com/blog/a-modern-c-dev-env). It is a demo development environment using Docker, CMake, Unity, and GitHub Actions.
This is the example repository for a [post on the Interrupt blog](https://interrupt.memfault.com/blog/a-modern-c-dev-env). It is a demo development environment using Docker, CMake, Unity, and Gitea (ported from Guthub) Actions.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 61 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 102 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 450 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 588 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 498 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 487 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 463 KiB

View File

@@ -2,7 +2,7 @@ ARG base_tag=bullseye
ARG base_img=mcr.microsoft.com/vscode/devcontainers/base:dev-${base_tag}
# ARG base_img=debian:${base_tag}
FROM --platform=linux/amd64 ${base_img} AS builder-install
FROM ${base_img} AS builder-install
# the following shows how to install the latest version of a package.
# you can determine the installed version with `apt-cache policy <list of packages>` and fix
@@ -15,7 +15,6 @@ RUN apt-get install -y --no-install-recommends \
cmake \
build-essential \
gcc \
g++-multilib \
locales \
make \
ruby \
@@ -61,29 +60,28 @@ RUN ln -s /usr/bin/clang-tidy-${llvm_version} /usr/local/bin/clang-tidy
# this can take a significant amount of time (e.g., several minutes just to compile one tool),
# and also increases the image size significantly. therefore, we go for option B below.
# RUN curl https://sh.rustup.rs -sSf | sh -s -- --default-toolchain stable -y
# ENV PATH=/root/.cargo/bin:$PATH
RUN curl https://sh.rustup.rs -sSf | sh -s -- --default-toolchain stable -y
ENV PATH=/root/.cargo/bin:$PATH
# Each takes around 280 s to build on an M2 macbook air
# RUN cargo install run-clang-format
# RUN cargo install run-clang-tidy
RUN cargo install run-clang-format
RUN cargo install run-clang-tidy
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# option B: install pre-built clang wrappers
# RUN mkdir -p /usr/local/run-clang-format
# RUN wget -O clang-utils.tgz "https://github.com/lmapii/run-clang-format/releases/download/v1.4.14/run-clang-format-v1.4.14-i686-unknown-linux-gnu.tar.gz" && \
# tar -C /usr/local/run-clang-format -xzf clang-utils.tgz --strip-components 1 && \
# rm clang-utils.tgz
# ENV PATH /usr/local/run-clang-format:$PATH
# RUN run-clang-format --version
RUN mkdir -p /usr/local/run-clang-format
RUN wget -O clang-utils.tgz "https://github.com/lmapii/run-clang-format/releases/download/v1.4.14/run-clang-format-v1.4.14-i686-unknown-linux-gnu.tar.gz" && \
tar -C /usr/local/run-clang-format -xzf clang-utils.tgz --strip-components 1 && \
rm clang-utils.tgz
ENV PATH /usr/local/run-clang-format:$PATH
RUN run-clang-format --version
RUN mkdir -p /usr/local/run-clang-tidy
RUN wget -O clang-utils.tgz "https://github.com/lmapii/run-clang-tidy/releases/download/v0.2.5/run-clang-tidy-v0.2.5-i686-unknown-linux-gnu.tar.gz" && \
tar -C /usr/local/run-clang-tidy -xzf clang-utils.tgz --strip-components 1 && \
rm clang-utils.tgz
ENV PATH /usr/local/run-clang-tidy:$PATH
RUN run-clang-tidy --version
# RUN mkdir -p /usr/local/run-clang-tidy
# RUN wget -O clang-utils.tgz "https://github.com/lmapii/run-clang-tidy/releases/download/v0.2.5/run-clang-tidy-v0.2.5-i686-unknown-linux-gnu.tar.gz" && \
# tar -C /usr/local/run-clang-tidy -xzf clang-utils.tgz --strip-components 1 && \
# rm clang-utils.tgz
# ENV PATH /usr/local/run-clang-tidy:$PATH
# RUN run-clang-tidy --version
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# install unity and ceedling

View File

@@ -102,24 +102,20 @@
- -Wall
- -g0
- -O3
- -m32
:link:
:*:
- -g0
- -O3
- -m32
:gcov:
:compile:
:*:
- -g0
- -O3
- -Wall
- -m32
:link:
:*:
- -g0
- -O3
- -m32
# LIBRARIES