Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Source scripts instead of just executing #13

Merged
merged 4 commits into from
Jul 20, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,7 @@ jobs:
with:
apt-dependencies: ''
codecov-token: ${{ secrets.CODECOV_TOKEN }}
script-before-cmake: before_cmake.sh
cmake-args: '-DBUILD_TESTING=1'
script-between-cmake-make: between_cmake_make.sh
script-after-make: after_make.sh
script-after-make-test: after_make_test.sh
```

### Dependencies
Expand All @@ -47,7 +43,15 @@ Create a secret on the repository with Codecov's token, called `CODECOV_TOKEN`.

### Custom scripts

The `script-`s are optional hooks that you can run at specific times of the build.
You can add optional scripts to be run at specific times of the build:

* `.github/ci-bionic/before_cmake.sh`: Runs before the `cmake` call
* `.github/ci-bionic/between_cmake_make.sh`: Runs after the `cmake` and before `make`
* `.github/ci-bionic/after_make.sh`: Runs after `make` and before `make test`
* `.github/ci-bionic/after_make_test.sh`: Runs after `make test`

All scripts are sourced inside the build folder. Be sure to move back to the
build folder before exiting the script.

### Custom CMake Arguments

Expand Down
20 changes: 0 additions & 20 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,34 +13,14 @@ inputs:
description: 'Token to upload to Codecov'
required: false
default: ''
script-before-cmake:
description: 'Bash script to be run before cmake inside the build folder'
required: false
default: ''
cmake-args:
description: 'Additional CMake arguments to use when building package under test'
required: false
default: ''
script-between-cmake-make:
description: 'Bash script to be run after cmake and before make inside the build folder'
required: false
default: ''
script-after-make:
description: 'Bash script to be run after make and before make test inside the build folder'
required: false
default: ''
script-after-make-test:
description: 'Bash script to be run after make test inside the build folder'
required: false
default: ''
runs:
using: 'docker'
image: 'Dockerfile'
args:
- ${{ inputs.apt-dependencies }}
- ${{ inputs.codecov-token }}
- ${{ inputs.script-before-cmake }}
- ${{ inputs.cmake-args }}
- ${{ inputs.script-between-cmake-make }}
- ${{ inputs.script-after-make }}
- ${{ inputs.script-after-make-test }}
39 changes: 21 additions & 18 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@ set -e

APT_DEPENDENCIES=$1
CODECOV_TOKEN=$2
SCRIPT_BEFORE_CMAKE=$3
CMAKE_ARGS=$4
SCRIPT_BETWEEN_CMAKE_MAKE=$5
SCRIPT_AFTER_MAKE=$6
SCRIPT_AFTER_MAKE_TEST=$7
CMAKE_ARGS=$3

SOURCE_DEPENDENCIES=".github/ci-bionic/dependencies.yaml"
SCRIPT_BEFORE_CMAKE="../.github/ci-bionic/before_cmake.sh"
chapulina marked this conversation as resolved.
Show resolved Hide resolved
SCRIPT_BETWEEN_CMAKE_MAKE="../.github/ci-bionic/between_cmake_make.sh"
SCRIPT_AFTER_MAKE="../.github/ci-bionic/after_make.sh"
SCRIPT_AFTER_MAKE_TEST="../.github/ci-bionic/after_make_test.sh"

cd $GITHUB_WORKSPACE

Expand Down Expand Up @@ -42,7 +44,8 @@ cd ..

sh tools/code_check.sh

if [ -f ".github/ci-bionic/dependencies.yaml" ] ; then
echo ::group::Dependencies from source
if [ -f "$SOURCE_DEPENDENCIES" ] ; then
mkdir -p deps/src
cd deps
vcs import src < ../.github/ci-bionic/dependencies.yaml
Expand All @@ -54,9 +57,9 @@ fi
mkdir build
cd build

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

if [ ! -z "$CODECOV_TOKEN" ] ; then
Expand All @@ -65,24 +68,24 @@ else
cmake .. $CMAKE_ARGS
fi

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

make

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

export CTEST_OUTPUT_ON_FAILURE=1
make test

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

if [ ! -z "$CODECOV_TOKEN" ] ; then
Expand Down