Skip to content

Commit

Permalink
Create build.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
mikucionisaau authored Nov 1, 2023
1 parent 1c04a52 commit a5ccf0e
Showing 1 changed file with 87 additions and 0 deletions.
87 changes: 87 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
---
name: Build

on:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]

jobs:
build:
runs-on: ${{ matrix.runner }}
env:
CCACHE_DIR: ${{ github.workspace }}/CCACHE
CMAKE_GENERATOR: Ninja
CMAKE_BUILD_TYPE: Release
CTEST_OUTPUT_ON_FAILURE: 1
strategy:
fail-fast: false
matrix:
include:
- target: x86_64-linux-cc
runner: ubuntu-latest
tools-install: |
sudo apt-get -qq update
sudo apt-get -qq install cmake ninja-build ccache g++
- target: x86_64-darwin-cc
runner: macos-11
xcode: '13.2.1'
tools-install: |
brew install bash coreutils cmake ninja ccache
steps:
- name: Checkout Source
uses: actions/checkout@v3

- name: Install Build Tools
run: ${{ matrix.tools-install }}

- name: Setup Xcode (macOS)
if: ${{ matrix.xcode }}
uses: maxim-lobanov/setup-xcode@v1
with:
xcode-version: ${{ matrix.xcode }}
- name: Setup Environment
run: |
TARGET=${{ matrix.target }}
WORKSPACE=${{ github.workspace }}
echo "TARGET=$TARGET" >> $GITHUB_ENV
# echo "CMAKE_TOOLCHAIN_FILE=$WORKSPACE/cmake/toolchain/$TARGET.cmake" >> $GITHUB_ENV
echo "CMAKE_INSTALL_PREFIX=$WORKSPACE/$TARGET" >> $GITHUB_ENV
echo "BUILD_DIR=build-$TARGET" >> $GITHUB_ENV
- name: Compute CCache Keys
id: ccache-keys
run: |
key2=ccache-${{env.TARGET}}-
key1="${key2}$(date +%V)"
echo "key1=${key1}" >> $GITHUB_OUTPUT
echo "key2=${key2}" >> $GITHUB_OUTPUT
- name: Restore CCache
id: ccache-restore
uses: actions/cache@v3
with:
path: ${{ env.CCACHE_DIR }}
key: ${{ steps.ccache-keys.outputs.key1 }}
restore-keys: ${{ steps.ccache-keys.outputs.key2 }}

- name: CCache Ready Stats
run: ccache --show-stats

- name: Configure
run: cmake -B "$BUILD_DIR" -S . -DFIND_FATAL=ON
- name: Compile
run: cmake --build "$BUILD_DIR" --config $CMAKE_BUILD_TYPE
- name: Test
if: ${{ ! matrix.test-disable }}
run: ctest --test-dir "$BUILD_DIR" --config $CMAKE_BUILD_TYPE
- name: Install
run: cmake --install "$BUILD_DIR" --config $CMAKE_BUILD_TYPE --prefix "$CMAKE_INSTALL_PREFIX"
- name: Display Assets
working-directory: ${{ env.CMAKE_INSTALL_PREFIX }}
run: ls -R

- name: CCache Show Stats
run: ccache --show-stats

0 comments on commit a5ccf0e

Please sign in to comment.