updt cmakefile #368
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#onbings@gmail.com (a) b.harmel@gmail.com | |
#https://www.docker.com/blog/docker-github-actions/ | |
#https://stackoverflow.com/questions/60735334/github-continuous-integration-cmake-c | |
#https://dev.to/mihinduranasinghe/using-docker-containers-in-jobs-github-actions-3eof | |
name: BuildBofStd | |
on: | |
# Triggers the workflow on push or pull request events but only for the main branch | |
push: | |
branches: [ main ] | |
pull_request: | |
branches: [ main ] | |
# tags: | |
# - "v*.*.*" | |
jobs: | |
build-bofstd: | |
# The CMake configure and build commands are platform agnostic and should work equally | |
# well on Windows or Mac. You can convert this to a matrix build if you need | |
# cross-platform coverage. | |
# See: https://docs.github.com/en/free-pro-team@latest/actions/learn-github-actions/managing-complex-workflows#using-a-build-matrix | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
BUILD_TYPE: [Debug, Release] #[Debug] # | |
BUILD_TARGET: [DESKTOP_DEBIAN64] #[DESKTOP_LINUX64] #[DESKTOP_LINUX64, DESKTOP_DEBIAN64] | |
BUILD_TARGET_IMAGE: ['onbings/debian_stretch_builder:latest'] #[''] | |
#BUILD_TARGET_OPTION: ['-v /home/runner/work:/__w'] | |
env: | |
ACTIONS_ALLOW_UNSECURE_COMMANDS: 'true' #to be able to execute echo ::set-env name= The `set-env` command is disabled. Please upgrade to using Environment Files or opt into unsecure command execution by setting the `ACTIONS_ALLOW_UNSECURE_COMMANDS` | |
BUILD_PACKAGE_NAME: bofstd | |
BUILD_TYPE: ${{matrix.BUILD_TYPE}} | |
BUILD_BIN_DIR: /__w/bofstd/bofstd/build/${{matrix.BUILD_TYPE}} #${{ github.workspace }}/build/${{matrix.BUILD_TYPE}} #can't do this at that level .... BUILD_BIN_DIR: $BUILD_ROOT/build/$BUILD_TYPE | |
# BUILD_BIN_DIR: ${{ github.workspace }}/build/${{matrix.BUILD_TYPE}} #can't do this at that level .... BUILD_BIN_DIR: $BUILD_ROOT/build/$BUILD_TYPE | |
BLD_TARGET_PLATFORM: ${{matrix.BUILD_TARGET}} | |
container: | |
image: ${{matrix.BUILD_TARGET_IMAGE}} | |
# options: ${{matrix.BUILD_TARGET_OPTION}} #-v "/home/runner/work/googletest/googletest":"/github/workspace" | |
# credentials: | |
# username: ${{secrets.DOCKER_HUB_USERNAME}} | |
# password: ${{secrets.DOCKER_HUB_ACCESS_TOKEN}} | |
steps: | |
- name: First, checkout bofstd source | |
uses: actions/checkout@v2 | |
- name: Then checkout cmake support | |
uses: actions/checkout@v2 | |
with: | |
repository: onbings/cmake | |
#token: ${{ secrets.GitHub_PAT }} # `GitHub_PAT` is a secret that contains your PAT | |
path: cmake | |
# - name: Docker build or not, set build env to ${{ matrix.BUILD_TARGET_IMAGE }} | |
# if: ${{ matrix.BUILD_TARGET_IMAGE != '' }} | |
# uses: docker://onbings/debian_stretch_builder:latest #${{ matrix.BUILD_TARGET_IMAGE }} | |
# with: | |
# args: uname -a | |
- name: Configure CMake | |
# Use a bash shell so we can use the same syntax for environment variable | |
# access regardless of the host operating system | |
shell: bash | |
#Native ubuntu | |
#pwd: /home/runner/work/googletest/googletest | |
#uname -a: Linux fv-az163-623 5.4.0-1041-azure #43-Ubuntu SMP Fri Feb 26 10:21:20 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux | |
run: | | |
pwd | |
uname -a | |
echo ::set-env name=BUILD_INSTALL_DIR::${{ env.BUILD_BIN_DIR }}/install | |
cmake -E make_directory $BUILD_BIN_DIR | |
- name: Build | |
shell: bash | |
# Execute the build. You can specify a specific target with "--target <NAME>" | |
run: | | |
echo "BLD_TARGET_PLATFORM $BLD_TARGET_PLATFORM" | |
echo "BUILD_PACKAGE_NAME $BUILD_PACKAGE_NAME" | |
echo "BUILD_TYPE $BUILD_TYPE" | |
echo "BUILD_BIN_DIR $BUILD_BIN_DIR" | |
echo "BUILD_INSTALL_DIR $BUILD_INSTALL_DIR" | |
cd ${{ env.BUILD_BIN_DIR }} | |
cmake -DCMAKE_BUILD_TYPE=${{ env.BUILD_TYPE }} -DCMAKE_INSTALL_PREFIX=${{ env.BUILD_INSTALL_DIR }} -DCMAKE_FIND_ROOT_PATH=${{ env.BUILD_INSTALL_DIR }} -DBLD_TARGET_PLATFORM=${{ env.BLD_TARGET_PLATFORM }} ../.. | |
cmake --build . --config ${{ env.BUILD_TYPE }} | |
- name: Test | |
shell: bash | |
# Execute tests defined by the CMake configuration. | |
# See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail | |
run: | | |
cd $BUILD_BIN_DIR | |
ctest -C $BUILD_TYPE | |
# - name: Debug Docker with a multiline script | |
# run: | | |
# pwd | |
# ls -al /github | |
- name: Install | |
shell: bash | |
# Execute the build. You can specify a specific target with "--target <NAME>" | |
run: | | |
cd $BUILD_BIN_DIR | |
cmake --build . --target install --config $BUILD_TYPE #-DCMAKE_INSTALL_PREFIX=$BUILD_INSTALL_DIR made above | |
pwd | |
BLD_CMAKE_INFO=$(cat BLD_CMAKE_INFO.TXT) | |
echo "BLD_CMAKE_INFO=$BLD_CMAKE_INFO" #>> $GITHUB_ENV | |
echo ::set-env name=BUILD_ARTIFACT::${{ matrix.BUILD_TARGET }}@${{ env.BUILD_PACKAGE_NAME }}@$BLD_CMAKE_INFO | |
#Write info 3.1.0.1@GNU_6.3.0 in /__w/bofstd/bofstd/build/Debug/BLD_CMAKE_INFO.TXT file. | |
#cmake 3.15 | |
#cmake --install . --config $BUILD_TYPE --prefix $BUILD_INSTALL_DIR | |
- name: Upload Artifact on GitHub | |
uses: actions/upload-artifact@v2 | |
with: | |
name: ${{env.BUILD_ARTIFACT}} | |
path: ${{env.BUILD_INSTALL_DIR }} | |
if-no-files-found: error | |
#remote access to the build machine in case of failure, press q in the 'black' screen | |
# - name: Setup tmate session #https://github.com/mxschmitt/action-tmate | |
# if: ${{ failure() }} | |
# uses: mxschmitt/action-tmate@v3 | |
# with: | |
# sudo: false #false for docker true for ubuntu |