Skip to content

Commit

Permalink
[ci] Regenerate AOT binaries for every Android smoke test (#5815)
Browse files Browse the repository at this point in the history
  • Loading branch information
feisuzhu authored Aug 18, 2022
1 parent 921295b commit 19c0272
Show file tree
Hide file tree
Showing 6 changed files with 123 additions and 37 deletions.
11 changes: 10 additions & 1 deletion .github/workflows/scripts/aot-demo.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export TI_CI=1
function build-and-smoke-test-android-aot-demo {
pushd taichi
GIT_COMMIT=$(git rev-parse HEAD | cut -c1-7)
setup_python
popd

export TAICHI_REPO_DIR=$(pwd)/taichi
Expand All @@ -18,12 +19,20 @@ function build-and-smoke-test-android-aot-demo {

# Normally we checkout the master's commit Id: https://github.com/taichi-dev/taichi-aot-demo/commit/master
# As for why we need this explicit commit Id here, refer to: https://docs.taichi-lang.org/docs/master/contributor_guide#handle-special-ci-failures
cd taichi-aot-demo && git checkout 82aaecb9224ac24baf4abfdb5e94f1c6edb464c3 && cd -
pushd taichi-aot-demo
git checkout bd8fb7bf30a3494f4ecc671cd4d017b926afed10
popd

APP_ROOT=taichi-aot-demo/implicit_fem
ANDROID_APP_ROOT=$APP_ROOT/android
JNI_PATH=$ANDROID_APP_ROOT/app/src/main/jniLibs/arm64-v8a/

pip install /taichi-wheel/*.whl
pushd $APP_ROOT/python
sudo chmod 0777 $HOME/.cache
python implicit_fem.py --aot
popd

mkdir -p $JNI_PATH
cp taichi/build/libtaichi_export_core.so $JNI_PATH
cd $ANDROID_APP_ROOT
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/scripts/common-utils.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ setup_sccache() {
}

setup_python() {
if [[ "$IN_DOCKER" == "true" ]]; then
if [[ "$(check_in_docker)" == "true" ]]; then
source $HOME/miniconda/etc/profile.d/conda.sh
conda activate "$PY"
fi
Expand Down
42 changes: 42 additions & 0 deletions .github/workflows/scripts/unix-build-v2.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#!/bin/bash

# TODO: replace unix_build.sh
# currently only used in android build job
set -ex

. $(dirname $0)/common-utils.sh

IN_DOCKER=$(check_in_docker)
[[ "$IN_DOCKER" == "true" ]] && cd taichi

build_taichi_wheel() {
git fetch origin master --tags
PROJECT_TAGS=""
EXTRA_ARGS=""
if [ "$PROJECT_NAME" = "taichi-nightly" ]; then
PROJECT_TAGS="egg_info --tag-date"
fi

if [[ $OSTYPE == "linux-"* ]]; then
if [ -f /etc/centos-release ] ; then
EXTRA_ARGS="-p manylinux2014_x86_64"
else
EXTRA_ARGS="-p manylinux_2_27_x86_64"
fi
fi
python3 misc/make_changelog.py --ver origin/master --repo_dir ./ --save

export TAICHI_CMAKE_ARGS="${TAICHI_CMAKE_ARGS} -DTI_WITH_C_API=ON"
python3 setup.py $PROJECT_TAGS bdist_wheel $EXTRA_ARGS
sccache -s
}

setup-sccache-local
setup_python

build_taichi_wheel
NUM_WHL=$(ls dist/*.whl | wc -l)
if [ $NUM_WHL -ne 1 ]; then echo "ERROR: created more than 1 whl." && exit 1; fi

chmod -R 777 "$SCCACHE_DIR"
rm -f python/CHANGELOG.md
97 changes: 64 additions & 33 deletions .github/workflows/testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -405,7 +405,7 @@ jobs:
--gpus 'all,"capabilities=graphics,utility,display,video,compute"' \
-v /tmp/.X11-unix:/tmp/.X11-unix \
-e PY -e GPU_BUILD -e PROJECT_NAME -e TAICHI_CMAKE_ARGS -e DISPLAY \
registry.taichigraphics.com/taichidev-ubuntu18.04:v0.3.2 \
registry.taichigraphics.com/taichidev-ubuntu18.04:v0.3.3 \
/home/dev/taichi/.github/workflows/scripts/unix_build.sh
# A tarball is needed because sccache needs some permissions that only the file owner has.
# 1000 is the uid and gid of user "dev" in the container.
Expand Down Expand Up @@ -444,7 +444,7 @@ jobs:
-e TI_LITE_TEST \
-e TI_TEST_OFFLINE_CACHE \
-e DISPLAY -e PY -e GPU_TEST -e TI_WANTED_ARCHS -e TI_RUN_RELEASE_TESTS \
registry.taichigraphics.com/taichidev-ubuntu18.04:v0.3.2 \
registry.taichigraphics.com/taichidev-ubuntu18.04:v0.3.3 \
/home/dev/unix_test.sh
docker cp .github/workflows/scripts/unix_test.sh taichi_test:/home/dev/unix_test.sh
docker cp .github/workflows/scripts/common-utils.sh taichi_test:/home/dev/common-utils.sh
Expand Down Expand Up @@ -613,71 +613,102 @@ jobs:
contents: read
env:
REDIS_HOST: 172.16.5.8
PY: py39
steps:
- uses: actions/checkout@v2
name: Checkout taichi
with:
submodules: "recursive"

- name: Prepare Environment
run: >-
TAICHI_WHEEL_DIR=$(mktemp -d);
echo TAICHI_WHEEL_DIR=$TAICHI_WHEEL_DIR >> $GITHUB_ENV;
chmod 0777 $TAICHI_WHEEL_DIR;
echo DOCKER_RUN_ARGS="
-e PY
-e REDIS_HOST
-e TI_LITE_TEST
-e TAICHI_CMAKE_ARGS
-e SCCACHE_ROOT=/var/lib/sccache
-v $(pwd):/home/dev/taichi
-v $(readlink -f ~/sccache):/var/lib/sccache
-v $(readlink -f ~/git-cache):/var/lib/git-cache
-v $(readlink -f ~/build-cache)/pip:/home/dev/.cache/pip
-v $(readlink -f ~/build-cache)/dot-gradle:/home/dev/.gradle
-v $TAICHI_WHEEL_DIR:/taichi-wheel
" >> $GITHUB_ENV;
for i in {0..9}; do if xset -display ":$i" -q >/dev/null 2>&1; then break; fi; done;
if [ $? -ne 0 ]; then echo "No display!"; exit 1; fi;
echo DOCKER_RUN_GPU_ARGS="
--runtime=nvidia
-e DISPLAY=:$i
-e NVIDIA_VISIBLE_DEVICES=all
-e NVIDIA_DRIVER_CAPABILITIES=all
" >> $GITHUB_ENV;
mkdir -p ~/build-cache/pip; chmod 0777 ~/build-cache/pip;
mkdir -p ~/build-cache/dot-gradle; chmod 0777 ~/build-cache/dot-gradle;
mkdir -p ~/build-cache/pip; chmod 0777 ~/build-cache/pip;
- name: Build Host Taichi
run: |
docker rm -f taichi_build_host
docker run --user dev --name taichi_build_host \
$DOCKER_RUN_ARGS \
-v $TAICHI_WHEEL_DIR:/home/dev/taichi/dist \
registry.taichigraphics.com/taichidev-ubuntu18.04:v0.3.3 \
/home/dev/taichi/.github/workflows/scripts/unix-build-v2.sh
env:
TAICHI_CMAKE_ARGS: >-
-DTI_WITH_OPENGL:BOOL=ON
-DTI_WITH_CC:BOOL=OFF
-DTI_WITH_VULKAN:BOOL=ON
-DCMAKE_C_COMPILER_LAUNCHER=sccache
-DCMAKE_CXX_COMPILER_LAUNCHER=sccache
- name: Build For Android
run: |
git clean -fxd
docker rm taichi_build_android -f
mkdir -p ~/build-cache/pip; chmod 0777 ~/build-cache/pip
chown -R 1000:1000 .
docker run -i --user dev --name taichi_build_android \
-e SCCACHE_ROOT=/var/lib/sccache \
-e TI_LITE_TEST \
-v $(pwd):/home/dev/taichi \
-v $(readlink -f ~/sccache):/var/lib/sccache \
-v $(readlink -f ~/git-cache):/var/lib/git-cache \
-v $(readlink -f ~/build-cache)/pip:/home/dev/.cache/pip \
registry.taichigraphics.com/taichidev-androidsdk18.04:v0.0.5 \
$DOCKER_RUN_ARGS \
registry.taichigraphics.com/taichidev-androidsdk18.04:v0.0.6 \
/home/dev/taichi/.github/workflows/scripts/android-build.sh build-ext
- name: Test For Android AOT (export core)
run: |
docker rm taichi_test_android -f
mkdir -p ~/build-cache/dot-gradle; chmod 0777 ~/build-cache/dot-gradle
mkdir -p ~/build-cache/pip; chmod 0777 ~/build-cache/pip
chown -R 1000:1000 .
docker run -i --user dev --name taichi_test_android \
-e REDIS_HOST \
-e TI_LITE_TEST \
-v $(pwd):/home/dev/taichi \
-v $(readlink -f ~/build-cache)/pip:/home/dev/.cache/pip \
-v $(readlink -f ~/build-cache)/dot-gradle:/home/dev/.gradle \
registry.taichigraphics.com/taichidev-androidsdk18.04:v0.0.5 \
$DOCKER_RUN_ARGS \
$DOCKER_RUN_GPU_ARGS \
registry.taichigraphics.com/taichidev-androidsdk18.04:v0.0.6 \
/home/dev/taichi/.github/workflows/scripts/aot-demo.sh build-and-smoke-test-android-aot-demo
- name: Prepare Unity Build Environment
run: |
chown -R 1000:1000 .
docker run -i --rm --user dev \
-e TI_LITE_TEST \
-v $(pwd):/home/dev/taichi \
-v $(readlink -f ~/git-cache):/var/lib/git-cache \
-v $(readlink -f ~/build-cache)/pip:/home/dev/.cache/pip \
registry.taichigraphics.com/taichidev-androidsdk18.04:v0.0.5 \
$DOCKER_RUN_ARGS \
registry.taichigraphics.com/taichidev-androidsdk18.04:v0.0.6 \
/home/dev/taichi/.github/workflows/scripts/aot-demo.sh prepare-unity-build-env
- name: Build Taichi-UnityExample
run: |
docker run -i --rm --user dev \
-e TI_LITE_TEST \
-v $(pwd):/home/dev/taichi \
-v $(readlink -f ~/git-cache):/var/lib/git-cache \
-v $(readlink -f ~/build-cache)/pip:/home/dev/.cache/pip \
-v $(readlink -f ~/build-cache)/dot-gradle:/home/dev/.gradle \
$DOCKER_RUN_ARGS \
registry.taichigraphics.com/unityci-editor:ubuntu-2020.3.14f1-android-1-with-secret-sauce \
/home/dev/taichi/.github/workflows/scripts/aot-demo.sh build-unity-demo
- name: Run Taichi-UnityExample (C-API)
run: |
chown -R 1000:1000 .
docker run -i --rm --user dev \
-e TI_LITE_TEST \
-v $(pwd):/home/dev/taichi \
-v $(readlink -f ~/git-cache):/var/lib/git-cache \
-e REDIS_HOST \
registry.taichigraphics.com/taichidev-androidsdk18.04:v0.0.5 \
$DOCKER_RUN_ARGS \
registry.taichigraphics.com/taichidev-androidsdk18.04:v0.0.6 \
/home/dev/taichi/.github/workflows/scripts/aot-demo.sh smoke-test-unity-demo
2 changes: 1 addition & 1 deletion ci/Dockerfile.android-sdk.18.04
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM registry.taichigraphics.com/taichidev-ubuntu18.04:v0.3.1
FROM registry.taichigraphics.com/taichidev-ubuntu18.04:v0.3.3
ENV ANDROID_SDK_ROOT=/android-sdk
USER root
RUN mkdir /android-sdk && \
Expand Down
6 changes: 5 additions & 1 deletion ci/Dockerfile.ubuntu.18.04
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ RUN apt-get update && \
apt-get install -y software-properties-common && add-apt-repository -y ppa:git-core/ppa && apt-get update && \
apt-get install -y python3-pip \
libtinfo-dev \
sudo \
clang-10 \
wget \
git \
Expand Down Expand Up @@ -43,7 +44,10 @@ RUN apt-get update && \
libglfw3 \
libglfw3-dev \
libjpeg-dev \
libvulkan-dev
libvulkan-dev \
&& \
printf "root ALL=(ALL:ALL) NOPASSWD: ALL\ndev ALL=(ALL:ALL) NOPASSWD: ALL\n" > /etc/sudoers && \
true

# Install the latest version of CMAKE v3.20.5 from source
WORKDIR /
Expand Down

0 comments on commit 19c0272

Please sign in to comment.