From 3221f469294ba54c491826fa840320c345add507 Mon Sep 17 00:00:00 2001 From: Christian Eltzschig Date: Tue, 31 Oct 2023 00:43:52 +0100 Subject: [PATCH] [#3] Add script to check existance of license header --- ... => ci_test_only_use_assert_that_macro.sh} | 0 scripts/ci_test_spdx_license_header.sh | 27 ++++++ scripts/ci_test_target.sh | 85 ------------------- 3 files changed, 27 insertions(+), 85 deletions(-) rename scripts/{check_only_use_assert_that_macro.sh => ci_test_only_use_assert_that_macro.sh} (100%) create mode 100755 scripts/ci_test_spdx_license_header.sh delete mode 100755 scripts/ci_test_target.sh diff --git a/scripts/check_only_use_assert_that_macro.sh b/scripts/ci_test_only_use_assert_that_macro.sh similarity index 100% rename from scripts/check_only_use_assert_that_macro.sh rename to scripts/ci_test_only_use_assert_that_macro.sh diff --git a/scripts/ci_test_spdx_license_header.sh b/scripts/ci_test_spdx_license_header.sh new file mode 100755 index 0000000..c2e530a --- /dev/null +++ b/scripts/ci_test_spdx_license_header.sh @@ -0,0 +1,27 @@ +#!/bin/bash + +cd $(git rev-parse --show-toplevel) + +RET_VAL=0 +FILES=$(find . -iwholename "*.rs") +CHECK_LICENSE="// SPDX-License-Identifier: Apache-2.0" + +for FILE in $FILES +do + FIRST_LINE=$(head -n 1 $FILE) + SECOND_LINE=$(head -n 2 $FILE | tail -n 1) + + if [[ "$FIRST_LINE" != "$CHECK_LICENSE" ]] + then + echo "$FILE :: missing license header \"$CHECK_LICENSE\"" + RET_VAL=1 + fi + + if [[ "$SECOND_LINE" != "" ]] + then + echo "$FILE :: missing new line after license header" + RET_VAL=1 + fi +done + +exit $RET_VAL diff --git a/scripts/ci_test_target.sh b/scripts/ci_test_target.sh deleted file mode 100755 index 2c7787e..0000000 --- a/scripts/ci_test_target.sh +++ /dev/null @@ -1,85 +0,0 @@ -#!/bin/bash - -# on freebsd to be able to work with message queues -# kldload mqueuefs -# mount -t mqueuefs null /mnt/mqueue - -CRATES=" - elkodon_bb_lock_free - elkodon_bb_threadsafe - elkodon_bb_container - elkodon_bb_elementary - elkodon_bb_log - elkodon_bb_memory - elkodon_bb_posix - elkodon_bb_system_types - elkodon_bb_testing - - elkodon_cal - elkodon - - elkodon_pal_posix - elkodon_pal_settings - elkodon_pal_concurrency_primitives - - example_publish_subscribe - example_event - example_discovery - - benchmark_publish_subscribe" - -HAS_FAILED=0 - -function build() { - cargo build -p $CRATE - - if [[ $? -ne 0 ]] - then - echo "FAILED to build: $CRATE" - HAS_FAILED=1 - exit $HAS_FAILED - fi -} - -function test() { - cargo test -p $CRATE -- --test-threads=1 - - if [[ $? -ne 0 ]] - then - echo "FAILED test in: $CRATE" - HAS_FAILED=1 - exit $HAS_FAILED - fi -} - -function doc_test() { - cargo test --doc -p $CRATE - - if [[ $? -ne 0 ]] - then - echo "FAILED doc test in: $CRATE" - HAS_FAILED=1 - exit $HAS_FAILED - fi -} - -cd $(git rev-parse --show-toplevel) - -echo Install required packages -apt -y update -apt -y install libacl1-dev - -echo Install some test users and test groups -useradd testuser1 -useradd testuser2 -groupadd testgroup1 -groupadd testgroup2 - -for CRATE in $CRATES -do - build - test - doc_test -done - -exit $HAS_FAILED