Compare commits
9 Commits
fix/remove
...
57cccd1cf2
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
57cccd1cf2 | ||
|
|
13bcb67fa5 | ||
|
|
2fae1da76f | ||
|
|
bf1882e528 | ||
|
|
94c1ad26d5 | ||
|
|
8712d22ff5 | ||
|
|
2df45c01ff | ||
|
|
105c1be3df | ||
|
|
716962af71 |
@@ -8,49 +8,85 @@ on:
|
||||
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-and-test:
|
||||
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: https://github.com/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
|
||||
push: false
|
||||
load: true
|
||||
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: https://github.com/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
|
||||
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"
|
||||
run: |
|
||||
docker run \
|
||||
--rm \
|
||||
--workdir /builder/mnt \
|
||||
-v ${{ gitea.workspace }}:/builder/mnt \
|
||||
cproject-builder:latest \
|
||||
/bin/bash -c "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"
|
||||
run: |
|
||||
docker run \
|
||||
--rm \
|
||||
--workdir /builder/mnt/tests/unittest \
|
||||
-v ${{ gitea.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}}"
|
||||
staging="reports-${{gitea.run_number}}"
|
||||
mkdir -p "$staging"
|
||||
cp -r tests/unittest/build/artifacts/gcov "$staging"
|
||||
echo "ASSET=$staging" >> $GITHUB_ENV
|
||||
tar czf "$staging.tar.gz" "$staging"
|
||||
echo "ASSET=$staging.tar.gz" >> $GITEA_ENV
|
||||
-
|
||||
name: Archive artifacts
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: reports-${{github.run_number}}
|
||||
name: reports-${{gitea.run_number}}
|
||||
path: ${{ env.ASSET }}
|
||||
retention-days: 3
|
||||
|
||||
# TODO: delete cache on merge.
|
||||
|
||||
@@ -23,16 +23,3 @@ 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
|
||||
)
|
||||
|
||||
BIN
assets/docker-sharing.png
Normal file
|
After Width: | Height: | Size: 61 KiB |
BIN
assets/gcovr-report.png
Normal file
|
After Width: | Height: | Size: 102 KiB |
BIN
assets/github-action.png
Normal file
|
After Width: | Height: | Size: 450 KiB |
BIN
assets/vscode-container.png
Normal file
|
After Width: | Height: | Size: 588 KiB |
BIN
assets/vscode-rebuild.png
Normal file
|
After Width: | Height: | Size: 498 KiB |
BIN
assets/vscode-reload.png
Normal file
|
After Width: | Height: | Size: 487 KiB |
BIN
assets/vscode-remote.png
Normal file
|
After Width: | Height: | Size: 463 KiB |
@@ -1,4 +1,6 @@
|
||||
|
||||
[](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 Gitea (ported from Guthub) 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 GitHub Actions.
|
||||