~aleteoryx/muditaos

d83e8fe34b94acbed123afb1ee1de5c06c0c2562 — Adam Dobrowolski 4 years ago f16a18d
[EGD-7445] Removed dead scripts

Removed dead scripts
12 files changed, 1 insertions(+), 815 deletions(-)

D .github/actions/build/action.yml
D .github/workflows/main.yml
D .github/workflows/releases.yaml
D PurePhone JLink Debug.launch
M doc/adding_unittests.md
D print_last_changes.sh
D tools/check_unittests.sh
D tools/daily_release.sh
D tools/get_unittests.sh
D tools/last_changelog.awk
D tools/run_unittests.sh
D tools/upload_release.sh
D .github/actions/build/action.yml => .github/actions/build/action.yml +0 -47
@@ 1,47 0,0 @@
name: 'Style Check'
description: 'Checking style for last commit'
branding:
  icon: 'align-left'
  color: 'white'
inputs:
  action:
    description: 'Describes action to be taken: style|configure|build|c&b|check|package'
    required: true
    default: 'style'
  target:
    description: 'Defines on destination target, should be one of: rt1051|linux'
    required: false
    default: 'rt1051'
  build_type:
    destination: 'Defines build type, must be one of: Debug|Release|RelWithDebInfo'
    required: false
    default: 'RelWithDebInfo'
  build_generator:
    description: 'Define kind of generator, must be one of make|Ninja'
    required: false
    default: 'make'
  jobs:
    description: 'Defines how many parallel jobs to run, default is to number of cpus'
    required: false
    default: 'nproc'
outputs:
  build_dir: # name of the vaiable
    description: "Build directory name"
  package:
    description: "Name of the package"
  package_path:
    description: "Full path to the package"
  mime_type:
    description: "Mime type of the package"
  release_notes:
    description: "Content of changelog.md"
runs:
  using: 'docker'
  image: 'docker://muditadocker/pure_phone_build:v1.2'
  args:
    - ${{ inputs.action }}
    - ${{ inputs.target }}
    - ${{ inputs.build_type }}
    - ${{ inputs.build_generator}}
    - ${{ inputs.jobs}}


D .github/workflows/main.yml => .github/workflows/main.yml +0 -93
@@ 1,93 0,0 @@
name: CI

on:
  pull_request:
    types:
      - opened
      - synchronize
      - reopened
      - ready_for_review

jobs:
  check_commit_messages:
    name: check commit messages
    if: github.event.pull_request.draft == false
    runs-on: self-hosted
    steps:
      - name: clone repository
        uses: actions/checkout@v2
        with:
          fetch-depth: 0
      - name: check commit messages
        run: ./tools/check_commit_messages.py

  check_copyright_and_style:
    name: check copyright and style
    if: github.event.pull_request.draft == false
    runs-on: self-hosted
    steps:
      - name: clone repository
        uses: actions/checkout@v2
        with:
          token: ${{ secrets.GitHub_PAT }}
          fetch-depth: 0
          submodules: recursive
      - name: Copyright notice check
        run: config/license_header_check.sh --ci --check-only
      - name: Style checking
        run: ./config/style_check_hook.sh --last
      - name: Clang tidy check
        run: ./config/clang_check.sh

  build_rt1051_binary:
    name: build rt1051 binary
    if: github.event.pull_request.draft == false
    needs:
      - check_copyright_and_style
    runs-on: self-hosted
    steps:
      - name: clone repository
        uses: actions/checkout@v2
        with:
          token: ${{ secrets.GitHub_PAT }}
          submodules: recursive
      - name: Build for RT1051
        run: |
          export JOBS=${JOBS:-$(nproc)} && \
          echo "JOBS=${JOBS}" &&  \
          ./configure.sh pure rt1051 Release -G Ninja && \
          pushd build-purephone-rt1051-Release && \
          ninja -j ${JOBS} && \
          popd 

  build_linux_binary_and_run_tests:
    name: build linux binary and run tests
    if: github.event.pull_request.draft == false
    needs:
      - check_copyright_and_style
    runs-on: self-hosted
    steps:
      - name: clone repository
        uses: actions/checkout@v2
        with:
          token: ${{ secrets.GitHub_PAT }}
          submodules: recursive
      - name: build Linux Debug
        run: |
          export JOBS=${JOBS:-$(nproc)} && \
          echo "JOBS=${JOBS}" &&  \
          ./configure.sh pure linux Debug -G Ninja && \
          pushd build-purephone-linux-Debug && \
          ninja -j ${JOBS} unittests && \
          ninja -j ${JOBS} && \
          popd
      - name: run unit tests
        run: |
          ./tools/run_unittests.sh enabled_unittests
      - name: Check for statics
        run: |
          ./tools/find_global_data.py build-purephone-linux-Debug/PurePhone.elf
      - name: check if all Unit Tests where run
        run: |
          ./tools/check_unittests.sh enabled_unit_tests


D .github/workflows/releases.yaml => .github/workflows/releases.yaml +0 -84
@@ 1,84 0,0 @@
name: Build Release
on:
  push:
    tags:
    - 'release-*'

jobs:
  build:
    runs-on: self-hosted
    steps:
    - name: "Check Out"
      uses: actions/checkout@v2
      with:
        token: ${{ secrets.RELEASE_TOKEN }}
        submodules: recursive
        fetch-depth: 0
    - name: "Style checking"
      run: |
        ./config/pre-commit.hook --last
    - name: Build Unit Tests
      run: |
        export JOBS=${JOBS:-$(nproc)} && \
        echo "JOBS=${JOBS}" &&  \
        ./configure.sh pure linux Debug -G Ninja && \
        pushd build-purephone-linux-Debug && \
        ninja unittests && \
        popd
    - name: Run unit tests
      run: |
        export JOBS=${JOBS:-$(nproc)} && \
        echo "JOBS=${JOBS}" &&  \
        pushd build-purephone-linux-Debug && \
        ninja check -j ${JOBS} && \
        popd
    - name: "Build and package for RT1051"
      id: build_release_package 
      env:
        ASSETS_LOGIN: ${{ secrets.ASSETS_LOGIN }}
        ASSETS_TOKEN: ${{ secrets.ASSETS_TOKEN }}
      run: |
        export JOBS=${JOBS:-$(nproc)} && \
        echo "JOBS=${JOBS}" &&  \
        ./configure.sh pure rt1051 RelWithDebInfo -DWITH_BOARD_REVISION=6 -G Ninja && \
        pushd build-purephone-rt1051-RelWithDebInfo && \
        ninja -j ${JOBS} Pure&& \
        ninja -j ${JOBS} PurePhone-UpdatePackage && \
        ninja -j ${JOBS} PurePhone-StandaloneImage && \
        popd && \
        ./print_last_changes.sh && \
        uptime
    - name: Create Release
      id: create_release
      uses: actions/create-release@v1
      env:
        GITHUB_TOKEN: ${{ secrets.RELEASE_TOKEN }}
      with:
        tag_name: ${{ github.ref }}
        release_name: ${{ github.ref }}
        draft: true
        prerelease: true
        body: ${{steps.build_release_package.outputs.release_notes }}
    - name: Upload Standalone Package
      id: upload-stanalone-package
      uses: actions/upload-release-asset@v1.0.2
      env:
        GITHUB_TOKEN: ${{ secrets.RELEASE_TOKEN }}
      with:
        upload_url: ${{ steps.create_release.outputs.upload_url }}
        # here we have to use relative path with starting "./"
        asset_path: ./${{ steps.build_release_package.outputs.package_path }}/${{ steps.build_release_package.outputs.package-standalone }}
        asset_name: ${{ steps.build_release_package.outputs.package-standalone }}
        asset_content_type: ${{ steps.build_release_package.outputs.standalone-mime_type }}
    - name: Upload Update Package
      id: upload-update-package
      uses: actions/upload-release-asset@v1.0.2
      env:
        GITHUB_TOKEN: ${{ secrets.RELEASE_TOKEN }}
      with:
        upload_url: ${{ steps.create_release.outputs.upload_url }}
        # here we have to use relative path with starting "./"
        asset_path: ./${{ steps.build_release_package.outputs.package_path }}/${{ steps.build_release_package.outputs.package-update }}
        asset_name: ${{ steps.build_release_package.outputs.package-update }}
        asset_content_type: ${{ steps.build_release_package.outputs.update-mime_type }}


D PurePhone JLink Debug.launch => PurePhone JLink Debug.launch +0 -91
@@ 1,91 0,0 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<launchConfiguration type="com.nxp.mcuxpresso.core.debug.support.segger.launchConfigurationType">
<stringAttribute key="com.crt.ctrlcenter.OFSemuDetails" value="JLink50120482"/>
<booleanAttribute key="com.crt.ctrlcenter.mainBreakIsHardware" value="true"/>
<stringAttribute key="com.crt.ctrlcenter.serialNumber" value="USB 50120482"/>
<mapAttribute key="com.crt.ctrlcenter.symbolsGroupSettings"/>
<intAttribute key="com.nxp.mcuxpresso.core.debug.support.segger.launches.JLinkLaunchConfigHandler.version" value="2"/>
<booleanAttribute key="com.nxp.mcuxpresso.flash.clear.console" value="true"/>
<booleanAttribute key="com.nxp.mcuxpresso.flash.confirm" value="false"/>
<stringAttribute key="com.nxp.mcuxpresso.ide.probe.manufacturer" value="SEGGER"/>
<stringAttribute key="com.nxp.mcuxpresso.ide.probe.name" value="J-Link"/>
<stringAttribute key="com.nxp.mcuxpresso.ide.probe.type" value="USB"/>
<stringAttribute key="com.nxp.mcuxpresso.jlink.flash.base.address" value="0x00000000"/>
<stringAttribute key="com.nxp.mcuxpresso.jlink.flash.executable" value="hex"/>
<booleanAttribute key="com.nxp.mcuxpresso.jlink.flash.halt.target" value="true"/>
<booleanAttribute key="com.nxp.mcuxpresso.jlink.flash.reset.target" value="true"/>
<stringAttribute key="com.nxp.mcuxpresso.segger.auto.startup" value="auto"/>
<stringAttribute key="com.nxp.mcuxpresso.segger.device" value="MCIMXRT1051"/>
<stringAttribute key="com.nxp.mcuxpresso.segger.endian" value="little"/>
<stringAttribute key="com.nxp.mcuxpresso.segger.halt.target" value="-halt"/>
<stringAttribute key="com.nxp.mcuxpresso.segger.if" value="SWD"/>
<stringAttribute key="com.nxp.mcuxpresso.segger.init.register" value="-noir"/>
<stringAttribute key="com.nxp.mcuxpresso.segger.jlinkscriptfile" value="C:\Projects\PurePhone\evkbimxrt1050_sdram_init.jlinkscript"/>
<stringAttribute key="com.nxp.mcuxpresso.segger.options" value=""/>
<intAttribute key="com.nxp.mcuxpresso.segger.port" value="2331"/>
<booleanAttribute key="com.nxp.mcuxpresso.segger.powertarget 50" value="false"/>
<stringAttribute key="com.nxp.mcuxpresso.segger.reset" value="true;"/>
<stringAttribute key="com.nxp.mcuxpresso.segger.rtos" value="true;GDBServer/RTOSPlugin_FreeRTOS"/>
<stringAttribute key="com.nxp.mcuxpresso.segger.select" value="USB=50120482"/>
<stringAttribute key="com.nxp.mcuxpresso.segger.silent" value="-nosilent"/>
<stringAttribute key="com.nxp.mcuxpresso.segger.singlerun" value="-singlerun"/>
<stringAttribute key="com.nxp.mcuxpresso.segger.speed" value="auto"/>
<intAttribute key="com.nxp.mcuxpresso.segger.swoport" value="2332"/>
<intAttribute key="com.nxp.mcuxpresso.segger.telnetport" value="2333"/>
<stringAttribute key="com.nxp.mcuxpresso.segger.verify" value="-vd"/>
<stringAttribute key="disconnect" value="Run"/>
<stringAttribute key="launch.config.handler" value="com.nxp.mcuxpresso.core.debug.support.segger.launches.JLinkLaunchConfigHandler"/>
<intAttribute key="org.eclipse.cdt.debug.gdbjtag.core.delay" value="3"/>
<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.doHalt" value="true"/>
<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.doReset" value="true"/>
<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.imageFileName" value=""/>
<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.imageOffset" value=""/>
<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.initCommands" value="monitor reset"/>
<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.ipAddress" value="localhost"/>
<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.jtagDeviceId" value="org.eclipse.cdt.debug.gdbjtag.core.jtagdevice.genericDevice"/>
<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.loadImage" value="true"/>
<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.loadSymbols" value="true"/>
<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.pcRegister" value=""/>
<intAttribute key="org.eclipse.cdt.debug.gdbjtag.core.portNumber" value="2331"/>
<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.runCommands" value=""/>
<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.setPcRegister" value="false"/>
<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.setResume" value="false"/>
<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.setStopAt" value="true"/>
<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.stopAt" value="main"/>
<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.symbolsFileName" value=""/>
<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.symbolsOffset" value=""/>
<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.useFileForImage" value="false"/>
<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.useFileForSymbols" value="false"/>
<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.useProjBinaryForImage" value="true"/>
<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.useProjBinaryForSymbols" value="true"/>
<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.useRemoteTarget" value="true"/>
<stringAttribute key="org.eclipse.cdt.dsf.gdb.DEBUG_NAME" value="arm-none-eabi-gdb"/>
<booleanAttribute key="org.eclipse.cdt.dsf.gdb.DEBUG_ON_FORK" value="false"/>
<booleanAttribute key="org.eclipse.cdt.dsf.gdb.EXTERNAL_CONSOLE" value="false"/>
<stringAttribute key="org.eclipse.cdt.dsf.gdb.GDB_INIT" value=""/>
<booleanAttribute key="org.eclipse.cdt.dsf.gdb.NON_STOP" value="false"/>
<booleanAttribute key="org.eclipse.cdt.dsf.gdb.REVERSE" value="false"/>
<stringAttribute key="org.eclipse.cdt.dsf.gdb.REVERSE_MODE" value="UseSoftTrace"/>
<stringAttribute key="org.eclipse.cdt.dsf.gdb.TRACEPOINT_MODE" value="TP_NORMAL_ONLY"/>
<booleanAttribute key="org.eclipse.cdt.dsf.gdb.UPDATE_THREADLIST_ON_SUSPEND" value="false"/>
<intAttribute key="org.eclipse.cdt.launch.ATTR_BUILD_BEFORE_LAUNCH_ATTR" value="2"/>
<stringAttribute key="org.eclipse.cdt.launch.DEBUGGER_ID" value="gdb"/>
<stringAttribute key="org.eclipse.cdt.launch.DEBUGGER_START_MODE" value="remote"/>
<stringAttribute key="org.eclipse.cdt.launch.PROGRAM_NAME" value="build\PurePhone.elf"/>
<stringAttribute key="org.eclipse.cdt.launch.PROJECT_ATTR" value="PurePhone"/>
<booleanAttribute key="org.eclipse.cdt.launch.PROJECT_BUILD_CONFIG_AUTO_ATTR" value="false"/>
<stringAttribute key="org.eclipse.cdt.launch.PROJECT_BUILD_CONFIG_ID_ATTR" value=""/>
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
<listEntry value="/PurePhone"/>
</listAttribute>
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
<listEntry value="4"/>
</listAttribute>
<mapAttribute key="org.eclipse.debug.core.preferred_launchers">
<mapEntry key="[debug]" value="com.nxp.mcuxpresso.core.debug.support.segger.dsfLaunchDelegate"/>
</mapAttribute>
<stringAttribute key="org.eclipse.dsf.launch.MEMORY_BLOCKS" value="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;memoryBlockExpressionList context=&quot;reserved-for-future-use&quot;/&gt;&#13;&#10;"/>
<stringAttribute key="process_factory_id" value="com.crt.dsfdebug.dsf.override.CRTProcessFactory"/>
<booleanAttribute key="semihost" value="true"/>
<booleanAttribute key="start.server" value="true"/>
</launchConfiguration>

M doc/adding_unittests.md => doc/adding_unittests.md +1 -22
@@ 10,25 10,16 @@ There are few test written in `gtest` but we focus on using `catch2`
In `CMakeLists.txt` use `add_catch2_executable` function for tests based on `catch2`.
If you wrote your test in `gtest` use `add_gtest_executable` function.
Both functions are defined in `test/CMakeLists.txt` and there described parameters.
Then to make sure that test is run add it to `enabled_unittests`.

Each binary has it's own section, and in section we each test in separate line,
each test name have to end with;

## disable unit test

If for some reason you need to disable some unit test, find it in `enabled_unittests` and
put # before it's name

## checking what tests are run

On our CI, we check what tests are available in binaries and if they where run.
If some tests are not run, job called "Check run unit tests" will fail, this check
is not required for PR to pass, it is just indicator that some tests are not working.

## running tests

Locally we may run tests in two way by `make check` or by `./tools/run_unittests.sh`

### make check



@@ 36,18 27,6 @@ This will run all defined tests, even disabled ones, what is useful for unit tes
This way is not used on CI.

```bash
cd buil-linux-Debug
cd build-purephone-linux-Debug
make check
```

### run_unittests.sh

Runs only enabled tests, this how we do it on CI.
All tests must pass, if test doesn't pass PR is blocked.


```bash
./tools/run_unittests.sh enabled_unittests
```

This script may be used for running set of tests.

D print_last_changes.sh => print_last_changes.sh +0 -17
@@ 1,17 0,0 @@
#!/bin/bash
# Copyright (c) 2017-2020, Mudita Sp. z.o.o. All rights reserved.
# For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md

# prints change log as a GitHub Variable

CHANGELOG_FILE="changelog.md"

function printChangeLogForGH() {
    CHANGELOG="$(awk -f tools/last_changelog.awk ${CHANGELOG_FILE})"
    CHANGELOG="${CHANGELOG//'%'/'%25'}"
    CHANGELOG="${CHANGELOG//$'\n'/'%0A'}"
    CHANGELOG="${CHANGELOG//$'\r'/'%0D'}"
    echo "::set-output name=release_notes::${CHANGELOG}"
}

printChangeLogForGH

D tools/check_unittests.sh => tools/check_unittests.sh +0 -121
@@ 1,121 0,0 @@
#!/bin/bash
# Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved.
# For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md

root_dir="$(realpath $(dirname $(realpath $0))/..)"
build_dir="${root_dir}/build-linux-Debug"

ALL_TESTS_FILE=all_unittests
ALL_TESTS_PATH=${build_dir}/${ALL_TESTS_FILE}
ENABLED_TESTS_PATH=${root_dir}/enabled_unittests

END=0

trim() {
    local var="$*"
    # remove leading whitespace characters
    var="${var#"${var%%[![:space:]]*}"}"
    # remove trailing whitespace characters
    var="${var%"${var##*[![:space:]]}"}"   
    printf '%s' "$var"
}


# get all tests
${root_dir}/tools/get_unittests.sh ${ALL_TESTS_FILE} CHECK_OUT > /dev/null
TEMP_SOURCE=$(mktemp)
sed -e '/^[[:space:]]*#.*/d' ${ALL_TESTS_PATH} > $TEMP_SOURCE
source ${TEMP_SOURCE}

# get enabled tests
sed -e '/^[[:space:]]*#.*/d' ${ENABLED_TESTS_PATH} > $TEMP_SOURCE
source ${TEMP_SOURCE}

declare -a BINARY_NOT_RUN
declare -A TESTS_NOT_RUN
echo "--tests--"
for BINARY in ${!CHECK_OUT[@]}
do
    #echo BINARY:$BINARY
    #echo "TESTS_LIST[${BINARY}]: ${TESTS_LIST[${BINARY}]}" 
    if [[ -n "${TESTS_LIST[${BINARY}]}" ]]; then
        #echo ""
        readarray -d\; -t TESTS_FROM_ALL < <(echo ${CHECK_OUT["${BINARY}"]} | tr "\n" " ")
        #declare -p TESTS_FROM_ALL
        #echo "NO: ${#TESTS_FROM_ALL[@]}"
        I=0
        declare -a TEST_NOT_RUN
        while [[ ${I} -lt ${#TESTS_FROM_ALL[@]} ]]; 
        do
            CURRENT_TEST=$(trim ${TESTS_FROM_ALL[${I}]})
            if [[ -n "$CURRENT_TEST" ]]; then
                #if [[ ${BINARY} == "catch2-gui-text" ]]; then
                #    echo "--- CURRENT_TEST: ${CURRENT_TEST}"
                #fi
                CHK=$(echo ${TESTS_LIST["${BINARY}"]} | grep -F "${CURRENT_TEST}")
                #echo "#@#@#@# $CHK #@#@##"
                if [[ -z "${CHK}" ]]; then
                    #echo "!!!!!!!!!!${CURRENT_TEST}!!!!!!!!!"
                    TEST_NOT_RUN+=("${CURRENT_TEST}")
                fi
            fi
            I=$(( $I + 1 ))
        done
        if [[ "${#TEST_NOT_RUN[@]}" -gt 0 ]]; then
            #echo "!@@!@!@!@!@! ${#TEST_NOT_RUN[@]} @!#!@#!@#!"
            #declare -p TEST_NOT_RUN
            I=0
            TEST_NOT_RUN_STR=""
            while [[ $I -lt ${#TEST_NOT_RUN[@]} ]]
            do
                #TEST_NOT_RUN_STR="${TEST_NOT_RUN[${I}]};${TEST_NOT_RUN_STR}"
                TEST_NOT_RUN_STR="${TEST_NOT_RUN_STR};${TEST_NOT_RUN[${I}]}"
                I=$(( I + 1 ))
            done
            TESTS_NOT_RUN["${BINARY}"]="${TEST_NOT_RUN_STR}"
            unset TEST_NOT_RUN
        fi
    else 
        #echo "######## $BINARY ########"
        BINARY_NOT_RUN+=($BINARY)
    fi
done

if [[ -n "${BINARY_NOT_RUN}" ]]; then
    END=1
    I=0
    echo "binaries not run:"
    while [[ $I -lt ${#BINARY_NOT_RUN[@]} ]]
    do
        echo "  - ${BINARY_NOT_RUN[$I]}"
        I=$(( $I + 1 ))
    done
fi
pushd ${build_dir} > /dev/null
BINARIES_IN_BUILD=( `ls -1 catch2*` )
popd > /dev/null
BINARIES_IN_DECLARED=( ${!TESTS_LIST[@]} )

if [[ ${#BINARIES_IN_BUILD[@]} -ne ${#BINARIES_IN_DECLARED[@]} ]]; then
    END=1
    echo "not all binaries were build:"
    printf '\t- %s\n' ${BINARIES_IN_BUILD[@]} ${BINARIES_IN_DECLARED[@]} | sort | uniq -u
fi
#declare -p TESTS_NOT_RUN
#echo ${#TESTS_NOT_RUN[@]}
if [[ "${#TESTS_NOT_RUN[@]}" -gt 0 ]]; then
    END=1
    echo "Tests not run:"
    for BINARY in ${!TESTS_NOT_RUN[@]}
    do
        echo -n "  - Binary: ${BINARY}"
        echo "${TESTS_NOT_RUN[${BINARY}]}" | sed 's/;/\n\t- /g'
    done
fi

case $END in
    "0") echo "OK";;
    "*") echo "ERROR";;
esac

exit $END

D tools/daily_release.sh => tools/daily_release.sh +0 -116
@@ 1,116 0,0 @@
#!/bin/bash 
# Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved.
# For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md

#script is used on CI for creating daily builds

#this script should be run in docker container

set -e

LOGIN=${LOGIN}
TOKEN=${TOKEN}
IMAGE_NAME=${IMAGE_NAME:-wearemudita/mudita_os_builder:1.9}
WORK_DIR=${WORK_DIR:-MuditaOS}
REPOSITORY_URL=${REPOSITORY_URL:-https://${TOKEN}:x-oauth-basic@github.com/mudita/MuditaOS}
REPOSITORY_BRANCH=${REPOSITORY_BRANCH:-master}
ARTIFACTS_DIR=${ARTIFACTS_DIR:-/artifacts/${REPOSITORY_BRANCH}}
PRODUCT=${PRODUCT:-PurePhone}

CONFIG_LOG=config.log

VARS_TO_CHECK=(
        PRODUCT
        REPOSITORY_URL
        REPOSITORY_BRANCH
        LOGIN
        TOKEN
        IMAGE_NAME
    )

function printVar(){
    echo "$1: '${!1}'"
}

function checkVariables() {
    I=0
    while [[ $I -lt ${#VARS_TO_CHECK[@]} ]]
    do
        printVar ${VARS_TO_CHECK[$I]}
        if [[ -z "${!VARS_TO_CHECK[$I]}" ]]; then
            echo "${VARS_TO_CHECK[$I]} is not set - aborting" 1>&2
            exit 1
        fi
        I=$(( I + 1 ))
    done
}

function checkIfGit() {
    if [[ -d .git ]]; then
        echo .git;
    else 
        git rev-parse --git-dir 2> /dev/null;
    fi;
}

function addTokens(){
    git config user.githublogin ${LOGIN}
    git config user.apitoken ${TOKEN}
}

##################### script ####################
checkVariables

if [ ! -d ${ARTIFACTS_DIR} ]; then
    mkdir -p ${ARTIFACTS_DIR}
fi

if [ ! -d ${WORK_DIR} ]; then
    mkdir -p ${WORK_DIR}
fi

pushd ${WORK_DIR}

if checkIfGit; then
    git clean -ffdx                                   &>/dev/null
    git fetch --tags --force                          &>/dev/null
    git checkout ${REPOSITORY_BRANCH} -f
    git reset origin/${REPOSITORY_BRANCH} --hard      &>/dev/null
    git submodule update --init --recursive --force   &>/dev/null
else
    echo "not a git dir"
    git clone --recurse-submodules -b ${REPOSITORY_BRANCH} ${REPOSITORY_URL} .
fi

if [ ! -d ccache ]; then
    mkdir ccache
fi

CCACHE_DIR=$(pwd)/ccache
export CCACHE_DIR

DATE=$(date "+%Y.%m.%d")
# gets latest release tag
# please mind that if there are more than one tag - first will be taken
LATEST=$(git tag -l | grep release\- | grep -E '[0-9]{1,2}.[0-9]{1,2}.[0-9]{1,2}' -o | tail -1)
VERSION="${LATEST}-${DATE}"
echo "Creating release with: $VERSION"

addTokens
git submodule update --init --recursive
git tag -f daily-${VERSION}
git push -f origin daily-${VERSION}
./configure.sh ${PRODUCT} rt1051 RelWithDebInfo -G Ninja
cd build-${PRODUCT,,}-rt1051-RelWithDebInfo
ninja
ninja ${PRODUCT}-StandaloneImage
ninja ${PRODUCT}-UpdatePackage

PKG_NAME_PREFIX=${PRODUCT}-${LATEST}-RT1051

echo "Copy assets to ${ARTIFACTS_DIR}" 
cp *-image.tar.xz ${ARTIFACTS_DIR}/${PKG_NAME_PREFIX}-${DATE}-image.tar.xz
cp *-Update.tar ${ARTIFACTS_DIR}/${PKG_NAME_PREFIX}-${DATE}-Update.tar

/scripts/upload_release.sh tag="daily-${VERSION}" token="$TOKEN" repo="MuditaOS" files="${ARTIFACTS_DIR}/${PKG_NAME_PREFIX}-${DATE}-image.tar.xz,${ARTIFACTS_DIR}/${PKG_NAME_PREFIX}-${DATE}-Update.tar,PurePhone.elf" || { echo "upload failed!"; exit 1; }
popd

D tools/get_unittests.sh => tools/get_unittests.sh +0 -77
@@ 1,77 0,0 @@
#!/bin/bash
# Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved.
# For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md

root_dir="$(realpath $(dirname $(realpath $0))/..)"
build_dir="${root_dir}/build-linux-Debug"

function help() {
    cat <<- EOF
		Usage: $0 tests_list [VAR_NAME]
	EOF
}


if [[ $# -lt 1 ]]; then
    help
    exit 1
fi

TESTS_FILE=$1

TESTS_LIST_VAR=${2:-TESTS_LIST}

function addHeader() {
cat <<- EOF
	# Enabled test list
	# test format
	# TESTS_LIST["catch2-<binary-name>"]=" 
	#        test 1;
	#        test 1; 
	#        test 3;
	#"
	# 
	# each test is in separate line
	# to disable test just rem it by putting # in front of it
	# 
	# folowing caracters have to be escaped:
	# [],
	# \[ \] \,
	
	declare -A ${TESTS_LIST_VAR}
	
EOF
}

pushd ${build_dir}
addHeader > ${TESTS_FILE}

for TEST_BINARY in catch2-*
do
    echo "${TEST_BINARY}"
    echo "${TESTS_LIST_VAR}[\"${TEST_BINARY}\"]=\"" >> ${TESTS_FILE}

    #sed explaind
    #:a         - lablel 'a' current pattern space to jump to
    #N          - append next line to pattern space (wiht \n)
    #/\n  /     - search for this pattern
    #s/\n //    - delete "\n " (can be "replace")
    #ta         - if we changed something, jump to lable 'a'
    #P          - print part until new line
    #D          - delete part until new line
    TESTS_LIST_STR=$(./${TEST_BINARY} -l | grep -E "^  .*" | cut -f3- -d\  | sed -e ':a;N;/\n  /s/\n //;ta;P;D' )

    readarray -t TESTS_LIST < <( echo -e "$TESTS_LIST_STR" | tr "\n" "\0" | xargs -0 -i{} echo {} )

    I=0
    while [[ $I -lt ${#TESTS_LIST[@]} ]]
    do
        #sed cannot search for single ] to search for it we use ][ patter (and also look for closing ])
        echo -e "    ${TESTS_LIST[$I]};" | sed -e 's#[][,]#\\&#g' >> ${TESTS_FILE}
        I=$(( $I + 1 ))
    done
    echo "\"" >> ${TESTS_FILE}
    echo "#---------" >> ${TESTS_FILE}
done
popd


D tools/last_changelog.awk => tools/last_changelog.awk +0 -17
@@ 1,17 0,0 @@
#!/usr/bin/awk -f
# Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved.
# For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md

BEGIN {
    version_count=0
}

/^## / {
    version_count++
}

{
    if(version_count < 2) {
        print $0
    }
}

D tools/run_unittests.sh => tools/run_unittests.sh +0 -77
@@ 1,77 0,0 @@
#!/bin/bash
# Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved.
# For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md

root_dir="$(realpath $(dirname $(realpath $0))/..)"
build_dir="${root_dir}/build-linux-Debug"

run_logs=${build_dir}/ut_run_logs

function help() {
    cat <<- EOF
		Usage: $0 tests_list
	EOF
}

trim() {
    local var="$*"
    # remove leading whitespace characters
    var="${var#"${var%%[![:space:]]*}"}"
    # remove trailing whitespace characters
    var="${var%"${var##*[![:space:]]}"}"   
    printf '%s' "$var"
}

if [[ $# -ne 1 ]]; then
    help
    exit 1
fi

source ${root_dir}/config/common_scripsts_lib

TESTS_FILE=$1

if [[ ! -r ${TESTS_FILE} ]]; then
    echo "Cannot read: \"${TESTS_FILE}\""
    exit 2
fi

TEMP_SOURCE=$(mktemp)

sed -e '/^[[:space:]]*#.*/d' ${TESTS_FILE} > $TEMP_SOURCE

source ${TEMP_SOURCE}

pushd ${build_dir}
for TEST_BINARY in catch2-*
do
    echo "= ${TEST_BINARY} ="
    readarray -d\; -t TESTS < <(echo ${TESTS_LIST["${TEST_BINARY}"]} | tr "\n" " " )
    I=0
    while [[ $I -lt ${#TESTS[@]} ]]
    do
        CUR_TEST=$( trim ${TESTS[$I]}) 
        if [[ -n "${CUR_TEST}" ]]; then
            echo -en "${TEST_BINARY} \"${CUR_TEST}\":"
            ./${TEST_BINARY} "${CUR_TEST}" --use-colour=yes > ${run_logs}
            RESULT=$?

            if [[ ${RESULT} -eq 0 ]]; then
                echo -e "${OK}"
            else
                echo -e "${ERROR}"
                cat ${run_logs}
                exit 1
            fi

            CHK_IF_RUN=`cat ${run_logs} | grep "No tests ran" || true` 
            echo "---$CHK_IF_RUN---"
            if [[ -n "${CHK_IF_RUN}" ]]; then
                echo "no such test: ${TEST_BINARY} ${CUR_TEST}"
                exit 1
            fi
        fi
        I=$(( $I + 1 ))
    done
done
popd

D tools/upload_release.sh => tools/upload_release.sh +0 -53
@@ 1,53 0,0 @@
#!/bin/bash
# Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved.
# For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md

# base taken from: https://gist.github.com/stefanbuck/ce788fee19ab6eb0b4447a85fc99f447 and modified
# modman: Adam
# license: mit

set -eou pipefail

for line in "$@"; do
  eval "$line"
done

[ -v "tag"  ]  ||   { echo "script requires tag as parameter i.e. latest release tag"; exit 1; }
[ -v "token" ] ||  { echo "script requires token as parameter to access server (please see GitHub tags)"; exit 1; }
[ -v "files" ] ||  { echo "script requires files as parameters to know what files to upload to server"; exit 1; }
[ -v "repo" ]  ||  { echo "script requires repo to push to"; exit 1; }

github_api_token="$token"
filenames=( $(echo $files | tr "," " ") )

for file in "${filenames[@]}"; do
    [ -f "$file" ] || { echo "file '$file' doesn't exist!"; exit 1; }
done

# Define variables.
GH_REPO="https://api.github.com/repos/mudita/$repo"
GH_TAGS="$GH_REPO/releases/tags/$tag"
GH_RELEASE="$GH_REPO/releases"
AUTH="Authorization: token $github_api_token"

echo "test token"
curl -o /dev/null -sH "$AUTH" $GH_REPO || { echo "Error: Invalid repo, token or network issue!";  exit 1; }

echo "create release"
curl -sH "$AUTH" -H "Accept: application/vnd.github.v3+json" -X POST $GH_RELEASE -d '{"tag_name":"'"$tag"'", "prerelease":true, "name":"'"$tag"'","body":"WARNING: this is daily prerelease"}' &>/dev/null

response=$(curl -sH "$AUTH" $GH_TAGS)
eval $(echo "$response" | grep -m 1 "id.:" | grep -w id | tr : = | tr -cd '[[:alnum:]]=')
[ "$id" ] || { echo "Error: Failed to get release id for tag: $tag"; echo "$response" | awk 'length($0)<100' >&2; exit 1; }

echo "release ID : ${id}"


for filename in "${filenames[@]}"; do
    GH_ASSET="https://uploads.github.com/repos/mudita/$repo/releases/$id/assets?name=$(basename $filename)"
    [[ "$filename" =~ .*.tar ]] && content_type='Content-Type: application/x-tar' || content_type='Content-Type: application/x-xz'
    curl -s --data-binary @"$filename" -H "Authorization: token $github_api_token" -H "$content_type" $GH_ASSET  &>/dev/null
    echo "asset $filename added to release under: tag $tag"
done

echo "uploading files done!"