Skip to content

Build tests

Build tests #62

Workflow file for this run

# This is the name of the workflow, visible on GitHub UI.
name: 'Build tests'
env:
# Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.)
BUILD_TYPE: Release
TARGET_TEST: picode_example
# Controls when the action will run.
# Here we tell GitHub to run the workflow when a commit.
on:
push:
paths:
- '*.cpp'
- 'src/**'
- 'libs/**'
- '.github/workflows/*.yml'
- 'CMakeLists.txt'
pull_request:
paths:
- '*.cpp'
- 'src/**'
- 'libs/**'
# Scheduled the first day of every month at 00:00h UTC
schedule:
- cron: '0 0 1 * *'
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
jobs:
build:
# This is the name of the job
name: 'Build for ${{ matrix.config.name }}'
# The CMake configure and build commands are platform agnostic and should work equally
# well on Windows, Linux or Mac.
runs-on: ${{ matrix.config.os }}
# Job env var for cmake build directory
env:
BUILD_DIR: ${{ github.workspace }}/build
# Here we tell GitHub that the jobs must be determined
# dynamically depending on a matrix configuration.
strategy:
# Set to false so that GitHub does not cancel all jobs
# in progress if any array job fails.
fail-fast: false
# The matrix will produce one job for each configuration:
matrix:
config:
- name: 'Linux x86_64'
os: 'ubuntu-latest'
bindir: 'echo "BIN_DIR=$BUILD_DIR" >> $GITHUB_ENV'
static: '*.a'
dynamic: '*.so'
- name: 'macOS Universal'
os: 'macos-latest'
bindir: 'echo "BIN_DIR=$BUILD_DIR" >> $GITHUB_ENV'
static: '*.a'
dynamic: '*.dylib'
- name: 'Windows x86_64'
os: 'windows-latest'
bindir: 'echo "BIN_DIR=$env:BUILD_DIR/$Env:BUILD_TYPE" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf-8 -Append'
static: '*.lib'
dynamic: '*.dll'
# This is the list of steps this job will run.
steps:
# Clone repo using the checkout action.
- name: Checkout
uses: actions/checkout@v2
with:
submodules: recursive
- name: Create Build Environment
# Some projects don't allow in-source building, so create a separate build directory
# We'll use this as our working directory for all subsequent commands
run: cmake -E make_directory ${{ env.BUILD_DIR }}
- name: Running CMake
working-directory: ${{ env.BUILD_DIR }}
run: cmake .. -DCMAKE_BUILD_TYPE=${{ env.BUILD_TYPE }}
- name: Build PiCode Library
working-directory: ${{ env.BUILD_DIR }}
run: cmake --build . --config ${{ env.BUILD_TYPE }}
- name: Build C++ test ${{ env.TARGET_TEST }}
working-directory: ${{ env.BUILD_DIR }}
# Execute the build. You can specify a specific target with "--target <NAME>"
run: cmake --build . --config ${{ env.BUILD_TYPE }} --target ${{ env.TARGET_TEST }}
- name: Build C test c${{ env.TARGET_TEST }}
working-directory: ${{ env.BUILD_DIR }}
# Execute the build. You can specify a specific target with "--target <NAME>"
run: cmake --build . --config ${{ env.BUILD_TYPE }} --target c${{ env.TARGET_TEST }}
# Set BIN_DIR from matrix bindir command
- name: Setting the binaries directory
run: ${{ matrix.config.bindir }}
# Execute test
- name: Execution C++ test ${{env.TARGET_TEST}}
run: ${{ env.BIN_DIR }}/${{ env.TARGET_TEST }}
- name: Execution C test c${{env.TARGET_TEST}}
run: ${{ env.BIN_DIR }}/c${{ env.TARGET_TEST }}
# Upload binary files to artifacts
- name: Upload compiled binaries to Artifacts
uses: actions/upload-artifact@v2
with:
name: "Binaries for ${{ matrix.config.name }}"
path: |
${{ env.BIN_DIR }}/${{ env.TARGET_TEST }}*
${{ env.BIN_DIR }}/c${{ env.TARGET_TEST }}*
${{ env.BIN_DIR }}/${{ matrix.config.static }}
${{ env.BIN_DIR }}/${{ matrix.config.dynamic }}