Skip to content

Commit

Permalink
ci: Build all examples as standalone
Browse files Browse the repository at this point in the history
This ensures the examples can be built independently as described in the
readme file.
  • Loading branch information
rettichschnidi committed Jan 30, 2022
1 parent ca5e599 commit 561422f
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 4 deletions.
36 changes: 34 additions & 2 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
name: C Standards
name: Compilation only checks

on: [push, pull_request]

jobs:
build:
standards:
runs-on: ubuntu-20.04

strategy:
Expand Down Expand Up @@ -38,3 +38,35 @@ jobs:
--c-extensions ${{ matrix.c_extensions }}
env:
CC: ${{ matrix.compiler }}

standalone-examples:
runs-on: ubuntu-20.04

strategy:
matrix:
example: ["bootstrap_server", "client", "lightclient", "server"]

steps:
- name: Checkout code including full history and submodules
uses: actions/checkout@v2
with:
submodules: true
fetch-depth: 0

- name: Install dependencies from APT repository
run: |
sudo apt-get update
sudo apt-get install libcunit1-dev wget unzip
- name: Install CMake
uses: lukka/get-cmake@latest

- name: Install Ninja
uses: seanmiddleditch/gha-setup-ninja@master

- Build examples as stand-alone projects
run: |
tools/ci/run_ci.sh \
--run-clean \
--run-build \
--source-directory examples/${{ matrix.example }}
12 changes: 10 additions & 2 deletions tools/ci/run_ci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ OPT_CLANG_FORMAT="clang-format-10"
OPT_SANITIZER=""
OPT_SCAN_BUILD=""
OPT_SONARQUBE=""
OPT_SOURCE_DIRECTORY="${REPO_ROOT_DIR}"
OPT_TEST_COVERAGE_REPORT=""
OPT_VERBOSE=0
OPT_WRAPPER_CMD=""
Expand All @@ -54,6 +55,8 @@ Options:
(VERSION: 99, 11)
--clang-format BINARY Set specific clang-format binary
(BINARY: defaults to ${OPT_CLANG_FORMAT})
--source-directory PATH Configure CMake using PATH instead of the
repositories root directory.
--sanitizer TYPE Enable sanitizer
(TYPE: address leak thread undefined)
--scan-build BINARY Enable Clang code analyzer using specified
Expand All @@ -73,7 +76,7 @@ Available steps (executed by --all):
--run-git-blame-ignore Validate .git-blame-ignore-revs
--run-clean Remove all build artifacts
--run-build Build all targets
--run-tests Build and execute tests
--run-tests Execute tests (works only for top level project)
"

function usage() {
Expand Down Expand Up @@ -127,7 +130,7 @@ function run_build() {
# Existing directory needed by SonarQube build-wrapper
mkdir -p build-wakaama

${OPT_WRAPPER_CMD} cmake -GNinja -S . -B build-wakaama ${CMAKE_ARGS}
${OPT_WRAPPER_CMD} cmake -GNinja -S ${OPT_SOURCE_DIRECTORY} -B build-wakaama ${CMAKE_ARGS}
${OPT_WRAPPER_CMD} cmake --build build-wakaama
}

Expand Down Expand Up @@ -201,6 +204,7 @@ if ! PARSED_OPTS=$(getopt -o vah \
-l sanitizer: \
-l scan-build: \
-l sonarqube: \
-l source-directory: \
-l test-coverage: \
-l verbose \
--name "${SCRIPT_NAME}" -- "$@");
Expand Down Expand Up @@ -272,6 +276,10 @@ while true; do
RUN_CLEAN=1
shift 2
;;
--source-directory)
OPT_SOURCE_DIRECTORY=$2
shift 2
;;
--test-coverage)
OPT_TEST_COVERAGE_REPORT=$2
shift 2
Expand Down

0 comments on commit 561422f

Please sign in to comment.