Skip to content

Commit

Permalink
[action] use github action to build arc_lab
Browse files Browse the repository at this point in the history
Signed-off-by: Jingru Wang <[email protected]>
  • Loading branch information
wangnuannuan committed Jul 25, 2023
1 parent 66eab80 commit a883ac5
Show file tree
Hide file tree
Showing 9 changed files with 229 additions and 381 deletions.
File renamed without changes.
67 changes: 67 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
name: Build

env:
GIT_AUTHOR_NAME: svc-arcoss_auto arc
GIT_COMMITTER_NAME: svc-arcoss_auto arc
GIT_AUTHOR_EMAIL: [email protected]
GIT_COMMITTER_EMAIL: [email protected]
TOOLCHAIN: gnu
TOOLCHAIN_VER: 2020.09
on:
push:
branches:
- master
- jingru-github-ci-flow

jobs:
example-build-on-iotdk:
name: "Build arc_labs tests on iotdk"
runs-on: ubuntu-latest
env:
BOARD: iotdk

steps:
- name: checkout
uses: actions/checkout@v2
with:
submodules: true
- name: checkout-embarc_osp
uses: actions/checkout@v2
with:
repository: foss-for-synopsys-dwc-arc-processors/embarc_osp
path: 'embarc_osp'
ref: scripts-allow-insert-tests

- name: install-dependencies
run: |
bash ./embarc_osp/scripts/.ci/before_install.sh
- name: build
run: |
bash .github/workflows/script.sh
example-build-on-nsim:
name: "Build arc_labs tests on nsim"
runs-on: ubuntu-latest
env:
BOARD: nsim

steps:
- name: checkout
uses: actions/checkout@v2
with:
submodules: true
- name: checkout-embarc_osp
uses: actions/checkout@v2
with:
repository: foss-for-synopsys-dwc-arc-processors/embarc_osp
path: 'embarc_osp'
ref: scripts-allow-insert-tests

- name: install-dependencies
run: |
bash ./embarc_osp/scripts/.ci/before_install.sh
- name: build
run: |
bash .github/workflows/script.sh
79 changes: 79 additions & 0 deletions .github/workflows/script.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
#!/bin/sh -eux

readonly _DIR="$(readlink -e $(dirname $(readlink -e $0)))"

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

prepare_env() {
out_dir="${_DIR}/out"
logs_dir="${_DIR}/logs"
test_log="$logs_dir/test.log"

mkdir -p $logs_dir $out_dir
: >$test_log

TOOLCHAIN_CACHE_FOLDER=".cache/toolchain"

[ "${TRAVIS}" == "true" || "${GITHUB_ACTIONS}" == "true" ] && {
if [ "${TOOLCHAIN}" == "gnu" ] ; then
python scripts/.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 ${TOOLCHAIN} not supported in travis ci"
fi
}

if [ -d $ARC_DEV_TOOL_ROOT ] ; then
REAL_ARC_DEV_ROOT=$(readlink -f ${ARC_DEV_TOOL_ROOT})
export ARC_GNU_ROOT=${REAL_ARC_DEV_ROOT}
export PATH=${REAL_ARC_DEV_ROOT}/bin:${PATH}
arc-elf32-gcc -v || die "ARC GNU toolchain is not installed correctly"
else
die "The toolchain path ${ARC_DEV_TOOL_ROOT} does not exist "
fi
git checkout -- . || die

echo "Using ${TOOLCHAIN}-${TOOLCHAIN_VER}" || die
. apply_embARC_patch.sh
}

run_test() {
local target_flags=""
if [[ ${BD_VER:-} ]]; then
target_flags="$target_flags --platform-version $BD_VER"
fi
export PYTHONUNBUFFERED=1
{
hostname
python ./scripts/test.py --platform $BOARD --testcase-root arc_labs/labs --toolchain $TOOLCHAIN $target_flags --build-only --report-dir $logs_dir -v -v || true
} 2>&1 | tee -a $test_log
}

parse_logs() {
# get rid of MAC \r and change it to UNIX \n
sed -i 's/\r/\n/g' $test_log

METRICS=$(cat $test_log | grep "test configurations passed" | sed -n 's/^.* \([0-9]\+\) of.*, \([0-9]\+\).*failed, \([0-9]\+\).*in \([0-9]\+\).*$/\1 \2 \3 \4/p')
if ! ([ ${#METRICS[@]} -eq 4 ] && [ ${METRICS[1]} == "0" ]); then
exit 1
fi
}

main() {
mkdir embarc_osp/arc_labs
cp -r labs embarc_osp/arc_labs
pushd embarc_osp
prepare_env
run_test
parse_logs
popd
}

main
135 changes: 0 additions & 135 deletions .gitlab-ci.yml

This file was deleted.

70 changes: 0 additions & 70 deletions .travis.yml

This file was deleted.

Loading

0 comments on commit a883ac5

Please sign in to comment.