Skip to content

Commit

Permalink
ci: build on windows and mac
Browse files Browse the repository at this point in the history
  • Loading branch information
NikolaDucak committed May 25, 2024
1 parent 88d8766 commit 39739d8
Show file tree
Hide file tree
Showing 4 changed files with 129 additions and 81 deletions.
119 changes: 119 additions & 0 deletions .github/workflows/build-and-test-matrix.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
name: Build and test matrix

on:
workflow_call:
inputs:
version:
description: 'Version of the caps-log'
required: false
default: ''
type: string
run_sanitizers:
description: 'Whether to run sanitizers'
required: false
default: false
type: boolean
run_tests:
description: 'Whether to run tests'
required: false
default: false
type: boolean
build_type:
description: 'Build type (e.g., Debug, Release)'
required: true
type: string
release_name:
description: 'Name of the release'
required: false
default: ''
type: string

jobs:
build_and_test_windows:
runs-on: windows-latest
steps:
- name: Get deps
run: |
choco install cmake --installargs 'ADD_CMAKE_TO_PATH=System'
choco install boost-msvc-14.1
choco install libgit2
- name: Configure environment
run: |
$boost_root = "C:\local\boost"
$libgit2_root = "C:\Program Files\libgit2"
echo "LIBGIT2_INCLUDE_DIR=$libgit2_root\include" >> $env:GITHUB_ENV
echo "LIBGIT2_LIBRARY=$libgit2_root\lib\libgit2.lib" >> $env:GITHUB_ENV
echo "BOOST_ROOT=C:\local\boost_1_69_0" >> $env:GITHUB_ENV
echo "CMAKE_PREFIX_PATH=C:\local\boost_1_69_0;C:\Program Files\libgit2" >> $env:GITHUB_ENV
- uses: actions/checkout@v4
- name: CMake configure
run: |
if [ "${{ inputs.run_tests }}" == "true" ]; then TESTS="On"; else TESTS="Off"; fi
cmake -B ${{ github.workspace }}/build -DCMAKE_BUILD_TYPE=${{ inputs.build_type }} -DCAPS_LOG_BUILD_TESTS=$TESTS -DBOOST_ROOT=C:\local\boost_1_69_0 -DCMAKE_PREFIX_PATH="C:\local\boost_1_69_0;C:\Program Files\libgit2"
- name: CMake build
run: cmake --build ${{ github.workspace }}/build --config ${{ inputs.build_type }}
- name: Test
if: ${{ inputs.run_tests == true }}
working-directory: ${{ github.workspace }}/build
run: ctest -C ${{ inputs.build_type }} --output-on-failure
- name: Upload
if: ${{ inputs.release_name != '' }}
run: |
ARCHIVE="caps-log-win.tar.gz"
cp build/source/caps-log ./caps-log
tar -czvf $ARCHIVE caps-log
gh release upload ${{ inputs.release_name }} $ARCHIVE --clobber
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

build_and_test_macos:
runs-on: macos-latest
steps:
- name: Get deps
run: brew install libgit2 boost
- uses: actions/checkout@v4
- name: CMake configure
run: |
if [ "${{ inputs.run_tests }}" == "true" ]; then TESTS="On"; else TESTS="Off"; fi
cmake -B ${{ github.workspace }}/build -DCMAKE_BUILD_TYPE=${{ inputs.build_type }} -DCAPS_LOG_BUILD_TESTS=$TEST
- name: CMake build
run: cmake --build ${{github.workspace}}/build --config ${{ inputs.build_type }}
- name: Test
if: ${{ inputs.run_tests == true }}
working-directory: ${{ github.workspace }}/build
run: ctest -C ${{ inputs.build_type }} --output-on-failure
- name: Upload
if: ${{ inputs.release_name != '' }}
run: |
ARCHIVE="caps-log-macos.tar.gz"
cp build/source/caps-log ./caps-log
tar -czvf $ARCHIVE caps-log
gh release upload ${{ inputs.release_name }} $ARCHIVE --clobber
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

build_and_test_linux:
runs-on: ubuntu-latest
steps:
- name: Get deps
run: sudo apt-get update && sudo apt-get install libboost-program-options-dev libgit2-dev
- uses: actions/checkout@v4
- name: CMake configure
run: |
if [ "${{ inputs.run_tests }}" == "true" ]; then TESTS="On"; else TESTS="Off"; fi
cmake -B ${{ github.workspace }}/build -DCMAKE_BUILD_TYPE=${{ inputs.build_type }} -DCAPS_LOG_BUILD_TESTS=$TESTS
- name: CMake build
run: cmake --build ${{ github.workspace }}/build --config ${{ inputs.build_type }}
- name: Test
if: ${{ inputs.run_tests == true }}
working-directory: ${{ github.workspace }}/build
run: ctest -C ${{ inputs.build_type }} --output-on-failure
- name: Upload
if: ${{ inputs.release_name != '' }}
run: |
ARCHIVE="caps-log-linux.tar.gz"
cp build/source/caps-log ./caps-log
tar -czvf $ARCHIVE caps-log
gh release upload ${{ inputs.release_name }} $ARCHIVE --clobber
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2 changes: 1 addition & 1 deletion .github/workflows/conventional-commits.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ jobs:
name: Conventional Commits
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- uses: webiny/action-conventional-commits@v1.1.0

83 changes: 6 additions & 77 deletions .github/workflows/pr-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on:
pull_request:
branches: [ "master" ]
paths-ignore:
- '.github/**'
#- '.github/**'
- '.gitignore'
- 'README'
- 'LICENCE'
Expand All @@ -21,82 +21,11 @@ concurrency:
cancel-in-progress: true

jobs:
build:
strategy:
fail-fast: false
matrix:
compiler: ['clang','msvc','gcc']
os: ['ubuntu-latest', 'windows-latest']
exclude:
- os: 'ubuntu-latest'
compiler: 'msvc'
- os: 'windows-latest'
# temporary exclude everything
# compiler: 'gcc'

runs-on: ${{ matrix.os }}

steps:
- uses: actions/checkout@v3
- name: Cache
id: cache-step
uses: actions/cache@v3
with:
path: |
~/vcpkg
./build/vcpkg_installed
${{ env.CONAN_USER_HOME }}
~/.cache/pip
${{ env.HOME }}/.cache/vcpkg/archives
${{ env.XDG_CACHE_HOME }}/vcpkg/archives
${{ env.LOCALAPPDATA }}\vcpkg\archives
${{ env.APPDATA }}\vcpkg\archives
key: ${{ runner.os }}-${{ matrix.compiler }}-${{ hashFiles('**/CMakeLists.txt') }}
restore-keys: |
${{ runner.os }}-${{ matrix.compiler }}
- name: Prepare environment
uses: aminya/setup-cpp@v1
with:
compiler: ${{ matrix.compiler }}
vcvarsall: ${{ contains(matrix.os, 'windows' )}}
cmake: true
ninja: true
conan: false
vcpkg: false
ccache: false
clangtidy: false
cppcheck: false
gcovr: false
opencppcoverage: false

- name: Setup vcpkg and install Boost (Windows)
if: steps.cache-step.outputs.cache-hit != 'true' && matrix.os == 'windows-latest'

run: |
git clone https://github.com/microsoft/vcpkg.git
cd vcpkg
./bootstrap-vcpkg.bat
./vcpkg install boost
- name: Get boost
if: matrix.os != 'windows-latest'
run: sudo apt-get update && sudo apt-get install libboost-program-options-dev libgit2-dev

- name: Configure CMake (Windows)
if: matrix.os == 'windows-latest'
run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=Release -DCAPS_LOG_BUILD_TESTS=On -DCMAKE_TOOLCHAIN_FILE=${{github.workspace}}/vcpkg/scripts/buildsystems/vcpkg.cmake

- name: Configure CMake (Windows)
if: matrix.os != 'windows-latest'
run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=Release -DCAPS_LOG_BUILD_TESTS=On

- name: Build
run: cmake --build ${{github.workspace}}/build --config Release

- name: Test
working-directory: ${{ github.workspace }}/build
run: ctest -C ${{env.BUILD_TYPE}} --output-on-failure
matrix_build_and_test:
uses: ./.github/workflows/build-and-test-matrix.yml
with:
run_tests: true
build_type: "Release"

static-analysis:
runs-on: ubuntu-latest
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
version: ${{ steps.get_next_version.outputs.version }}
steps:
- name: Clone repository
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Get next version
Expand Down Expand Up @@ -45,7 +45,7 @@ jobs:
needs: create-release
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- run: sudo apt-get update && sudo apt-get install libboost-program-options-dev libssl-dev libgit2-dev

- name: Build
Expand All @@ -65,7 +65,7 @@ jobs:
needs: create-release
runs-on: macos-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- run: brew install boost openssl libgit2

- name: Build for MacOS
Expand Down

0 comments on commit 39739d8

Please sign in to comment.