Skip to content

Commit

Permalink
add new workflow
Browse files Browse the repository at this point in the history
Signed-off-by: Laurynas Jagutis <[email protected]>
  • Loading branch information
Laurynas-Jagutis committed Sep 30, 2024
1 parent 89694c8 commit b813f03
Showing 1 changed file with 145 additions and 0 deletions.
145 changes: 145 additions & 0 deletions .github/workflows/new-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,145 @@
# SPDX-FileCopyrightText: Contributors to the Power Grid Model project <[email protected]>
#
# SPDX-License-Identifier: MPL-2.0

name: Build and Test C++

# Controls when the workflow will run
on:
# run pipeline on push event of main branch
push:
branches:
- main
# run pipeline on pull request
pull_request:
# run pipeline on merge queue
merge_group:
# run this workflow manually from the Actions tab
workflow_dispatch:
inputs:
create_release:
type: boolean
description: Create a (pre-)release when CI passes
default: true
required: true

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true


jobs:

build-cpp-test-linux:
runs-on: ubuntu-latest
strategy:
matrix:
build-option: [ debug, release ]
compiler: [gcc, clang]
include:
- compiler: gcc
- compiler: clang

env:
CMAKE_PREFIX_PATH: /home/linuxbrew/.linuxbrew
PRESET: ci-${{ matrix.compiler }}-${{ matrix.build-option }}

steps:
- uses: actions/checkout@v4
with:
submodules: 'true'
- name: Initialize and update submodules
run: |
git submodule update --init --recursive
- name: Install packages
run: |
sudo apt-get update
sudo apt-get install -y ninja-build gcc-12 g++-12 clang-15
sudo ln -s /usr/bin/clang-15 /usr/local/bin/clang
sudo ln -s /usr/bin/clang++-15 /usr/local/bin/clang++
sudo ln -s /usr/bin/gcc-12 /usr/local/bin/gcc
sudo ln -s /usr/bin/g++-12 /usr/local/bin/g++
- name: Enable brew
run: |
echo "/home/linuxbrew/.linuxbrew/bin:/home/linuxbrew/.linuxbrew/sbin" >> $GITHUB_PATH
- name: Install C++ dependencies
run: |
brew install boost eigen nlohmann-json msgpack-cxx doctest
- name: Build and test
run: ./build.sh -p ${{ env.PRESET }} -i

build-cpp-test-windows:
runs-on: windows-latest
strategy:
matrix:
build-option: [ debug, release ]
compiler: [msvc, clang-cl]

env:
PRESET: ${{ matrix.compiler }}-${{ matrix.build-option }}

steps:
- uses: actions/checkout@v4
with:
submodules: 'true'

- name: Activate conda
uses: conda-incubator/setup-miniconda@v3 # install miniforge instead
with:
miniforge-version: latest

- name: List conda
run: |
conda info
conda list
- name: Install conda environment
run: |
conda create --yes -p C:\conda_envs\cpp_pkgs -c conda-forge libboost-headers eigen nlohmann_json msgpack-cxx doctest
- name: Build and test
run: |
$vsPath = &(Join-Path ${env:ProgramFiles(x86)} '\Microsoft Visual Studio\Installer\vswhere.exe') -property installationpath
Import-Module (Join-Path $vsPath 'Common7\Tools\Microsoft.VisualStudio.DevShell.dll')
Enter-VsDevShell -VsInstallPath $vsPath -SkipAutomaticLocation -DevCmdArguments '-arch=x64 -host_arch=x64'
# Resolve dirty PATH environment
# TODO(mgovers): Remove after https://github.com/actions/runner-images/issues/10001 is resolved
$env:PATH = ($env:PATH -split ';' | Where-Object { $_ -ne 'C:\Program Files\LLVM\bin' }) -join ';'
# generate cmake cache
cmake --preset ${{ env.PRESET }} -DCMAKE_PREFIX_PATH=C:\conda_envs\cpp_pkgs\Library; if(!$?) { Exit $LASTEXITCODE }
# build
cmake --build --preset ${{ env.PRESET }} --verbose -j 1; if(!$?) { Exit $LASTEXITCODE }
# test
ctest --preset ${{ env.PRESET }} --output-on-failure; if(!$?) { Exit $LASTEXITCODE }
# install
cmake --build --preset ${{ env.PRESET }} --verbose -j 1 --target install; if(!$?) { Exit $LASTEXITCODE }
build-cpp-test-macos:
runs-on: macos-14
strategy:
matrix:
build-option: [ debug, release ]
env:
CMAKE_PREFIX_PATH: /usr/local
PRESET: ci-clang-${{ matrix.build-option }}

steps:
- uses: actions/checkout@v4
with:
submodules: 'true'

- name: Set up XCode
uses: maxim-lobanov/setup-xcode@v1
with:
xcode-version: latest-stable

- name: Install cpp dependencies
run: |
brew install ninja boost eigen nlohmann-json msgpack-cxx doctest
- name: Build and test
run: ./build.sh -p ${{ env.PRESET }} -i

0 comments on commit b813f03

Please sign in to comment.