Skip to content

travis: update CI configuration #55

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 12 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .ci/before_install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,7 @@ fi
pip install configparser || die
pip install requests || die
pip install XlsxWriter || die
pip install cpplint || die
pip install flake8 || die
pip install sh || die
}
26 changes: 26 additions & 0 deletions .ci/code_check.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/bin/sh

die()
{
echo " *** ERROR: " $*
exit 1
}

# When pull request, check code style
if [ "$TRAVIS_PULL_REQUEST" != "false" ]; then
git diff --name-only --diff-filter=d FETCH_HEAD..master \
| ( grep '.\(c\|cpp\|h\|hpp\)$' || true ) \
| while read file; do cpplint "${file}" >> result.log 2>&1; done


git diff --name-only --diff-filter=d FETCH_HEAD..master \
| ( grep '.\(py\)$' || true ) \
| while read file; do flake8 "${file}" >> result.log 2>&1; done


COMMENT_CONTENT=$(sed 's/$/&<br>/g' result.log)
COMMENT_HEAD="# Code style check result \n***********************\n<pre>"
COMMENT_TAIL="</pre>"
COMMENT="${COMMENT_HEAD}${COMMENT_CONTENT}${COMMENT_TAIL}"
bash -c "$COMMENTS"
fi
56 changes: 56 additions & 0 deletions .ci/expected.ini
Original file line number Diff line number Diff line change
@@ -1,3 +1,59 @@
[embarc_applications/ibaby_smarthome_multinode/src/wearable_node]
iotdk=

[embarc_applications/ibaby_smarthome_multinode/src/lamp_node]
iotdk=
hsdk=

[embarc_applications/aws_iot_smarthome/src]
iotdk=

[embarc_applications/arc_design_contest/2018/HUST_iRhythm]
iotdk=
hsdk=

[embarc_applications/arc_design_contest/2018/XDU_Master-Sign-Language/arc]
iotdk=
hsdk=
emsk=22,23

[embarc_applications/arc_design_contest/2018/Smart_Power_Saving_System_of_3D_Remote_Interaction/ARC]
iotdk=
hsdk=

[embarc_applications/arc_design_contest/2018/HUST_inverted_pendulum/src]
iotdk=
hsdk=

[embarc_applications/arc_design_contest/2018/NCTU_Smart_Pillow/src]
iotdk=

[embarc_applications/arc_design_contest/2018/XDU_Autofollowing_suitcase/src]
iotdk=

[embarc_applications/aws_iot_smarthome_secureshield/src]
iotdk=
hsdk=
emsk=

[embarc_applications/ilight_smartdevice/src]
iotdk=

[embarc_applications/aws_iot_smarthome_multinode/src/frontDoor]
iotdk=

[embarc_applications/aws_iot_smarthome_multinode/src/kitchen]
iotdk=

[embarc_applications/aws_iot_smarthome_multinode/src/livingRoom]
iotdk=

[embarc_applications/ot_smarthome_multinode/src/frontDoor]
iotdk=
hsdk=
emsk=22,23

[embarc_applications/ot_smarthome_multinode/src/livingRoom]
iotdk=
hsdk=
emsk=22,23
83 changes: 83 additions & 0 deletions .ci/get_examples.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
import os
import json
import argparse
import git
from embarc_tools.utils import cd, getcwd
from embarc_tools.settings import MAKEFILENAMES


def parse_args():
parser = argparse.ArgumentParser(
description="Generate a sanitycheck argument for for tests "
" that have changed")
parser.add_argument("--root", default=getcwd(),
help="Specify the repo root directory")
parser.add_argument('--commit_start', default=None,
help="Commit range start point")
parser.add_argument('--commit_end', default=None,
help="Commit range end point")
parser.add_argument('--only_failed', action="store_true",
help="Commit range end point")
return parser.parse_args()


def find_embarc_appl(root):
cur_path = root
cur_dir = os.path.dirname(root)
while cur_path != cur_dir:
for item in os.listdir(cur_dir):
if item in MAKEFILENAMES:
return cur_dir
cur_path = cur_dir
cur_dir = os.path.dirname(cur_path)


def get_modified_examples(root, tree0, tree1):
root = os.path.abspath(root)
dirname = os.path.basename(root)
repo = git.Repo(root)
diff_cmd = ["--name-only"]
diff_cmd.append("{}..{}".format(tree0, tree1))
examples_changed = list()
update = repo.git.diff(diff_cmd).split("\n")
for item in update:
if not item.startswith("."):
item_path = os.path.join(root, item)
example_root = find_embarc_appl(item_path)
if example_root:
example_root = example_root.replace(root, dirname)
examples_changed.append(example_root)
return examples_changed


def get_last_failed(file=None):
if file:
job = file
else:
job = os.environ.get("CI_JOB_NAME")
if not job:
job = os.environ.get("NAME")
if not job:
job = os.environ.get("STAGE_NAME")
if job:
home = os.environ.get("HOME")
cache = "{}/.cache/result".format(home)
last_failed_cache = os.path.join(cache, job, "failed_results.json")
if os.path.exists(last_failed_cache):
last_failed_appls = json.load(last_failed_cache).keys()
return last_failed_appls

def main():
args = parse_args()
if args.commit_start and args.commit_end:
examples_changed = get_modified_examples(args.root,
args.commit_start, args.commit_end)
if examples_changed:
print("%s" %(",".join(examples_changed)))
if args.only_failed:
last_failed_appls = get_last_failed()
if last_failed_appls:
print("%s" %(",".join(last_failed_appls)))

if __name__ == "__main__":
main()
108 changes: 59 additions & 49 deletions .ci/script.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,69 +3,79 @@ die() {
exit 1

}
if [ "$NAME" == "code-style-check" ]; then
bash .ci/code_check.sh || die
else
TOOLCHAIN_CACHE_FOLDER=".cache/toolchain"
ARC_DEV_GNU_ROOT="/u/arcgnu_verif/gnu_builds"
ARC_DEV_MW_ROOT="/u/relauto/.TOOLS_ROOT/ToolsCommon/MWDT_eng/"

TOOLCHAIN_CACHE_FOLDER=".cache/toolchain"
ARC_DEV_GNU_ROOT="/u/arcgnu_verif/gnu_builds"
ARC_DEV_MW_ROOT="/u/relauto/.TOOLS_ROOT/ToolsCommon/MWDT_eng/"
if [ "${TOOLCHAIN}" == "gnu" ]; then
ARC_DEV_TOOL_ROOT="${ARC_DEV_GNU_ROOT}/${TOOLCHAIN_VER}/elf32_le_linux"
else
ARC_DEV_TOOL_ROOT="${ARC_DEV_MW_ROOT}/mwdt_${TOOLCHAIN_VER}/linux/ARC"
fi

if [ "${TOOLCHAIN}" == "gnu" ]; then
ARC_DEV_TOOL_ROOT="${ARC_DEV_GNU_ROOT}/${TOOLCHAIN_VER}/elf32_le_linux"
else
ARC_DEV_TOOL_ROOT="${ARC_DEV_MW_ROOT}/mwdt_${TOOLCHAIN_VER}/linux/ARC"
fi
if [ "$TRAVIS_PULL_REQUEST" != "false" ]; then
modified_example=$(python .ci/get_examples.py --root . --commit_start FETCH_HEAD --commit_end master)
if [ "$modified_example" ]; then
EXAMPLES="$modified_example"
fi
fi

U_NAME=${U_NAME:=embARC_Bot}
U_EMAIL=${U_EMAIL:[email protected]}
echo $U_NAME, $U_EMAIL
git config --global user.name "${U_NAME}"
git config --global user.email "${U_EMAIL}"
git checkout -- . || die
git archive --format zip -o applications.zip --prefix embarc_applications/ HEAD || die
U_NAME=${U_NAME:=embARC_Bot}
U_EMAIL=${U_EMAIL:[email protected]}
echo $U_NAME, $U_EMAIL
git config --global user.name "${U_NAME}"
git config --global user.email "${U_EMAIL}"
git checkout -- . || die
git archive --format zip -o applications.zip --prefix embarc_applications/ HEAD || die

embARC_OSP_REPO=${embARC_OSP_REPO:="https://github.com/foss-for-synopsys-dwc-arc-processors/embarc_osp.git"}
embARC_OSP_REPO=${embARC_OSP_REPO:="https://github.com/foss-for-synopsys-dwc-arc-processors/embarc_osp.git"}

git clone ${embARC_OSP_REPO} embarc_osp
cd embarc_osp || die
unzip ../applications.zip>/dev/null 2>&1 || die
git clone ${embARC_OSP_REPO} embarc_osp
cd embarc_osp || die
unzip ../applications.zip>/dev/null 2>&1 || die

[ "$TRAVIS" == "true" ] && {
if [ "${TOOLCHAIN}" == "gnu" ] ; then
python .ci/toolchain.py -v $TOOLCHAIN_VER -c $TOOLCHAIN_CACHE_FOLDER || die
if [ -d $TOOLCHAIN_CACHE_FOLDER ] ;then
if [ -d $TOOLCHAIN_CACHE_FOLDER/$TOOLCHAIN_VER ] ; then
ARC_DEV_TOOL_ROOT="${TOOLCHAIN_CACHE_FOLDER}/${TOOLCHAIN_VER}"
[ "$TRAVIS" == "true" ] && {
if [ "${TOOLCHAIN}" == "gnu" ] ; then
python .ci/toolchain.py -v $TOOLCHAIN_VER -c $TOOLCHAIN_CACHE_FOLDER || die
if [ -d $TOOLCHAIN_CACHE_FOLDER ] ;then
if [ -d $TOOLCHAIN_CACHE_FOLDER/$TOOLCHAIN_VER ] ; then
ARC_DEV_TOOL_ROOT="${TOOLCHAIN_CACHE_FOLDER}/${TOOLCHAIN_VER}"
fi
fi
else
die "Toolchain not supported in travis ci"
fi
}

if [ -d $ARC_DEV_TOOL_ROOT ] ; then
bash .ci/linux_env_set_arc.sh -t $TOOLCHAIN -r $ARC_DEV_TOOL_ROOT || die
[ ! -e "arctool.env" ] && die "arctool.env doesn't exist"
source arctool.env || die
rm -rf arctool.env || die
else
die "Toolchain not supported in travis ci"
die "The toolchain path ${ARC_DEV_TOOL_ROOT} does not exist "
fi
}

if [ -d $ARC_DEV_TOOL_ROOT ] ; then
bash .ci/linux_env_set_arc.sh -t $TOOLCHAIN -r $ARC_DEV_TOOL_ROOT || die
[ ! -e "arctool.env" ] && die "arctool.env doesn't exist"
source arctool.env || die
rm -rf arctool.env || die
else
die "The toolchain path ${ARC_DEV_TOOL_ROOT} does not exist "
fi


if [ "${TOOLCHAIN}" == "gnu" ] ; then
arc-elf32-gcc -v || die "ARC GNU toolchain is not installed correctly"
else
ccac -v || die "MWDT toolchain is not installed correctly"
fi
if [ "${TOOLCHAIN}" == "gnu" ] ; then
arc-elf32-gcc -v || die "ARC GNU toolchain is not installed correctly"
else
ccac -v || die "MWDT toolchain is not installed correctly"
fi

{
bash apply_embARC_patch.sh || die

{
bash apply_embARC_patch.sh || die
EXPECTED="../${EXPECTED}"
cd .ci || die
{
BUILD_OPTS="OSP_ROOT=${OSP_ROOT} TOOLCHAIN=${TOOLCHAIN} BOARD=${BOARD} BD_VER=${BD_VER} CUR_CORE=${CUR_CORE} TOOLCHAIN_VER=${TOOLCHAIN_VER} EXAMPLES=${EXAMPLES} EXPECTED=${EXPECTED}"
python build.py ${BUILD_OPTS} || die
}

EXPECTED="../${EXPECTED}"
cd .ci || die
{
BUILD_OPTS="OSP_ROOT=${OSP_ROOT} TOOLCHAIN=${TOOLCHAIN} BOARD=${BOARD} BD_VER=${BD_VER} CUR_CORE=${CUR_CORE} GNU_VER=${GNU_VER} EXAMPLES=${EXAMPLES} EXPECTED=${EXPECTED}"
python build.py ${BUILD_OPTS} || die
}
fi

}
48 changes: 37 additions & 11 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
language: python
python: 2.7
python: 3.6

sudo: required
dist: trusty
Expand All @@ -15,19 +15,36 @@ env:
"context": "travis-ci/$NAME",
"target_url": "https://travis-ci.org/$TRAVIS_REPO_SLUG/jobs/$TRAVIS_JOB_ID"
}\nDATA'

COMMENT=none
COMMENTS=$'curl -so/dev/null --user "$EMBARC_BOT" --request POST
https://api.github.com/repos/$TRAVIS_REPO_SLUG/issues/$TRAVIS_PULL_REQUEST/comments
--data @- << DATA\n{
"body": "$COMMENT"
}\nDATA'
- EXPECTED=".ci/expected.ini"
- TOOLCHAIN="gnu"
- TOOLCHAIN_VER="latest"
- EXAMPLES=$(basename ${TRAVIS_REPO_SLUG})

cache:
pip: true
directories:
- .cache/result
- .cache/toolchain
- $HOME/.cache/result
- $HOME/.cache/toolchain

before_install:
- bash .ci/before_install.sh
# setup git
- git config --global user.name "${U_NAME}"
- git config --global user.email "${U_EMAIL}"
- >
if [ "$TRAVIS_PULL_REQUEST" != "false" ]; then
diff=$(git diff FETCH_HEAD master .ci)
if [ "$diff" == "" ]; then
git checkout remotes/origin/master -- .ci
fi
fi
- bash .ci/before_install.sh

after_success:
- bash -c "$STATUS" success "Local $NAME testing has passed"
Expand All @@ -40,21 +57,30 @@ script:

matrix:
include:
- env: NAME="emsk-11-gnu_201709" OSP_ROOT="." BOARD="emsk" TOOLCHAIN="gnu" BD_VER="11" TOOLCHAIN_VER="2017.09" EXAMPLES="embarc_applications"
- env: NAME="code-style-check"
os: linux
compiler: gcc
- env: NAME="emsk-11-gnu_201803" OSP_ROOT="." BOARD="emsk" TOOLCHAIN="gnu" BD_VER="11" TOOLCHAIN_VER="2018.03" EXAMPLES="embarc_applications"

- env: NAME="emsk-11-gnu_latest" OSP_ROOT="." BOARD="emsk" BD_VER="11"
os: linux
compiler: gcc
- env: NAME="emsk-22-gnu_201709" OSP_ROOT="." BOARD="emsk" TOOLCHAIN="gnu" BD_VER="22" TOOLCHAIN_VER="2017.09" EXAMPLES="embarc_applications"

- env: NAME="emsk-22-gnu_latest" OSP_ROOT="." BOARD="emsk" BD_VER="22"
os: linux
compiler: gcc
- env: NAME="emsk-22-gnu_201803" OSP_ROOT="." BOARD="emsk" TOOLCHAIN="gnu" BD_VER="22" TOOLCHAIN_VER="2018.03" EXAMPLES="embarc_applications"

- env: NAME="emsk-23-gnu_latest" OSP_ROOT="." BOARD="emsk" BD_VER="23" EXAMPLES="embarc_applications/ilight_smartdevice,embarc_applications/ibaby_smarthome_multinode,embarc_applications/aws_iot_smarthome,embarc_applications/aws_iot_smarthome_multinode,embarc_applications/aws_iot_smarthome_secureshield"
os: linux
compiler: gcc
- env: NAME="emsk-23-gnu_201709" OSP_ROOT="." BOARD="emsk" TOOLCHAIN="gnu" BD_VER="23" TOOLCHAIN_VER="2017.09" EXAMPLES="embarc_applications"

- env: NAME="emsk-23-gnu_latest" OSP_ROOT="." BOARD="emsk" BD_VER="23" EXAMPLES="embarc_applications/arc_design_contest,embarc_applications/ot_smarthome_multinode"
os: linux
compiler: gcc

- env: NAME="hsdk-gnu-latest" OSP_ROOT="." BOARD="hsdk"
os: linux
compiler: gcc
- env: NAME="emsk-23-gnu_201803" OSP_ROOT="." BOARD="emsk" TOOLCHAIN="gnu" BD_VER="23" TOOLCHAIN_VER="2018.03" EXAMPLES="embarc_applications"

- env: NAME="iotdk-gnu-latest" OSP_ROOT="." BOARD="iotdk"
os: linux
compiler: gcc
compiler: gcc
Loading