Skip to content

Commit

Permalink
Split CI workflow jobs (#872)
Browse files Browse the repository at this point in the history
Authored by r9-pena.  Splits workflow into multiple pieces for efficiency.
  • Loading branch information
r9-pena authored Jul 27, 2021
1 parent 48dec2b commit 764194a
Show file tree
Hide file tree
Showing 11 changed files with 200 additions and 95 deletions.
1 change: 0 additions & 1 deletion .github/actions/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,3 @@ USER fprime

# Code file to execute when the docker container starts up (`entrypoint.sh`)
ENTRYPOINT ["/entrypoint.sh"]

7 changes: 4 additions & 3 deletions .github/actions/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@
set -e
set -x
cd "$GITHUB_WORKSPACE"
if [ "$GITHUB_WORKFLOW" != "Autodocs" ]
if [ "$GITHUB_WORKFLOW" == "Autodocs" ]
then
"$GITHUB_WORKSPACE/ci/master.bash" QUICK
else
/autodoc.bash
else
#echo "$INPUT_TEST1"
"$GITHUB_WORKSPACE/ci/master.bash" $INPUT_TEST
fi
7 changes: 7 additions & 0 deletions .github/actions/github-ci-action.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
name: 'F prime CI'
description: 'Runs continuous integration testing on F prime'
inputs:
test:
description: Test number to run
required: true
default: ''
runs:
using: 'docker'
image: 'Dockerfile'
args:
- ${{ inputs.test }}
77 changes: 74 additions & 3 deletions .github/workflows/build-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ on:

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "build"
build:
# This workflow contains 4 jobs. One for every CI test."
Framework:
# The type of runner that the job will run on
runs-on: ubuntu-latest

Expand All @@ -25,11 +25,82 @@ jobs:
- name: F prime CI step
uses: ./.github/actions/
id: github-ci-action
with:
test: Framework
# Archive the outputs
- name: 'Archive Logs'
uses: actions/upload-artifact@v2
if: always()
with:
name: ci-framework-logs
path: ci-logs.tar.gz
retention-days: 5

Ref:
# The type of runner that the job will run on
runs-on: ubuntu-latest

# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v2
# Runs the CI action internal to the repository
- name: F prime CI step
uses: ./.github/actions/
id: github-ci-action
with:
test: 'Ref'
# Archive the outputs
- name: 'Archive Logs'
uses: actions/upload-artifact@v2
if: always()
with:
name: ci-ref-logs
path: ci-logs.tar.gz
retention-days: 5

RPI:
# The type of runner that the job will run on
runs-on: ubuntu-latest

# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v2
# Runs the CI action internal to the repository
- name: F prime CI step
uses: ./.github/actions/
id: github-ci-action
with:
test: 'RPI'
# Archive the outputs
- name: 'Archive Logs'
uses: actions/upload-artifact@v2
if: always()
with:
name: ci-logs
name: ci-rpi-logs
path: ci-logs.tar.gz
retention-days: 5

Integration:
# The type of runner that the job will run on
runs-on: ubuntu-latest

# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v2
# Runs the CI action internal to the repository
- name: F prime CI step
uses: ./.github/actions/
id: github-ci-action
with:
test: '30-ints'
# Archive the outputs
- name: 'Archive Logs'
uses: actions/upload-artifact@v2
if: always()
with:
name: ci-int-logs
path: ci-logs.tar.gz
retention-days: 5
33 changes: 9 additions & 24 deletions ci/master.bash
Original file line number Diff line number Diff line change
Expand Up @@ -4,38 +4,23 @@
#
# Master script to run the CI process. This will setup and run the tests for the CI system.
####

export CTEST_OUTPUT_ON_FAILURE=1
export SCRIPT_DIR="$(dirname ${BASH_SOURCE})"
. "${SCRIPT_DIR}/helpers.bash"

TESTS="${@}"
export TEST_TYPE="FULL"
if (( $# == 0 )) || [[ "${TESTS}" == "FULL" ]]
then
TESTS="$(ls "${SCRIPT_DIR}/tests"/*)"
elif [[ "${TESTS}" == "QUICK" ]]
then
TESTS="${SCRIPT_DIR}/tests/20-fputil.bash ${SCRIPT_DIR}/tests/30-ints.bash"
export TEST_TYPE="QUICK"
elif [[ "${TESTS}" == "STATIC" ]]
then
TESTS="${SCRIPT_DIR}/tests/40-pylama.bash"
export TEST_TYPE="STATIC"
fi
export TEST="${@}"
TEST_RUN="${SCRIPT_DIR}/tests/${TEST}.bash"
export TEST_TYPE="${TEST}"

#### NEEDED ENVIRONMENT ####
export FPRIME_DIR="$(cd ${SCRIPT_DIR}/..; pwd)"
export LOG_DIR="${FPRIME_DIR}/ci-logs-$(date +"%Y-%m-%dT%H%M%S")"
export LOG_DIR="${FPRIME_DIR}/ci-${TEST}-logs-$(date +"%Y-%m-%dT%H%M%S")"
mkdir -p "${LOG_DIR}"

. "${SCRIPT_DIR}/bootstrap.bash"
# Run the test script
echo -e "${BLUE}Starting CI test ${TEST_RUN} ${TEST}${NOCOLOR}"
/usr/bin/time "${TEST_RUN}" || fail_and_stop "${TEST} failed"
echo -e "${GREEN}CI test ${TEST_RUN} ${TEST} SUCCESSFUL${NOCOLOR}"

# Loop through all scripts in tests directory and run them
for test_script in ${TESTS}
do
"${SCRIPT_DIR}/clean.bash" || fail_and_stop "Cleaning directory"
echo -e "${BLUE}Starting CI test ${test_script}${NOCOLOR}"
/usr/bin/time "${test_script}" || fail_and_stop "${test_script} failed"
echo -e "${GREEN}CI test ${test_script} SUCCESSFUL${NOCOLOR}"
done
archive_logs
39 changes: 0 additions & 39 deletions ci/tests/20-fputil.bash

This file was deleted.

13 changes: 7 additions & 6 deletions ci/tests/30-ints.bash
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@
#
# Integration tests for CI
####
# Directory to be used for Integration CI test
export FPUTIL_DEPLOYS="${FPRIME_DIR}/Ref"

export SCRIPT_DIR="$(dirname ${BASH_SOURCE})/.."
. "${SCRIPT_DIR}/helpers.bash"

. ${SCRIPT_DIR}/tests/fputil.bash
# Loop over deployments and targets
for deployment in ${INT_DEPLOYS}
do
echo -e "${BLUE}Testing ${deployment} against integration tests${NOCOLOR}"
integration_test "${deployment}"
done

# Run integration tests
echo -e "${BLUE}Testing ${INT_DEPLOYS} against integration tests${NOCOLOR}"
integration_test "${FPUTIL_DEPLOYS}"
24 changes: 24 additions & 0 deletions ci/tests/Framework.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/bin/bash
####
# Framework.bash:
#
# Run the tests on the software through fp-util.
####
# Directory to be used for Framework CI test
export FPUTIL_DEPLOYS="${FPRIME_DIR}"

export SCRIPT_DIR="$(dirname ${BASH_SOURCE})/.."
. "${SCRIPT_DIR}/helpers.bash"
. ${SCRIPT_DIR}/tests/fputil.bash

export CMAKE_EXTRA_SETTINGS=""
echo -e "${BLUE}Testing ${FPUTIL_DEPLOYS} against fprime-util targets: ${FPUTIL_TARGETS[@]}${NOCOLOR}"
export CHECK_TARGET_PLATFORM="native"
for target in "${FPUTIL_TARGETS[@]}"
do
if [[ "${target}" == "generate" ]]
then
rm -rf "${FPUTIL_DEPLOYS}/build-fprime-automatic-"*
fi
fputil_action "${FPUTIL_DEPLOYS}" "${target}"
done
32 changes: 32 additions & 0 deletions ci/tests/RPI.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/bin/bash
####
# RPI.bash:
#
# Run the tests on the software through fp-util.
####
# Directory to be used for RPI CI test
export FPUTIL_DEPLOYS="${FPRIME_DIR}/RPI"

export SCRIPT_DIR="$(dirname ${BASH_SOURCE})/.."
. "${SCRIPT_DIR}/helpers.bash"
. ${SCRIPT_DIR}/tests/fputil.bash

export CMAKE_EXTRA_SETTINGS=""
if [ ! -d "/opt/rpi/tools/arm-bcm2708/arm-rpi-4.9.3-linux-gnueabihf" ]
then
warn_and_cont "RPI tools not installed, refusing to test."
continue
fi
# For RPI deployment to disable FRAMEWORK UTS
export CMAKE_EXTRA_SETTINGS="${CMAKE_EXTRA_SETTINGS} -DFPRIME_ENABLE_FRAMEWORK_UTS=OFF"

echo -e "${BLUE}Testing ${FPUTIL_DEPLOYS} against fprime-util targets: ${FPUTIL_TARGETS[@]}${NOCOLOR}"
export CHECK_TARGET_PLATFORM="native"
for target in "${FPUTIL_TARGETS[@]}"
do
if [[ "${target}" == "generate" ]]
then
rm -rf "${FPUTIL_DEPLOYS}/build-fprime-automatic-"*
fi
fputil_action "${FPUTIL_DEPLOYS}" "${target}"
done
27 changes: 27 additions & 0 deletions ci/tests/Ref.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/bin/bash
####
# Ref.bash:
#
# Run the tests on the software through fp-util.
####
# Directory to be used for Ref CI test
export FPUTIL_DEPLOYS="${FPRIME_DIR}/Ref"

export SCRIPT_DIR="$(dirname ${BASH_SOURCE})/.."
. "${SCRIPT_DIR}/helpers.bash"
. ${SCRIPT_DIR}/tests/fputil.bash

export CMAKE_EXTRA_SETTINGS=""
# For Ref deployment to disable FRAMEWORK UTS
export CMAKE_EXTRA_SETTINGS="${CMAKE_EXTRA_SETTINGS} -DFPRIME_ENABLE_FRAMEWORK_UTS=OFF"

echo -e "${BLUE}Testing ${FPUTIL_DEPLOYS} against fprime-util targets: ${FPUTIL_TARGETS[@]}${NOCOLOR}"
export CHECK_TARGET_PLATFORM="native"
for target in "${FPUTIL_TARGETS[@]}"
do
if [[ "${target}" == "generate" ]]
then
rm -rf "${FPUTIL_DEPLOYS}/build-fprime-automatic-"*
fi
fputil_action "${FPUTIL_DEPLOYS}" "${target}"
done
35 changes: 16 additions & 19 deletions ci/tests/fputil.bash
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,8 @@
#
# Helpers to test via FP util
####
set -e
export FPUTIL_TARGETS=("generate" "generate --ut" "build" "build --all" "check --all")
export FPUTIL_DEPLOYS="${FPRIME_DIR} ${FPRIME_DIR}/Ref ${FPRIME_DIR}/RPI"

export INT_DEPLOYS="${FPRIME_DIR}/Ref"
####
# fputil_action:
#
Expand All @@ -17,29 +15,20 @@ export INT_DEPLOYS="${FPRIME_DIR}/Ref"
# :param deploy($2): deployment to run on
####
function fputil_action {
export DEPLOYMENT="${1}"
export WORKDIR="${1}"
export TARGET="${2}"
export WORKDIR="${DEPLOYMENT}/${3}"
let JOBS="${JOBS:-$(( ( RANDOM % 100 ) + 1 ))}"
(
cd "${DEPLOYMENT}"
PLATFORM=""

# Generate is only needed when it isn't being tested
if [[ "${TARGET}" != "generate" ]] && [[ "${TEST_TYPE}" != "QUICK" ]]
then
echo "[INFO] Generating build cache before ${DEPLOYMENT//\//_} '${TARGET}' execution"
fprime-util "generate" ${PLATFORM} ${CMAKE_EXTRA_SETTINGS} > "${LOG_DIR}/${DEPLOYMENT//\//_}_pregen.out.log" 2> "${LOG_DIR}/${DEPLOYMENT//\//_}_pregen.err.log" \
|| fail_and_stop "Failed to generate before ${DEPLOYMENT//\//_} '${TARGET}' execution"
fi
cd "${WORKDIR}"
if [[ "${TARGET}" != "generate" ]] && [[ "${TARGET}" != "generate --ut" ]]
then
echo "[INFO] FP Util in ${WORKDIR} running ${TARGET} with ${JOBS} jobs"
echo "[INFO] FP Util in ${WORKDIR} running ${TARGET} with ${JOBS} jobs"
fprime-util ${TARGET} --jobs "${JOBS}" ${PLATFORM} > "${LOG_DIR}/${WORKDIR//\//_}_${TARGET/ /}.out.log" 2> "${LOG_DIR}/${WORKDIR//\//_}_${TARGET/ /}.err.log" \
|| fail_and_stop "Failed to run '${TARGET}' in ${WORKDIR}"
else
echo "[INFO] FP Util in ${WORKDIR} running ${TARGET}"
echo "[INFO] FP Util in ${WORKDIR} running ${TARGET}"
fprime-util ${TARGET} ${PLATFORM} ${CMAKE_EXTRA_SETTINGS} > "${LOG_DIR}/${WORKDIR//\//_}_${TARGET/ /}.out.log" 2> "${LOG_DIR}/${WORKDIR//\//_}_${TARGET/ /}.err.log" \
|| fail_and_stop "Failed to run '${TARGET}' in ${WORKDIR}"
fi
Expand All @@ -56,10 +45,18 @@ function integration_test {
export SLEEP_TIME="10"
export WORKDIR="${1}"
export ROOTDIR="${WORKDIR}/build-artifacts"
if [[ "${TEST_TYPE}" != "QUICK" ]]
then
fputil_action "${WORKDIR}" "build" || fail_and_stop "Failed to build before integration test"
fi
let JOBS="${JOBS:-$(( ( RANDOM % 100 ) + 1 ))}"

CMAKE_EXTRA_SETTINGS=""
PLATFORM=""

cd "${WORKDIR}"
fprime-util "generate" > "${LOG_DIR}/${WORKDIR//\//_}_pregen.out.log" 2> "${LOG_DIR}/${WORKDIR//\//_}_pregen.err.log" \
|| fail_and_stop "Failed to generate before ${WORKDIR//\//_} building integration test"
cd "${WORKDIR}/"
fprime-util "build" --jobs "${JOBS}" ${PLATFORM} > "${LOG_DIR}/${WORKDIR//\//_}_${TARGET/ /}.out.log" 2> "${LOG_DIR}/${WORKDIR//\//_}_${TARGET/ /}.err.log" \
|| fail_and_stop "Failed to build before integration test"

(
mkdir -p "${LOG_DIR}/gds-logs"
# Start the GDS layer and give it time to run
Expand Down

0 comments on commit 764194a

Please sign in to comment.