Skip to content

Commit

Permalink
azure pipeline ci init -- move files from dabnn
Browse files Browse the repository at this point in the history
  • Loading branch information
daquexian committed May 23, 2019
1 parent a645f98 commit ce1a521
Show file tree
Hide file tree
Showing 32 changed files with 299 additions and 0 deletions.
4 changes: 4 additions & 0 deletions ci/adb_push_and_run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#! /usr/bin/env bash

# echo "${@:2}"
adb push $1 /data/local/tmp/`basename $1` && adb shell "data/local/tmp/`basename $1` ${@:2}"
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes
54 changes: 54 additions & 0 deletions ci/build_aar.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
#! /usr/bin/env bash

set -e

nproc=$(ci/get_cores.sh)
if [[ "$OSTYPE" == "darwin"* ]]; then
echo "The system is Mac OS X, alias sed to gsed"
export PATH="/usr/local/opt/gnu-sed/libexec/gnubin:$PATH"
echo "Output of sed -v:"
sed --version
fi

MY_ANDROID_HOME="${ANDROID_HOME:-$HOME/Android/Sdk}"
MY_ANDROID_NDK_HOME="${ANDROID_NDK_HOME:-$MY_ANDROID_HOME/ndk-bundle}"
JNI_BUILD_DIR=build_jni_tmp
rm -rf ${JNI_BUILD_DIR} && mkdir ${JNI_BUILD_DIR} && pushd ${JNI_BUILD_DIR}
cmake -DCMAKE_SYSTEM_NAME=Android -DCMAKE_TOOLCHAIN_FILE=${MY_ANDROID_NDK_HOME}/build/cmake/android.toolchain.cmake -DANDROID_CPP_FEATURES=exceptions -DANDROID_PLATFORM=android-21 -DANDROID_ABI=arm64-v8a -DBNN_BUILD_JNI=ON -DBNN_BUILD_TEST=OFF -DBNN_BUILD_BENCHMARK=OFF ..
cmake --build . -- -j$nproc
popd
mkdir -p ci/android_aar/dabnn/src/main/jniLibs/arm64-v8a
cp ${JNI_BUILD_DIR}/dabnn/jni/libdabnn-jni.so ci/android_aar/dabnn/src/main/jniLibs/arm64-v8a/

# Increase version code and update version name

echo "Build source branch: $BUILD_SOURCEBRANCH"

if (($# == 0)); then
if [[ $BUILD_SOURCEBRANCH == refs/tags/v* ]]; then
ver=`echo $BUILD_SOURCEBRANCH | cut -c 12-`
else
echo "HEAD is not tagged as a version, skip deploy aar"
exit 0
fi
elif (( $# == 1 )); then
ver=$1
fi
echo "ver=$ver"

sed -i -E "s/versionName .+/versionName \"v$ver\"/" ci/android_aar/dabnn/build.gradle
sed -i -E "s/publishVersion = .+/publishVersion = \'$ver\'/" ci/android_aar/dabnn/build.gradle

cat ci/android_aar/dabnn/build.gradle

pushd ci/android_aar
ANDROID_HOME=$MY_ANDROID_HOME ./gradlew clean build

# Publishing is only for myself
if [[ -z $BINTRAY_KEY ]]; then
echo "BINTRAY_KEY is not set, skip bintray upload"
else
echo "Publishing.."
ANDROID_HOME=$MY_ANDROID_HOME ./gradlew bintrayUpload -PbintrayUser=daquexian566 -PbintrayKey=$BINTRAY_KEY -PdryRun=false
fi
popd
8 changes: 8 additions & 0 deletions ci/build_appimage.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
wget https://github.com/linuxdeploy/linuxdeploy/releases/download/continuous/linuxdeploy-x86_64.AppImage
wget https://github.com/linuxdeploy/linuxdeploy-plugin-appimage/releases/download/continuous/linuxdeploy-plugin-appimage-x86_64.AppImage

chmod +x linuxdeploy-*.AppImage
mkdir -p ci/appimage/appdir/usr/bin
cp build_onnx2bnn/tools/onnx2bnn/onnx2bnn ci/appimage/appdir/usr/bin/
./linuxdeploy-x86_64.AppImage --appdir ci/appimage/appdir -d ci/appimage/onnx2bnn.desktop -i ci/appimage/onnx2bnn.png --output appimage
mv `ls onnx2bnn-*.AppImage` onnx2bnn.AppImage
10 changes: 10 additions & 0 deletions ci/build_dnnlibrary.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#! /usr/bin/env bash
set -e

echo "y" | $ANDROID_HOME/tools/bin/sdkmanager --install 'ndk-bundle'
nproc=$(ci/get_cores.sh)

mkdir build_dabnn && cd build_dabnn
cmake -DCMAKE_TOOLCHAIN_FILE=$ANDROID_HOME/ndk-bundle/build/cmake/android.toolchain.cmake -DANDROID_ABI=arm64-v8a -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DCMAKE_BUILD_TYPE=Release ..
cmake --build . -- -j$nproc
cd -
9 changes: 9 additions & 0 deletions ci/build_onnx2daq.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#! /usr/bin/env bash
set -e

nproc=$(ci/get_cores.sh)

mkdir build_onnx2bnn && cd build_onnx2bnn
cmake ..
cmake --build . -- -j$nproc
cd -
47 changes: 47 additions & 0 deletions ci/dnnlibrary_build_and_test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
trigger:
branches:
include:
- master
tags:
include:
- v*
paths:
include:
- '*'
exclude:
- README.md
- docs/*
pr:
branches:
include:
- '*'
paths:
include:
- '*'
exclude:
- README.md
- docs/*

pool:
vmImage: 'macOS-10.14'
steps:
- checkout: self
submodules: true
- bash: brew install watch gnu-sed
displayName: Install watch and gnu-sed
- bash: ci/build_dabnn.sh
displayName: Build
- bash: ci/start_android_emulator.sh
displayName: Start Android Emulator
- bash: ci/adb_push_and_run.sh build_dabnn/tests/bconv_test
displayName: Binary Conv Test
- bash: ci/adb_push_and_run.sh build_dabnn/tests/bgemm_test
displayName: Binary Gemm Test
- bash: ci/download_models.sh
displayName: Download Models
- bash: ci/adb_push_and_run.sh build_dabnn/tests/net_test
displayName: Model Test
- bash: ci/build_aar.sh
env:
BINTRAY_KEY: $(bintrayKey)
displayName: Build and Publish AAR package
6 changes: 6 additions & 0 deletions ci/download_models.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#! /usr/bin/env bash

wget "https://drive.google.com/uc?export=download&id=1FYqF5BvYO2kl13bn28sheKtgverkbbQN" -O model_imagenet.dab
adb push model_imagenet.dab /data/local/tmp
wget "https://drive.google.com/uc?export=download&id=1frtRL1O0zhtJvPFbhE8COFl1-WWHIaOW" -O model_imagenet_stem.dab
adb push model_imagenet_stem.dab /data/local/tmp/
5 changes: 5 additions & 0 deletions ci/get_cores.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
if [[ "$OSTYPE" == "drawin*" ]]; then
echo $(sysctl -n hw.physicalcpu)
else
echo $(nproc)
fi
79 changes: 79 additions & 0 deletions ci/onnx2daq_build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
trigger:
branches:
include:
- master
tags:
include:
- v*
paths:
include:
- '*'
exclude:
- README.md
- docs/*
# not trigger onnx2bnn build when only dabnn is edited
- dabnn/*
pr:
branches:
include:
- '*'
paths:
include:
- '*'
exclude:
- README.md
- docs/*
# not trigger onnx2bnn build when only dabnn is edited
- dabnn/*

jobs:
- job: LinuxAppImage
pool:
vmImage: 'ubuntu-16.04'
steps:
- checkout: self
submodules: true
- script: sudo apt install -y protobuf-compiler libprotobuf-dev
displayName: Install protobuf
- bash: ci/build_onnx2bnn.sh
displayName: Build
- bash: ci/build_appimage.sh
displayName: Build AppImage
- task: CopyFiles@2
inputs:
contents: 'onnx2bnn.AppImage'
targetFolder: $(Build.ArtifactStagingDirectory)
- template: template_onnx2bnn_publish_artifacts.yml
- template: template_onnx2bnn_github_release.yml
- job: Windows
pool:
vmImage: 'vs2017-win2016'
steps:
- checkout: self
submodules: true
- template: template_onnx2bnn_build_python_all_version.yml
- task: CopyFiles@2
inputs:
sourceFolder: '.setuptools-cmake-build\tools\onnx2bnn\Release\'
contents: 'onnx2bnn.exe'
targetFolder: $(Build.ArtifactStagingDirectory)
- template: template_onnx2bnn_publish_artifacts.yml
- template: template_onnx2bnn_github_release.yml
- template: template_onnx2bnn_upload_to_pypi.yml
- job: macOS
pool:
vmImage: 'macOS-10.14'
steps:
- checkout: self
submodules: true
- template: template_onnx2bnn_build_python_all_version.yml
- script: 'cp .setuptools-cmake-build/tools/onnx2bnn/onnx2bnn .setuptools-cmake-build/tools/onnx2bnn/onnx2bnn-macos'
displayName: 'Rename onnx2bnn'
- task: CopyFiles@2
inputs:
sourceFolder: '.setuptools-cmake-build/tools/onnx2bnn'
contents: 'onnx2bnn-macos'
targetFolder: $(Build.ArtifactStagingDirectory)
- template: template_onnx2bnn_publish_artifacts.yml
- template: template_onnx2bnn_github_release.yml
- template: template_onnx2bnn_upload_to_pypi.yml
24 changes: 24 additions & 0 deletions ci/start_android_emulator.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#! /usr/bin/env bash
set -e

export TERM=xterm

echo "y" | $ANDROID_HOME/tools/bin/sdkmanager --install 'system-images;android-25;google_apis;arm64-v8a'

echo "no" | $ANDROID_HOME/tools/bin/avdmanager create avd -n android_emulator -k 'system-images;android-25;google_apis;arm64-v8a' --force

echo "Starting emulator"

# Start emulator in background
nohup $ANDROID_HOME/emulator/emulator -avd android_emulator -no-snapshot -no-audio &

# start server in advance, so that the result of watch will only change when device gets online
$ANDROID_HOME/platform-tools/adb start-server

watch -g -n 1 '$ANDROID_HOME/platform-tools/adb devices | grep -c device$'

echo "Emulator is online"

$ANDROID_HOME/platform-tools/adb devices

echo "Emulator started"
6 changes: 6 additions & 0 deletions ci/template_onnx2daq_build_python.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
steps:
- script: python -m pip install --user --upgrade setuptools wheel twine
displayName: Install setuptools, wheel and twine
- script: python setup.py bdist_wheel
workingDirectory: tools/onnx2bnn/python/
displayName: Build onnx2bnn python package
20 changes: 20 additions & 0 deletions ci/template_onnx2daq_build_python_all_version.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
steps:
- task: UsePythonVersion@0
inputs:
versionSpec: '3.7'
addToPath: true
architecture: 'x64'
- template: template_onnx2bnn_build_python.yml
- task: UsePythonVersion@0
inputs:
versionSpec: '3.6'
addToPath: true
architecture: 'x64'
- template: template_onnx2bnn_build_python.yml
- task: UsePythonVersion@0
inputs:
versionSpec: '3.5'
addToPath: true
architecture: 'x64'
- template: template_onnx2bnn_build_python.yml

12 changes: 12 additions & 0 deletions ci/template_onnx2daq_github_release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
steps:
- task: GitHubRelease@0
condition: and(succeeded(), startsWith(variables['Build.SourceBranch'], 'refs/tags/v'))
inputs:
gitHubConnection: 'dabnn release'
repositoryName: '$(Build.Repository.Name)'
action: 'edit'
tag: '$(Build.SourceBranchName)'
target: '$(Build.SourceVersion)'
assets: '$(Build.ArtifactStagingDirectory)/*'
assetUploadMode: 'replace'

6 changes: 6 additions & 0 deletions ci/template_onnx2daq_publish_artifacts.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
steps:
- task: PublishBuildArtifacts@1
inputs:
pathtoPublish: $(Build.ArtifactStagingDirectory)
artifactName: onnx2bnn

9 changes: 9 additions & 0 deletions ci/template_onnx2daq_upload_to_pypi.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
steps:
- script: python -m twine upload dist/* --verbose
condition: and(succeeded(), startsWith(variables['Build.SourceBranch'], 'refs/tags/v'))
displayName: Upload wheel to PyPI
workingDirectory: tools/onnx2bnn/python/
env:
TWINE_USERNAME: $(twineUsername)
TWINE_PASSWORD: $(twinePassword)

0 comments on commit ce1a521

Please sign in to comment.