Skip to content

Commit

Permalink
Support apt dependencies in a file (#15)
Browse files Browse the repository at this point in the history
Signed-off-by: Louise Poubel <louise@openrobotics.org>
  • Loading branch information
chapulina authored Jul 29, 2020
1 parent c287b9a commit 9e2cb44
Show file tree
Hide file tree
Showing 2 changed files with 70 additions and 46 deletions.
15 changes: 13 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,25 @@ jobs:
id: ci
uses: ignition-tooling/ubuntu-bionic-ci-action@v1
with:
apt-dependencies: ''
codecov-token: ${{ secrets.CODECOV_TOKEN }}
cmake-args: '-DBUILD_TESTING=1'
```

### Dependencies

Be sure to put all apt-installable dependencies into `apt-dependencies`.
#### APT dependencies

Be sure to declare all apt-installable dependencies in the following files, one
package per line.

* `.github/ci/packages.apt` : Installed for all versions.
* `.github/ci/packages-<ubuntu version>.apt` : where `<ubuntu version>` can be
bionic, focal, etc. Use these if you need to install different dependencies
according to the distribution.

> The `apt-dependencies` input is deprecated.
#### Source dependencies

If you need to install dependencies from source, add a Vcstool yaml file to
`.github/ci-bionic/dependencies.yaml`. Dependencies will be built using
Expand Down
101 changes: 57 additions & 44 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,33 @@
set -x
set -e

APT_DEPENDENCIES=$1
OLD_APT_DEPENDENCIES=$1
CODECOV_TOKEN=$2
CMAKE_ARGS=$3

SOURCE_DEPENDENCIES="`pwd`/.github/ci-bionic/dependencies.yaml"
SCRIPT_BEFORE_CMAKE="`pwd`/.github/ci-bionic/before_cmake.sh"
SCRIPT_BETWEEN_CMAKE_MAKE="`pwd`/.github/ci-bionic/between_cmake_make.sh"
SCRIPT_AFTER_MAKE="`pwd`/.github/ci-bionic/after_make.sh"
SCRIPT_AFTER_MAKE_TEST="`pwd`/.github/ci-bionic/after_make_test.sh"

cd "$GITHUB_WORKSPACE"

echo ::group::Dependencies from binaries
apt update
echo ::group::Install tools: apt
apt update 2>&1
apt -y install \
wget \
lsb-release \
gnupg \
build-essential \
cmake \
cppcheck \
curl \
g++-8 \
git \
python3-pip
gnupg \
lsb-release \
python3-pip \
wget

UBUNTU_VERSION=`lsb_release -cs`

SOURCE_DEPENDENCIES="`pwd`/.github/ci-$UBUNTU_VERSION/dependencies.yaml"
SCRIPT_BEFORE_CMAKE="`pwd`/.github/ci-$UBUNTU_VERSION/before_cmake.sh"
SCRIPT_BETWEEN_CMAKE_MAKE="`pwd`/.github/ci-$UBUNTU_VERSION/between_cmake_make.sh"
SCRIPT_AFTER_MAKE="`pwd`/.github/ci-$UBUNTU_VERSION/after_make.sh"
SCRIPT_AFTER_MAKE_TEST="`pwd`/.github/ci-$UBUNTU_VERSION/after_make_test.sh"

# Infer package name from GITHUB_REPOSITORY
PACKAGE=$(echo "$GITHUB_REPOSITORY" | sed 's:.*/::' | sed 's:ign-:ignition-:')
Expand All @@ -34,57 +41,63 @@ pip3 install -r /tmp/gzdev/requirements.txt
/tmp/gzdev/gzdev.py \
repository enable --project="${PACKAGE}${PACKAGE_MAJOR_VERSION}"

apt-get update
apt -y install \
cmake \
build-essential \
curl \
g++-8 \
git \
cppcheck \
python3-pip \
$APT_DEPENDENCIES
apt-get update 2>&1
echo ::endgroup::

echo ::group::Install tools: pip
pip3 install -U pip vcstool colcon-common-extensions
echo ::endgroup::

echo ::group::Install tools: source
git clone https://github.com/linux-test-project/lcov.git -b v1.14 2>&1
cd lcov
make install
cd ..
echo ::endgroup::

echo ::group::GCC 8
update-alternatives \
--install /usr/bin/gcc gcc /usr/bin/gcc-8 800 \
--slave /usr/bin/g++ g++ /usr/bin/g++-8 \
--slave /usr/bin/gcov gcov /usr/bin/gcov-8
echo ::endgroup::

echo ::group::Install LCOV
git clone https://github.com/linux-test-project/lcov.git -b v1.14 2>&1
cd lcov
make install
cd ..
echo ::endgroup::
if [ -f "$SOURCE_DEPENDENCIES" ] ; then
echo ::group::Fetch source dependencies
mkdir -p deps/src
vcs import deps/src < ../.github/ci-$UBUNTU_VERSION/dependencies.yaml
echo ::endgroup::
fi

echo ::group::Code check
sh tools/code_check.sh 2>&1
echo ::group::Install dependencies from binaries
apt -y install \
$OLD_APT_DEPENDENCIES \
$(sort -u $(find . -iname 'packages-'$UBUNTU_VERSION'.apt' -o -iname 'packages.apt') | tr '\n' ' ')
echo ::endgroup::

echo ::group::Dependencies from source
if [ -f "$SOURCE_DEPENDENCIES" ] ; then
mkdir -p deps/src
echo ::group::Compile dependencies from source
cd deps
vcs import src < ../.github/ci-bionic/dependencies.yaml
colcon build --symlink-install --merge-install --cmake-args -DBUILD_TESTING=false
. install/setup.sh
cd ..
echo ::endgroup::
fi

echo ::group::Code check
sh tools/code_check.sh 2>&1
echo ::endgroup::

echo ::group::Build folder
mkdir build
cd build
echo ::endgroup::

echo ::group::Script before cmake
if [ -f "$SCRIPT_BEFORE_CMAKE" ] ; then
echo ::group::Script before cmake
. $SCRIPT_BEFORE_CMAKE
echo ::endgroup::
fi
echo ::endgroup::

echo ::group::cmake
if [ ! -z "$CODECOV_TOKEN" ] ; then
Expand All @@ -94,40 +107,40 @@ else
fi
echo ::endgroup::

echo ::group::Script between cmake and make
if [ -f "$SCRIPT_BETWEEN_CMAKE_MAKE" ] ; then
echo ::group::Script between cmake and make
. $SCRIPT_BETWEEN_CMAKE_MAKE 2>&1
echo ::endgroup::
fi
echo ::endgroup::

echo ::group::make
make
echo ::endgroup::

echo ::group::Script after make
if [ -f "$SCRIPT_AFTER_MAKE" ] ; then
echo ::group::Script after make
. $SCRIPT_AFTER_MAKE 2>&1
echo ::endgroup::
fi
echo ::endgroup::

echo ::group::make test
export CTEST_OUTPUT_ON_FAILURE=1
make test
echo ::endgroup::

echo ::group::Script after make test
if [ -f "$SCRIPT_AFTER_MAKE_TEST" ] ; then
echo ::group::Script after make test
. $SCRIPT_AFTER_MAKE_TEST 2>&1
echo ::endgroup::
fi
echo ::endgroup::

echo ::group::codecov
if [ ! -z "$CODECOV_TOKEN" ] ; then
echo ::group::codecov
make coverage VERBOSE=1

curl -s https://codecov.io/bash > codecov.sh

# disable gcov output with `-X gcovout -X gcov`
bash codecov.sh -t $CODECOV_TOKEN -X gcovout -X gcov
echo ::endgroup::
fi
echo ::endgroup::

0 comments on commit 9e2cb44

Please sign in to comment.