Skip to content

feat: NotePing() allows for testing to see if a notecard is respondin… #1116

feat: NotePing() allows for testing to see if a notecard is respondin…

feat: NotePing() allows for testing to see if a notecard is respondin… #1116

Workflow file for this run

name: note-c CI Pipeline
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
workflow_dispatch:
inputs:
force_build:
description: 'Force rebuild and publish Docker image (even if Dockerfile unchanged)'
required: false
type: boolean
default: false
jobs:
check_dockerfile_changed:
runs-on: ubuntu-latest
outputs:
changed: ${{ steps.filter.outputs.changed }}
steps:
- name: Checkout code
uses: actions/checkout@v4
# TODO: This is a 3rd party GitHub action from some dude. Ideally, we'd
# use something more "official".
- name: Check if Dockerfile changed
uses: dorny/paths-filter@v2
id: filter
with:
base: 'master'
filters: |
changed:
- '.devcontainer/ci/Dockerfile'
build_ci_docker_image:
runs-on: ubuntu-latest
needs: [check_dockerfile_changed]
if: ${{ needs.check_dockerfile_changed.outputs.changed == 'true' || inputs.force_build == true }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Rebuild image
uses: docker/build-push-action@v4
with:
context: .
file: .devcontainer/ci/Dockerfile
load: true
tags: ghcr.io/blues/note_c_ci:latest
outputs: type=docker,dest=/tmp/note_c_ci_image.tar
- name: Upload image artifact
uses: actions/upload-artifact@v4
with:
name: note_c_ci_image
path: /tmp/note_c_ci_image.tar
check_architecture_docs:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Check embedded architecture graph data
run: |
node docs/architecture/embed-architecture-json.mjs
git diff --exit-code docs/architecture/architecture.html
build_docs:
runs-on: ubuntu-latest
if: ${{ always() }}
needs: [build_ci_docker_image]
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Load CI Docker image
# Only load the Docker image artifact if build_ci_docker_image actually
# ran (e.g. it wasn't skipped and was successful).
if: ${{ needs.build_ci_docker_image.result == 'success' }}
uses: ./.github/actions/load-ci-image
- name: Build docs
run: |
docker run --rm --volume $(pwd):/note-c/ --workdir /note-c/ --entrypoint ./scripts/build_docs.sh ghcr.io/blues/note_c_ci:latest
check_libc_dependencies:
runs-on: ubuntu-latest
if: ${{ always() }}
needs: [build_ci_docker_image]
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Load CI Docker image
# Only load the Docker image artifact if build_ci_docker_image actually
# ran (e.g. it wasn't skipped and was successful).
if: ${{ needs.build_ci_docker_image.result == 'success' }}
uses: ./.github/actions/load-ci-image
- name: Check note-c's libc dependencies
run: |
docker run --rm --volume $(pwd):/note-c/ --workdir /note-c/ --entrypoint ./scripts/check_libc_dependencies.sh ghcr.io/blues/note_c_ci:latest
run_integration_tests:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Configure add_subdirectory integration test
run: cmake -S test/integration -B build-integration
- name: Build add_subdirectory integration test
run: cmake --build build-integration --parallel $(nproc)
- name: Run add_subdirectory integration test
run: ctest --test-dir build-integration --output-on-failure
run_unit_tests:
runs-on: ubuntu-latest
if: ${{ always() }}
needs: [build_ci_docker_image]
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Load CI Docker image
# Only load the Docker image artifact if build_ci_docker_image actually
# ran (e.g. it wasn't skipped and was successful).
if: ${{ needs.build_ci_docker_image.result == 'success' }}
uses: ./.github/actions/load-ci-image
- name: Run tests
run: |
docker run --rm --volume $(pwd):/note-c/ \
--workdir /note-c/ \
--entrypoint ./scripts/run_unit_tests.sh \
--user root \
ghcr.io/blues/note_c_ci:latest --coverage --mem-check
- name: Adjust lcov source file paths for Coveralls
run: sudo sed -i 's/\/note-c\///g' ./build/test/coverage/lcov.info
- name: Publish test coverage
uses: coverallsapp/github-action@master
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
path-to-lcov: ./build/test/coverage/lcov.info
run_low_mem_unit_tests:
runs-on: ubuntu-latest
if: ${{ always() }}
needs: [build_ci_docker_image]
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Load CI Docker image
# Only load the Docker image artifact if build_ci_docker_image actually
# ran (e.g. it wasn't skipped and was successful).
if: ${{ needs.build_ci_docker_image.result == 'success' }}
uses: ./.github/actions/load-ci-image
- name: Run tests with NOTE_LOWMEM defined
run: |
docker run --rm --volume $(pwd):/note-c/ --workdir /note-c/ --entrypoint ./scripts/run_unit_tests.sh ghcr.io/blues/note_c_ci:latest --mem-check --low-mem --single-precision
run_astyle:
runs-on: ubuntu-latest
if: ${{ always() }}
needs: [build_ci_docker_image]
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Load CI Docker image
# Only load the Docker image artifact if build_ci_docker_image actually
# ran (e.g. it wasn't skipped and was successful).
if: ${{ needs.build_ci_docker_image.result == 'success' }}
uses: ./.github/actions/load-ci-image
- name: Run astyle
run: |
docker run --rm --volume $(pwd):/note-c/ --workdir /note-c/ --entrypoint ./scripts/run_astyle.sh ghcr.io/blues/note_c_ci:latest
run_cppcheck:
runs-on: ubuntu-latest
if: ${{ always() }}
needs: [build_ci_docker_image]
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Load CI Docker image
# Only load the Docker image artifact if build_ci_docker_image actually
# ran (e.g. it wasn't skipped and was successful).
if: ${{ needs.build_ci_docker_image.result == 'success' }}
uses: ./.github/actions/load-ci-image
- name: Run cppcheck
run: |
docker run --rm --volume $(pwd):/note-c/ --workdir /note-c/ --entrypoint ./scripts/run_cppcheck.sh ghcr.io/blues/note_c_ci:latest
run_macos_unit_tests:
runs-on: macos-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Configure
run: cmake -B build -DNOTE_C_BUILD_TESTS=ON
- name: Build
run: cmake --build build --parallel $(sysctl -n hw.ncpu)
# NOTE: ctest is not run here. A subset of tests that rely on FFF
# symbol interposition fail on macOS due to two-level namespace
# linking. The build step above verifies that all sources and tests
# compile and link successfully.
#
# Even with -Wl,-flat_namespace, intra-library calls within the
# note_c dylib are resolved at link time as direct calls, so FFF
# fakes in the test executable cannot interpose them. Fully fixing
# this would require linking note-c as a static library for tests
# or using a different mocking approach on macOS.
publish_ci_image:
runs-on: ubuntu-latest
# Make sure unit tests unit tests passed before publishing.
needs: [build_ci_docker_image, run_unit_tests]
# Only publish the image if this is a push event (or manual trigger with force_build) and the Docker image was rebuilt
if: ${{ (github.event_name == 'push' || (github.event_name == 'workflow_dispatch' && inputs.force_build == true)) && needs.build_ci_docker_image.result == 'success' }}
steps:
- name: Download image artifact
uses: actions/download-artifact@v4
with:
name: note_c_ci_image
path: /tmp
- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Load and push image
run: |
docker load --input /tmp/note_c_ci_image.tar
docker push ghcr.io/blues/note_c_ci:latest