Browse Source

ci: add github action

tags/v0.4.0
luzzyzhang Xinran Xu 5 years ago
parent
commit
96742c19ae
6 changed files with 148 additions and 0 deletions
  1. +25
    -0
      .github/workflows/ci-cpu.yml
  2. +37
    -0
      ci/cmake.sh
  3. +39
    -0
      ci/docker_env/Dockerfile
  4. +24
    -0
      ci/run_cpp_test.sh
  5. +16
    -0
      ci/run_python_test.sh
  6. +7
    -0
      ci/utils.sh

+ 25
- 0
.github/workflows/ci-cpu.yml View File

@@ -0,0 +1,25 @@
name: CI CPU

on:
push:
branches: [master]
pull_request:

jobs:
cpu-test:
runs-on: self-hosted
container:
image: localhost:5000/megengine-ci:latest
steps:
- name: Checkout MegEngine
uses: actions/checkout@v2
- name: Checkout submodules
run: |
./third_party/prepare.sh
./third_party/install-mkl.sh
- name: Build MegEngine
run: ./ci/cmake.sh cpu
- name: Python test
run: ./ci/run_python_test.sh
- name: C++ test
run: ./ci/run_cpp_test.sh cpu

+ 37
- 0
ci/cmake.sh View File

@@ -0,0 +1,37 @@
#!/bin/bash

set -e

BASEDIR=$(readlink -f "$(dirname "$0")"/..)

source "${BASEDIR}/ci/utils.sh"

if [[ "$1" == cpu ]]; then
DMGE_WITH_DISTRIBUTED=OFF
DMGE_WITH_CUDA=OFF
elif [[ "$1" == cuda ]]; then
DMGE_WITH_DISTRIBUTED=ON
DMGE_WITH_CUDA=ON
else
log "Argument must cpu or cuda"
exit 1
fi


function build() {
log "Start to build"
local build_dir="/tmp/build/${1}"
mkdir -p "$build_dir"
pushd ${build_dir} >/dev/null
cmake -S "${BASEDIR}" -B "${build_dir}" \
-DMGE_WITH_DISTRIBUTED=${DMGE_WITH_DISTRIBUTED} \
-DMGE_WITH_CUDA=${DMGE_WITH_CUDA} \
-DMGE_WITH_TEST=ON \
-DCMAKE_BUILD_TYPE=RelWithDebInfo
make -j$(($(nproc) * 2)) -I ${build_dir}
make develop
popd >/dev/null
log "End build: $(ls ${build_dir})"
}

build "$@"

+ 39
- 0
ci/docker_env/Dockerfile View File

@@ -0,0 +1,39 @@
FROM nvidia/cuda:10.1-devel-ubuntu18.04
RUN rm /etc/apt/sources.list.d/cuda.list

RUN apt-get update && apt-get install -y --no-install-recommends \
autoconf \
autotools-dev \
automake \
clang-6.0 \
curl \
git-lfs \
libtool \
libpcre3-dev \
llvm-6.0-dev \
openssh-client \
openssh-server \
pkg-config \
python-pip \
python3-pip \
python3-dev \
python-numpy \
python3-numpy \
python3-setuptools \
software-properties-common \
swig \
vim \
wget \
zlib1g-dev \
# GitLab Runner need Git 2.18 or higher to create a local Git repository
&& add-apt-repository ppa:git-core/ppa -y && apt-get install --no-install-recommends -y git \
&& rm -rf /var/lib/apt/lists/*

RUN cd /tmp ; wget https://cmake.org/files/v3.14/cmake-3.14.4.tar.gz;tar -xzvf cmake-3.14.4.tar.gz;cd cmake-3.14.4;./configure; make -j32; make install

RUN git lfs install

ENV PATH=${PATH}:/usr/local/cuda/bin \
LIBRARY_PATH=${LIBRARY_PATH}:/usr/local/cuda/lib:/usr/local/cuda/lib64:/usr/local/cuda/lib/stubs:/usr/local/cuda/lib64/stubs:/usr/local/cuda-10.1-libs/cudnn-v7.6.0/lib:/usr/local/cuda-10.1-libs/cudnn-v7.6.0/lib64:/usr/local/cuda-10.1-libs/TensorRT-5.1.5.0/lib:/usr/local/cuda-10.1-libs/TensorRT-5.1.5.0/lib64 \
LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:/usr/local/nvidia/lib:/usr/local/nvidia/lib64:/usr/local/cuda/lib:/usr/local/cuda/lib64:/usr/local/cuda/lib/stubs:/usr/local/cuda/lib64/stubs:/usr/local/cuda-10.1-libs/cudnn-v7.6.0/lib:/usr/local/cuda-10.1-libs/cudnn-v7.6.0/lib64:/usr/local/cuda-10.1-libs/TensorRT-5.1.5.0/lib:/usr/local/cuda-10.1-libs/TensorRT-5.1.5.0/lib64:/usr/local/cuda/lib64/stubs/libcuda.so:/tmp/build/cuda/dnn/cuda-stub/libcuda.so.1 \
CPATH=${CPATH}:/usr/local/cuda/include:/usr/local/cuda-10.1-libs/cudnn-v7.6.0/include:/usr/local/cuda-10.1-libs/TensorRT-5.1.5.0/include

+ 24
- 0
ci/run_cpp_test.sh View File

@@ -0,0 +1,24 @@
#!/bin/bash

set -e

BASEDIR=$(readlink -f "$(dirname "$0")"/..)
source "${BASEDIR}/ci/utils.sh"

export MGB_TEST_NO_LOG=1
export MGB_STABLE_RNG=1

function cpp_test {
pushd /tmp/build/"${1}" >/dev/null
./dnn/test/megdnn_test
./test/megbrain_test
popd >/dev/null
}


if [[ "$1" != "cpu" && "$1" != "cuda" ]] ; then
echo "Argument must cpu or cuda"
exit 1
fi

cpp_test "$@"

+ 16
- 0
ci/run_python_test.sh View File

@@ -0,0 +1,16 @@
#!/bin/bash

set -e


BASEDIR=$(readlink -f "$(dirname "$0")"/..)

function python_test() {
pushd "${BASEDIR}"/python_module >/dev/null
pip3 install -e '.[ci]'
export PYTHONPATH=.
./test/run.sh
popd >/dev/null
}

python_test

+ 7
- 0
ci/utils.sh View File

@@ -0,0 +1,7 @@
#!/bin/bash -e


function log() {
d=$(date +'%Y-%m-%d %H:%M:%S')
echo $d" "$1
}

Loading…
Cancel
Save