From bef903b20a1b4b89a1faf2f80adce54475496bde Mon Sep 17 00:00:00 2001 From: Jeff Wang Date: Mon, 14 Sep 2020 01:07:42 -0400 Subject: [PATCH] initial attempt at CI build --- .github/actions/stc_docker/Dockerfile | 1 + .github/actions/stc_docker/action.yml | 1 + .github/workflows/main.yml | 17 +++++++++++++++++ .gitignore | 1 + Dockerfile | 16 ++++++++++++++++ action.yml | 7 +++++++ steps/build_calc.sh | 9 +++++++++ steps/compose_build.sh | 9 +++++++++ steps/compose_run.sh | 21 +++++++++++++++++++++ steps/desktop_build_check.sh | 24 ++++++++++++++++++++++++ steps/docker-compose.yml | 10 ++++++++++ 11 files changed, 116 insertions(+) create mode 120000 .github/actions/stc_docker/Dockerfile create mode 120000 .github/actions/stc_docker/action.yml create mode 100644 .github/workflows/main.yml create mode 100644 Dockerfile create mode 100644 action.yml create mode 100755 steps/build_calc.sh create mode 100755 steps/compose_build.sh create mode 100755 steps/compose_run.sh create mode 100755 steps/desktop_build_check.sh create mode 100644 steps/docker-compose.yml diff --git a/.github/actions/stc_docker/Dockerfile b/.github/actions/stc_docker/Dockerfile new file mode 120000 index 0000000..dcbd8a2 --- /dev/null +++ b/.github/actions/stc_docker/Dockerfile @@ -0,0 +1 @@ +../../../Dockerfile \ No newline at end of file diff --git a/.github/actions/stc_docker/action.yml b/.github/actions/stc_docker/action.yml new file mode 120000 index 0000000..850b616 --- /dev/null +++ b/.github/actions/stc_docker/action.yml @@ -0,0 +1 @@ +../../../action.yml \ No newline at end of file diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 0000000..1fec1b7 --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,17 @@ +on: [push] + +jobs: + stc_rpncalc_ci_job: + runs-on: ubuntu-latest + name: Test building + steps: + - name: Checkout + uses: actions/checkout@v2 + - name: Docker layer cache + uses: satackey/action-docker-layer-caching@v0.0.8 + - name: Docker + run: $GITHUB_WORKSPACE/steps/compose_build.sh + - name: Desktop build/check + run: $GITHUB_WORKSPACE/steps/compose_run.sh desktop_build_check.sh --rebuild + - name: Calc build + run: $GITHUB_WORKSPACE/steps/compose_run.sh build_calc.sh diff --git a/.gitignore b/.gitignore index 10bfdec..6244943 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ +*.swp *.hex *.bak CMakeLists.txt.user diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..253b0b0 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,16 @@ +FROM ubuntu:18.04 + +RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y \ + build-essential \ + catch \ + clang \ + cmake \ + git \ + lcov \ + libboost-dev \ + libgmp-dev \ + libmpfr-dev \ + ninja-build \ + qtdeclarative5-dev \ + sdcc=3.5.0+dfsg-2build1 \ + vim-tiny diff --git a/action.yml b/action.yml new file mode 100644 index 0000000..886c096 --- /dev/null +++ b/action.yml @@ -0,0 +1,7 @@ +# GitHub Actions + +name: 'STC RPN Calc CI build' +description: 'run CI build in docker container' +runs: + using: 'docker' + image: 'Dockerfile' diff --git a/steps/build_calc.sh b/steps/build_calc.sh new file mode 100755 index 0000000..0ec3bc9 --- /dev/null +++ b/steps/build_calc.sh @@ -0,0 +1,9 @@ +#!/bin/bash + +set -e + +SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" + +# build +cd $SCRIPT_DIR/.. +make diff --git a/steps/compose_build.sh b/steps/compose_build.sh new file mode 100755 index 0000000..579d976 --- /dev/null +++ b/steps/compose_build.sh @@ -0,0 +1,9 @@ +#!/bin/bash + +set -e + +SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" + +# build +cd $SCRIPT_DIR +docker-compose build diff --git a/steps/compose_run.sh b/steps/compose_run.sh new file mode 100755 index 0000000..d2ded9a --- /dev/null +++ b/steps/compose_run.sh @@ -0,0 +1,21 @@ +#!/bin/bash + +set -e + +SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" + +# set GITHUBWORKSPACE if building locally +if [[ -z "${GITHUB_WORKSPACE}" ]]; then + export GITHUB_WORKSPACE="$SCRIPT_DIR/.." +fi +echo "GITHUB_WORKSPACE: ${GITHUB_WORKSPACE}" + +# build +cd $SCRIPT_DIR + +if [ "$#" -eq 0 ]; then + # start shell + docker-compose run build_tools bash +else + docker-compose run build_tools /code/steps/$1 +fi diff --git a/steps/desktop_build_check.sh b/steps/desktop_build_check.sh new file mode 100755 index 0000000..d314fcc --- /dev/null +++ b/steps/desktop_build_check.sh @@ -0,0 +1,24 @@ +#!/bin/bash + +set -e + +SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" + +# build +cd $SCRIPT_DIR/.. +if [ "$1" == "--rebuild" ]; then + rm -rf build_qt + mkdir build_qt +else + mkdir -p build_qt +fi +cd build_qt +cmake .. -GNinja +ninja + +# run tests +src/decn/decn_tests + +# get coverage +lcov --capture --directory src/decn --output-file coverage.info +genhtml coverage.info --output-directory lcov diff --git a/steps/docker-compose.yml b/steps/docker-compose.yml new file mode 100644 index 0000000..8921a02 --- /dev/null +++ b/steps/docker-compose.yml @@ -0,0 +1,10 @@ +version: '3.2' +services: + build_tools: + build: + context: .. + dockerfile: Dockerfile + volumes: + - type: bind + source: $GITHUB_WORKSPACE + target: /code