From 64532d064afbf890ba9c7d8edec5b2a012356184 Mon Sep 17 00:00:00 2001 From: Adrian Stanea Date: Fri, 20 Oct 2023 16:50:09 +0300 Subject: [PATCH] ci: restructure CI scripts - delete travis uses Signed-off-by: Adrian Stanea --- CI/doxygen.sh | 63 ++++++++++++++++++++++++++++++++++++ CI/macOS/install_deps | 32 ++++++++++++++++++ CI/macOS/make_macOS | 17 ++++++++++ CI/ubuntu/install_deps | 73 ++++++++++++++++++++++++++++++++++++++++++ CI/ubuntu/make_linux | 39 ++++++++++++++++++++++ azure-pipelines.yml | 8 ++--- 6 files changed, 228 insertions(+), 4 deletions(-) create mode 100755 CI/doxygen.sh create mode 100755 CI/macOS/install_deps create mode 100755 CI/macOS/make_macOS create mode 100755 CI/ubuntu/install_deps create mode 100755 CI/ubuntu/make_linux diff --git a/CI/doxygen.sh b/CI/doxygen.sh new file mode 100755 index 00000000..5e66a5dc --- /dev/null +++ b/CI/doxygen.sh @@ -0,0 +1,63 @@ +#!/bin/bash + +TOP_DIR=$(pwd) + +echo_red() { printf "\033[1;31m$*\033[m\n"; } +echo_green() { printf "\033[1;32m$*\033[m\n"; } + +############################################################################ +# Check if the documentation will be generated w/o warnings or errors +############################################################################ +pushd ${TOP_DIR}/build +(cd doc && ! make doc 2>&1 | grep -E "warning|error") || { + echo_red "Documentation incomplete or errors in the generation of it have occured!" + exit 1 +} + +echo_green "Documentation was generated successfully!" + +############################################################################ +# If the current build is not a pull request and it is on master the +# documentation will be pushed to the gh-pages branch +############################################################################ +if [[ "${IS_PULL_REQUEST}" == "False" && "${BRANCH_NAME}" == "master" ]] +then + echo_green "Running Github docs update on commit '$CURRENT_COMMIT'" + git config --global user.email "cse-ci-notifications@analog.com" + git config --global user.name "CSE-CI" + + pushd ${TOP_DIR} + git fetch --depth 1 origin +refs/heads/gh-pages:gh-pages + git checkout gh-pages + mkdir -p ${TOP_DIR}/python + + cp -R ${TOP_DIR}/build/doc/doxygen_doc/html/* ${TOP_DIR} + cp -R ${TOP_DIR}/build/doc/doxygen_doc/python/* ${TOP_DIR}/python + + sudo rm -rf ${TOP_DIR}/doc + sudo rm -rf ${TOP_DIR}/glog + sudo rm -rf ${TOP_DIR}/build + + # Need to create a .nojekyll file to allow filenames starting with an underscore + # to be seen on the gh-pages site. Therefore creating an empty .nojekyll file. + if [ ! -f ".nojekyll" ] ; then + touch .nojekyll + fi + + GH_CURRENT_COMMIT=$(git log -1 --pretty=%B) + if [[ ${GH_CURRENT_COMMIT:(-7)} != ${CURRENT_COMMIT:0:7} ]] + then + git add --all . + git commit --allow-empty --amend -m "Update documentation to ${CURRENT_COMMIT:0:7}" + if [ -n "$GITHUB_DOC_TOKEN" ] ; then + git push https://${GITHUB_DOC_TOKEN}@github.com/${REPO_SLUG} gh-pages -f + else + git push origin gh-pages -f + fi + echo_green "Documentation updated!" + else + echo_green "Documentation already up to date!" + fi +else + echo_green "Documentation will be updated when this commit gets on master!" +fi diff --git a/CI/macOS/install_deps b/CI/macOS/install_deps new file mode 100755 index 00000000..3f5e704d --- /dev/null +++ b/CI/macOS/install_deps @@ -0,0 +1,32 @@ +#!/bin/sh -e + +TOP_DIR=$(pwd) +LIBIIO_VERSION=libiio-v0 + +# Note: not installing 'mono', it comes with Azure images, +# but it doesn't look it's installed with Homebrew +brew_install_if_not_exists cmake doxygen libusb libxml2 swig curl python +# libiio deps +brew_install_if_not_exists doxygen libusb libxml2 ncurses cdk libserialport sphinx-doc pkg-config +pip3 install sphinx + +pip3 install wheel twine build virtualenv + +# Install glog +echo "Building glog" +cd ${TOP_DIR} +git clone --branch v0.4.0 --depth 1 https://github.com/google/glog +mkdir -p glog/build_0_4_0 && cd glog/build_0_4_0 +cmake .. +make +sudo make install + +# Install libiio +echo "Building libiio - version $LIBIIO_VERSION" +cd ${TOP_DIR} +git clone https://github.com/analogdevicesinc/libiio.git -b $LIBIIO_VERSION libiio +mkdir ./libiio/build && cd ./libiio/build +cmake ../ +make +sudo make install + diff --git a/CI/macOS/make_macOS b/CI/macOS/make_macOS new file mode 100755 index 00000000..31a1865d --- /dev/null +++ b/CI/macOS/make_macOS @@ -0,0 +1,17 @@ +#!/bin/sh -e + +TOP_DIR=$(pwd) + +mkdir -p build +mkdir -p build_tar +export MACOSX_DEPLOYMENT_TARGET=10.15 + +cd build +cmake -DOSX_PACKAGE=ON -DENABLE_TOOLS=ON -DENABLE_PYTHON=ON -DENABLE_CSHARP=ON -DENABLE_LOG=ON -DBUILD_EXAMPLES=ON .. +make +ls + +cd ${TOP_DIR}/build_tar +cmake -DOSX_PACKAGE=OFF -DENABLE_PACKAGING=ON -DENABLE_PYTHON=ON -DENABLE_CSHARP=ON -DENABLE_TOOLS=ON -DENABLE_LOG=ON -DBUILD_EXAMPLES=ON .. +make && make package +ls diff --git a/CI/ubuntu/install_deps b/CI/ubuntu/install_deps new file mode 100755 index 00000000..39a0fe89 --- /dev/null +++ b/CI/ubuntu/install_deps @@ -0,0 +1,73 @@ +#!/bin/sh -e + +TOP_DIR=$(pwd) +LIBIIO_VERSION=libiio-v0 + +handle_default() { + sudo apt-get -qq update + echo "libm2k packages" + sudo DEBIAN_FRONTEND=noninteractive apt-get install -y cmake doxygen graphviz \ + libaio-dev libavahi-client-dev libavahi-common-dev libusb-1.0-0-dev \ + libxml2-dev rpm tar bzip2 gzip flex bison git curl \ + python3-dev python3-setuptools python3-pip python3-all \ + debhelper devscripts fakeroot libserialport-dev swig dh-python + + # libiio dependencies + sudo DEBIAN_FRONTEND=noninteractive apt-get install -y \ + libxml2-dev bison flex libcdk5-dev cmake \ + libaio-dev libusb-1.0-0-dev \ + libserialport-dev libavahi-client-dev + + #Install glog + cd ${TOP_DIR} + git clone --branch v0.4.0 --depth 1 https://github.com/google/glog + mkdir -p glog/build_0_4_0 && cd glog/build_0_4_0 + cmake -DCMAKE_PREFIX_PATH=/usr .. + make + sudo make install + sudo pip3 install --upgrade pip stdeb argparse + + # Install libiio + echo "Building libiio - version $LIBIIO_VERSION" + cd ${TOP_DIR} + git clone https://github.com/analogdevicesinc/libiio.git -b $LIBIIO_VERSION libiio + mkdir ./libiio/build && cd ./libiio/build + cmake ../ + make + sudo make install +} + +handle_doxygen() { + # TODO: REVIE THIS AFTER THE REWORK - IT MIGHT BREAK + # Install a recent version of doxygen + DOXYGEN_URL="wget https://sourceforge.net/projects/doxygen/files/rel-1.8.15/doxygen-1.8.15.src.tar.gz" + cd ${DEPS_DIR} + [ -d "doxygen" ] || { + mkdir doxygen && wget --quiet -O - ${DOXYGEN_URL} | tar --strip-components=1 -xz -C doxygen + } + cd doxygen + mkdir -p build && cd build + cmake .. + make -j${NUM_JOBS} + sudo make install + cd .. + cd .. + + cd ${TOP_DIR}/doc + mkdir -p build && cd build + cmake .. + cd .. + cd .. + + handle_default + cd ${TOP_DIR} + #Also install Sphinx for Python bindings + sudo apt-get install python3-sphinx + sudo pip3 install --upgrade sphinx_rtd_theme +} + +handle_ubuntu_docker() { + handle_default +} + +handle_${OS_TYPE} diff --git a/CI/ubuntu/make_linux b/CI/ubuntu/make_linux new file mode 100755 index 00000000..bd8d8170 --- /dev/null +++ b/CI/ubuntu/make_linux @@ -0,0 +1,39 @@ +#!/bin/sh -e + +TOP_DIR=$(pwd) + +handle_default() { + mkdir -p build + cd build + + #create deb for bindings + cmake -DENABLE_PYTHON=ON -DENABLE_TOOLS=ON -DENABLE_CSHARP=OFF -DENABLE_LOG=ON -DBUILD_EXAMPLES=ON .. && make + sudo python3 setup.py --command-packages=stdeb.command sdist_dsc + cd "$(find . -type d -name "debian" | head -n 1)" + sudo env DEB_BUILD_OPTIONS=nocheck debuild -us -uc + cp ../../*.deb ${TOP_DIR}/build/ + cd ${TOP_DIR}/build/ + #remove the tar.gz for bindings + sudo rm *.tar.gz + + #create simple .deb without Python bindings + cmake -DENABLE_PACKAGING=ON -DDEB_DETECT_DEPENDENCIES=ON -DENABLE_PYTHON=OFF -DENABLE_CSHARP=ON -DENABLE_TOOLS=ON -DENABLE_LOG=ON -DCMAKE_INSTALL_PREFIX=/usr -DBUILD_EXAMPLES=ON .. + make && make package + ls +} + +handle_doxygen() { + mkdir -p build + cd build + cmake -DENABLE_PYTHON=ON -DENABLE_CSHARP=OFF -DENABLE_DOC=ON .. + make && sudo make install + make doc + cd .. + ./CI/doxygen.sh +} + +handle_ubuntu_docker() { + handle_default +} + +handle_${BUILD_TYPE} \ No newline at end of file diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 05494d3f..bda2274b 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -60,9 +60,9 @@ jobs: fetchDepth: 1 clean: true persistCredentials: true - - script: ./CI/travis/before_install_linux + - script: ./CI/ubuntu/install_deps displayName: "Install Dependencies" - - script: ./CI/travis/make_linux + - script: ./CI/ubuntu/make_linux displayName: "Build" - task: CopyFiles@2 condition: ne(variables['System.JobName'], 'deploy_doxygen') @@ -112,10 +112,10 @@ jobs: - checkout: self fetchDepth: 1 clean: true - - script: ./CI/travis/before_install_darwin + - script: ./CI/macOS/install_deps displayName: "Install Dependencies" condition: ne(variables['agentName'],'macOS_arm64') - - script: ./CI/travis/make_darwin + - script: ./CI/macOS/make_macOS displayName: "Build" - ${{ each pyVersion in parameters.pythonVersions }}: - task: UsePythonVersion@0