Skip to content

Commit

Permalink
GitHub Actions: stop on first failure and cat ctest log
Browse files Browse the repository at this point in the history
  • Loading branch information
mattrm456 authored Dec 14, 2023
1 parent f73e830 commit f4ea959
Show file tree
Hide file tree
Showing 12 changed files with 295 additions and 64 deletions.
16 changes: 8 additions & 8 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,43 +14,43 @@ concurrency:

jobs:
build-check:
name: "Check whether NTF builds and passes unit tests"
name: "Linux"
runs-on: ubuntu-latest
timeout-minutes: 60
steps:
- uses: actions/checkout@v3

- name: Get cache name
- name: Cache-Identify
id: get-hash
run: echo "ntf_deps_hash=`cat .github/workflows/docker/build_deps.sh .github/workflows/docker/build_test_ntf.sh .github/workflows/docker/Dockerfile | shasum`" >> $GITHUB_OUTPUT

- name: Get cached dependencies docker image
- name: Cache-Lookup
id: cache-restore
uses: actions/cache/restore@v3
with:
path: ntf_deps_image.tar.gz
key: ${{ steps.get-hash.outputs.ntf_deps_hash }}

- name: Build dependencies docker image
- name: Cache-Build
if: steps.cache-restore.outputs.cache-hit != 'true'
run: docker build --tag ntf-deps --platform linux/amd64 .github/workflows/docker

- name: Load dependencies docker image from cache
- name: Cache-Restore
if: steps.cache-restore.outputs.cache-hit == 'true'
run: docker load < ntf_deps_image.tar.gz

- name: Save built dependencies docker image
- name: Cache-Save
if: steps.cache-restore.outputs.cache-hit != 'true'
run: docker save ntf-deps:latest | gzip > ntf_deps_image.tar.gz

- name: Cache built dependencies docker image
- name: Cache-Commit
id: cache-save
if: steps.cache-restore.outputs.cache-hit != 'true'
uses: actions/cache/save@v3
with:
path: ntf_deps_image.tar.gz
key: ${{ steps.get-hash.outputs.ntf_deps_hash }}

- name: Run dependencies docker container
- name: Build
id: ntf-deps-run
run: docker run -v $(pwd):/workspace/ntf-core --name ntf-deps ntf-deps /bin/bash -c "/workspace/ntf-core/.github/workflows/docker/build_test_ntf.sh"
92 changes: 74 additions & 18 deletions .github/workflows/docker/build_test_ntf.sh
Original file line number Diff line number Diff line change
@@ -1,28 +1,84 @@
#!/bin/bash
#!/usr/bin/env bash

set -e
# configure() {
# cd /workspace
# PATH="$PATH:$(realpath srcs/bde-tools/bin)"
# export PATH
# eval "$(bbs_build_env -u opt_64_cpp17)"
# }

configure() {
cd /workspace
PATH="$PATH:$(realpath srcs/bde-tools/bin)"
export PATH
eval "$(bbs_build_env -u opt_64_cpp17)"
}
build_ntf() {
local rc=0

build_ntf() {
cd /workspace/ntf-core
sed -i s/CMakeLists.txt//g ./configure
./configure --prefix /opt/bb
make -j8
make test | tee test.log

if cat test.log | grep -q "Errors while running CTest"; then
echo "There are errors while running UTs, exiting..."
exit 1
rc=${?}
if [ ${rc} -ne 0 ]; then
echo "Failed to change directory: rc = ${rc}"
exit ${rc}
fi

local jobs=$(getconf _NPROCESSORS_ONLN)

echo "Cores: ${concurrency}"
free -h

echo "Environment"
env

echo "File: /etc/hosts"
cat /etc/hosts

echo "File: /etc/services"
cat /etc/services

echo "File: /etc/resolv.conf"
cat /etc/resolv.conf

unset DISTRIBUTION_REFROOT
unset PREFIX

./configure --prefix /opt/bb \
--output /workspace/ntf-core/build \
--jobs ${jobs} \
--standalone \
--without-warnings \
--without-warnings-as-errors \
--from-continuous-integration
rc=${?}
if [ ${rc} -ne 0 ]; then
echo "Failed to configure: rc = ${rc}"
exit ${rc}
fi

make build
rc=${?}
if [ ${rc} -ne 0 ]; then
echo "Failed to build: rc = ${rc}"
exit ${rc}
fi

make build_test
rc=${?}
if [ ${rc} -ne 0 ]; then
echo "Failed to build tests: rc = ${rc}"
exit ${rc}
fi

make test
rc=${?}
if [ ${rc} -ne 0 ]; then
cat /workspace/ntf-core/build/Testing/Temporary/LastTest.log
echo "Failed to run tests successfully: rc = ${rc}"
exit ${rc}
fi

make install
rc=${?}
if [ ${rc} -ne 0 ]; then
echo "Failed to install: rc = ${rc}"
exit ${rc}
fi
}

configure
# configure
build_ntf
15 changes: 7 additions & 8 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -732,7 +732,6 @@ while true ; do

--from-continuous-integration)
NTF_CONFIGURE_FROM_CONTINUOUS_INTEGRATION=1
NTF_CONFIGURE_VERBOSE=1
shift ;;
--from-packaging)
NTF_CONFIGURE_FROM_PACKAGING=1 ; shift ;;
Expand Down Expand Up @@ -948,7 +947,7 @@ cd ${NTF_CONFIGURE_OUTPUT}

echo "${NTF_CONFIGURE_CMAKE}${NTF_CONFIGURE_CMAKE_OPTION_DISTRIBUTION_REFROOT}${NTF_CONFIGURE_CMAKE_OPTION_UFID}${NTF_CONFIGURE_CMAKE_OPTION_BUILD_TYPE}${NTF_CONFIGURE_CMAKE_OPTION_INSTALL_PREFIX}${NTF_CONFIGURE_CMAKE_OPTION_PREFIX_PATH}${NTF_CONFIGURE_CMAKE_OPTION_VERBOSE_MAKEFILE} -DCMAKE_TOOLCHAIN_FILE:PATH=${NTF_CONFIGURE_REPOSITORY}/toolchain.cmake -G \"${NTF_CONFIGURE_GENERATOR}\" -S ${NTF_CONFIGURE_REPOSITORY}"

${NTF_CONFIGURE_CMAKE}${NTF_CONFIGURE_CMAKE_OPTION_DISTRIBUTION_REFROOT}${NTF_CONFIGURE_CMAKE_OPTION_UFID}${NTF_CONFIGURE_CMAKE_OPTION_BUILD_TYPE}${NTF_CONFIGURE_CMAKE_OPTION_INSTALL_PREFIX}${NTF_CONFIGURE_CMAKE_OPTION_PREFIX_PATH}${NTF_CONFIGURE_CMAKE_OPTION_VERBOSE_MAKEFILE} -DCMAKE_TOOLCHAIN_FILE:PATH=${NTF_CONFIGURE_REPOSITORY}/toolchain.cmake -G "${NTF_CONFIGURE_GENERATOR}" -S ${NTF_CONFIGURE_REPOSITORY} 2>&1 | tee -a ${NTF_CONFIGURE_LOG_PREFIX}configure.log
${NTF_CONFIGURE_CMAKE}${NTF_CONFIGURE_CMAKE_OPTION_DISTRIBUTION_REFROOT}${NTF_CONFIGURE_CMAKE_OPTION_UFID}${NTF_CONFIGURE_CMAKE_OPTION_BUILD_TYPE}${NTF_CONFIGURE_CMAKE_OPTION_INSTALL_PREFIX}${NTF_CONFIGURE_CMAKE_OPTION_PREFIX_PATH}${NTF_CONFIGURE_CMAKE_OPTION_VERBOSE_MAKEFILE} -DCMAKE_TOOLCHAIN_FILE:PATH=${NTF_CONFIGURE_REPOSITORY}/toolchain.cmake -G "${NTF_CONFIGURE_GENERATOR}" -S ${NTF_CONFIGURE_REPOSITORY}
if [ ${?} -ne 0 ]; then
echo "Failed to configure"
exit 1
Expand All @@ -966,21 +965,21 @@ MAKEFLAGS+=${NTF_CONFIGURE_MAKEFLAGS}
all: build
build:
@${NTF_CONFIGURE_CMAKE} --build ${NTF_CONFIGURE_OUTPUT} --parallel ${NTF_CONFIGURE_JOBS} 2>&1 | tee -a ${NTF_CONFIGURE_LOG_PREFIX}build.log
@${NTF_CONFIGURE_CMAKE} --build ${NTF_CONFIGURE_OUTPUT} --parallel ${NTF_CONFIGURE_JOBS}
build_test:
@${NTF_CONFIGURE_CMAKE} --build ${NTF_CONFIGURE_OUTPUT} --parallel ${NTF_CONFIGURE_JOBS} --target build_test 2>&1 | tee -a ${NTF_CONFIGURE_LOG_PREFIX}build.log
@${NTF_CONFIGURE_CMAKE} --build ${NTF_CONFIGURE_OUTPUT} --parallel ${NTF_CONFIGURE_JOBS} --target build_test
test:
@export CTEST_PARALLEL_LEVEL=1
@${NTF_CONFIGURE_CMAKE} --build ${NTF_CONFIGURE_OUTPUT} --parallel ${NTF_CONFIGURE_JOBS} --target build_test 2>&1 | tee -a ${NTF_CONFIGURE_LOG_PREFIX}build.log
@${NTF_CONFIGURE_CMAKE} --build ${NTF_CONFIGURE_OUTPUT} --parallel 1 --target test 2>&1 | tee -a ${NTF_CONFIGURE_LOG_PREFIX}test.log
@${NTF_CONFIGURE_CMAKE} --build ${NTF_CONFIGURE_OUTPUT} --parallel ${NTF_CONFIGURE_JOBS} --target build_test
@${NTF_CONFIGURE_CMAKE} --build ${NTF_CONFIGURE_OUTPUT} --parallel 1 --target test
test_usage:
@${NTF_CONFIGURE_CMAKE} --build ${NTF_CONFIGURE_OUTPUT} --parallel 1 --target test_usage 2>&1 | tee -a ${NTF_CONFIGURE_LOG_PREFIX}test_usage.log
@${NTF_CONFIGURE_CMAKE} --build ${NTF_CONFIGURE_OUTPUT} --parallel 1 --target test_usage
coverage:
@${NTF_CONFIGURE_CMAKE} --build ${NTF_CONFIGURE_OUTPUT} --parallel 1 --target coverage 2>&1 | tee -a ${NTF_CONFIGURE_LOG_PREFIX}test.log
@${NTF_CONFIGURE_CMAKE} --build ${NTF_CONFIGURE_OUTPUT} --parallel 1 --target coverage
install:
@${NTF_CONFIGURE_CMAKE} --install ${NTF_CONFIGURE_OUTPUT} --prefix ${NTF_CONFIGURE_INSTALL_PREFIX_OVERRIDE}
Expand Down
8 changes: 8 additions & 0 deletions groups/ntc/ntcdns/ntcdns_database.t.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2125,6 +2125,10 @@ NTCCFG_TEST_CASE(3)
// Concern: Host database configurations from "/etc/hosts".
// Plan:

if (!ntscfg::Platform::hasHostDatabase()) {
return;
}

NTCI_LOG_CONTEXT();

ntsa::Error error;
Expand Down Expand Up @@ -2158,6 +2162,10 @@ NTCCFG_TEST_CASE(4)
// Concern: Port database configurations from "/etc/services".
// Plan:

if (!ntscfg::Platform::hasPortDatabase()) {
return;
}

NTCI_LOG_CONTEXT();

ntsa::Error error;
Expand Down
56 changes: 56 additions & 0 deletions groups/ntc/ntcdns/ntcdns_resolver.t.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -633,6 +633,14 @@ NTCCFG_TEST_CASE(6)
// Concern: Test 'getIpAddress' from database.
// Plan:

if (!ntscfg::Platform::hasHostDatabase()) {
return;
}

if (!ntscfg::Platform::hasPortDatabase()) {
return;
}

NTCI_LOG_CONTEXT();

ntsa::Error error;
Expand Down Expand Up @@ -731,6 +739,14 @@ NTCCFG_TEST_CASE(7)
// Concern: Test 'getDomainName' from database.
// Plan:

if (!ntscfg::Platform::hasHostDatabase()) {
return;
}

if (!ntscfg::Platform::hasPortDatabase()) {
return;
}

NTCI_LOG_CONTEXT();

ntsa::Error error;
Expand Down Expand Up @@ -832,6 +848,14 @@ NTCCFG_TEST_CASE(8)
// Concern: Test 'getPort' from database.
// Plan:

if (!ntscfg::Platform::hasHostDatabase()) {
return;
}

if (!ntscfg::Platform::hasPortDatabase()) {
return;
}

NTCI_LOG_CONTEXT();

ntsa::Error error;
Expand Down Expand Up @@ -929,6 +953,14 @@ NTCCFG_TEST_CASE(9)
// Concern: Test 'getServiceName' from database.
// Plan:

if (!ntscfg::Platform::hasHostDatabase()) {
return;
}

if (!ntscfg::Platform::hasPortDatabase()) {
return;
}

NTCI_LOG_CONTEXT();

ntsa::Error error;
Expand Down Expand Up @@ -1027,6 +1059,14 @@ NTCCFG_TEST_CASE(10)
// Concern: Test 'getEndpoint' from database.
// Plan:

if (!ntscfg::Platform::hasHostDatabase()) {
return;
}

if (!ntscfg::Platform::hasPortDatabase()) {
return;
}

NTCI_LOG_CONTEXT();

ntsa::Error error;
Expand Down Expand Up @@ -1734,6 +1774,10 @@ NTCCFG_TEST_CASE(18)
// Concern: Test 'getPort' from system.
// Plan:

if (!ntscfg::Platform::hasPortDatabase()) {
return;
}

NTCI_LOG_CONTEXT();

ntsa::Error error;
Expand Down Expand Up @@ -1810,6 +1854,10 @@ NTCCFG_TEST_CASE(19)
// Concern: Test 'getServiceName' from system.
// Plan:

if (!ntscfg::Platform::hasPortDatabase()) {
return;
}

NTCI_LOG_CONTEXT();

ntsa::Error error;
Expand Down Expand Up @@ -1887,6 +1935,14 @@ NTCCFG_TEST_CASE(20)
// Concern: Test 'getEndpoint' from system.
// Plan:

if (!ntscfg::Platform::hasHostDatabase()) {
return;
}

if (!ntscfg::Platform::hasPortDatabase()) {
return;
}

NTCI_LOG_CONTEXT();

ntsa::Error error;
Expand Down
Loading

0 comments on commit f4ea959

Please sign in to comment.