Skip to content

Commit

Permalink
ci: restructure CI scripts - delete travis uses
Browse files Browse the repository at this point in the history
Signed-off-by: Adrian Stanea <[email protected]>
  • Loading branch information
Adrian-Stanea committed Oct 20, 2023
1 parent baf3be3 commit 64532d0
Show file tree
Hide file tree
Showing 6 changed files with 228 additions and 4 deletions.
63 changes: 63 additions & 0 deletions CI/doxygen.sh
Original file line number Diff line number Diff line change
@@ -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 "[email protected]"
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
32 changes: 32 additions & 0 deletions CI/macOS/install_deps
Original file line number Diff line number Diff line change
@@ -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

17 changes: 17 additions & 0 deletions CI/macOS/make_macOS
Original file line number Diff line number Diff line change
@@ -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
73 changes: 73 additions & 0 deletions CI/ubuntu/install_deps
Original file line number Diff line number Diff line change
@@ -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}
39 changes: 39 additions & 0 deletions CI/ubuntu/make_linux
Original file line number Diff line number Diff line change
@@ -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}
8 changes: 4 additions & 4 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 64532d0

Please sign in to comment.