Skip to content

Commit 0a4e808

Browse files
Merge pull request #90 from alliander-opensource/feature/simplify-build
Simplify build process
2 parents f8e810b + 5c0fd3c commit 0a4e808

33 files changed

+1312
-1334
lines changed

.github/workflows/main.yml

Lines changed: 18 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,24 @@ jobs:
2323

2424
build-cpp-test-linux:
2525
if: (github.event_name == 'push') || (github.event_name == 'workflow_dispatch') || (!startsWith(github.head_ref, 'release'))
26-
runs-on: ubuntu-latest
27-
container: ghcr.io/alliander-opensource/power-grid-model-build-env:latest
26+
runs-on: ubuntu-22.04
2827
strategy:
2928
matrix:
3029
build-option: [ Debug, Release ]
30+
cpp-compiler: [g++-11, clang++-14]
31+
env:
32+
CMAKE_PREFIX_PATH: /home/linuxbrew/.linuxbrew
33+
CXX: ${{ matrix.cpp-compiler }}
3134

3235
steps:
3336
- uses: actions/checkout@v3
34-
37+
- name: Install packages
38+
run: |
39+
sudo apt-get update
40+
sudo apt-get install -y ninja-build
41+
- name: Install C++ dependencies
42+
run: |
43+
brew install boost eigen nlohmann-json doctest
3544
- name: Run build script
3645
run: ./build.sh ${{ matrix.build-option }}
3746

@@ -50,16 +59,14 @@ jobs:
5059
& "$env:CONDA\condabin\conda" init
5160
5261
- name: Install conda environment
53-
# TODO removed pinned v2 of catch2, see https://github.com/alliander-opensource/power-grid-model/issues/73
5462
run: |
55-
conda create --yes -p C:\conda_envs\cpp_pkgs -c conda-forge boost-cpp eigen nlohmann_json catch2==2.13.9
63+
conda create --yes -p C:\conda_envs\cpp_pkgs -c conda-forge boost-cpp eigen nlohmann_json doctest
5664
5765
- name: Build and test
5866
run: |
5967
$vsPath = &(Join-Path ${env:ProgramFiles(x86)} '\Microsoft Visual Studio\Installer\vswhere.exe') -property installationpath
6068
Import-Module (Join-Path $vsPath 'Common7\Tools\Microsoft.VisualStudio.DevShell.dll')
6169
Enter-VsDevShell -VsInstallPath $vsPath -SkipAutomaticLocation -DevCmdArguments '-arch=x64 -host_arch=x64'
62-
$env:Path += ";C:\conda_envs\cpp_pkgs\Library\bin"
6370
mkdir cpp_build_${{ matrix.build-option }}
6471
cd cpp_build_${{ matrix.build-option }}
6572
# generate cmake cache
@@ -88,10 +95,8 @@ jobs:
8895
- uses: actions/checkout@v3
8996

9097
- name: Install cpp dependencies
91-
# TODO removed pinned v2 of catch2, see https://github.com/alliander-opensource/power-grid-model/issues/73
9298
run: |
93-
brew install ninja boost eigen nlohmann-json
94-
curl https://raw.githubusercontent.com/Homebrew/homebrew-core/5e5abb11bf49787d01164c4066119365262c21ed/Formula/catch2.rb > $(find $(brew --repository) -name catch2.rb) && brew reinstall catch2
99+
brew install ninja boost eigen nlohmann-json doctest
95100
96101
- name: Build and test
97102
run: |
@@ -106,24 +111,18 @@ jobs:
106111
os: ubuntu-latest
107112
cc: gcc
108113
cxx: g++
109-
boost:
110-
eigen:
111114
cibw_build: "cp*-manylinux_x86_64 cp*-manylinux_aarch64"
112115
archs: "x86_64 aarch64"
113116
- platform: macos
114117
os: macos-latest
115118
cc: clang
116119
cxx: clang++
117-
boost: /usr/local/include
118-
eigen: /usr/local/include/eigen3
119120
cibw_build: cp*-macosx_*
120121
archs: "x86_64 arm64"
121122
- platform: windows
122123
os: windows-latest
123124
cc:
124125
cxx:
125-
boost: C:\conda_envs\cpp_pkgs\Library\include
126-
eigen: C:\conda_envs\cpp_pkgs\Library\include\eigen3
127126
cibw_build: cp*-win_amd64
128127
archs: AMD64
129128

@@ -133,26 +132,18 @@ jobs:
133132
env:
134133
CC: ${{ matrix.cc }}
135134
CXX: ${{ matrix.cxx }}
136-
BOOST_INCLUDE: ${{ matrix.boost }}
137-
EIGEN_INCLUDE: ${{ matrix.eigen }}
138135
CIBW_BUILD_VERBOSITY: 1
139136
CIBW_BUILD_FRONTEND: "build"
140137
CIBW_BUILD: ${{ matrix.cibw_build }}
141138
CIBW_ARCHS: ${{ matrix.archs }}
142-
CIBW_TEST_REQUIRES: pytest pytest-cov
139+
CIBW_TEST_EXTRAS: "dev"
143140
CIBW_TEST_COMMAND: pytest {package}/tests
144141
# Skip trying to test arm64 builds on Intel Macs
145142
CIBW_TEST_SKIP: "*-macosx_arm64 *-macosx_universal2:arm64"
146-
CIBW_MANYLINUX_X86_64_IMAGE: ghcr.io/alliander-opensource/power-grid-model-build-env
147-
CIBW_MANYLINUX_AARCH64_IMAGE: ghcr.io/alliander-opensource/power-grid-model-build-env-arm64
148-
CIBW_ENVIRONMENT_PASS_LINUX: GITHUB_SHA GITHUB_REF GITHUB_RUN_NUMBER
149-
CIBW_BEFORE_ALL_MACOS: >
150-
which clang++ &&
151-
clang++ --version &&
152-
brew install boost eigen
143+
CIBW_ENVIRONMENT_PASS_LINUX: GITHUB_SHA GITHUB_REF GITHUB_RUN_NUMBER CC CXX
153144
MACOSX_DEPLOYMENT_TARGET: 10.15
154-
CIBW_BEFORE_ALL_WINDOWS : >
155-
conda create --yes -p C:\conda_envs\cpp_pkgs -c conda-forge boost-cpp eigen
145+
CIBW_MANYLINUX_X86_64_IMAGE: manylinux2014
146+
CIBW_MANYLINUX_AARCH64_IMAGE: manylinux2014
156147

157148
steps:
158149
- uses: actions/checkout@v3
@@ -161,11 +152,6 @@ jobs:
161152
if: matrix.platform == 'linux'
162153
uses: docker/setup-qemu-action@v2
163154

164-
- name: Activate conda for windows
165-
if: matrix.platform == 'windows'
166-
run: |
167-
& "$env:CONDA\condabin\conda" init
168-
169155
- name: Build wheels
170156
uses: pypa/[email protected]
171157

.github/workflows/sonar.yml

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,21 +19,35 @@ jobs:
1919
sonar-cloud:
2020
if: (github.event_name == 'push') || (!startsWith(github.head_ref, 'release'))
2121
name: SonarCloud
22-
runs-on: ubuntu-latest
23-
container: ghcr.io/alliander-opensource/power-grid-model-build-env-sonar:latest
22+
runs-on: ubuntu-22.04
2423
env:
2524
SONAR_SCANNER_VERSION: 4.4.0.2170
2625
SONAR_SERVER_URL: "https://sonarcloud.io"
2726
BUILD_WRAPPER_OUT_DIR: build_wrapper_output_directory # Directory where build-wrapper output will be placed
27+
CMAKE_PREFIX_PATH: /home/linuxbrew/.linuxbrew
28+
LLVM_COV: llvm-cov-14
29+
CC: clang-14
30+
CXX: clang++-14
2831
steps:
2932
- uses: actions/checkout@v3
3033
with:
3134
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
35+
- name: Install packages
36+
run: |
37+
sudo apt-get update
38+
sudo apt-get install -y ninja-build lcov gcovr
39+
- name: Install C++ dependencies
40+
run: |
41+
brew install boost eigen nlohmann-json doctest
3242
- name: Set up JDK 11
3343
uses: actions/setup-java@v3
3444
with:
3545
java-version: 11
3646
distribution: 'microsoft'
47+
- name: Set up Python
48+
uses: actions/setup-python@v4
49+
with:
50+
python-version: "3.10"
3751
- name: Download and set up sonar-scanner
3852
env:
3953
SONAR_SCANNER_DOWNLOAD_URL: https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-${{ env.SONAR_SCANNER_VERSION }}-linux.zip
@@ -52,16 +66,15 @@ jobs:
5266
5367
- name: Python test and coverage
5468
run: |
55-
/opt/venv/bin/pip install -e .
56-
/opt/venv/bin/pip install -r dev-requirements.txt
57-
/opt/venv/bin/pytest
69+
pip install -e .[dev]
70+
pytest
5871
# remove cython generated cpp file
5972
rm -rf src/power_grid_model/*.cpp
6073
6174
- name: Run build-wrapper for C++
6275
run: |
6376
mkdir cpp_build
64-
cmake -S . -B cpp_build -GNinja -DCMAKE_BUILD_TYPE=Debug -DCMAKE_PREFIX_PATH=${CMAKE_PREFIX_PATH}
77+
cmake -S . -B cpp_build -GNinja -DCMAKE_BUILD_TYPE=Debug -DPOWER_GRID_MODEL_COVERAGE=1
6578
VERBOSE=1 build-wrapper-linux-x86-64 --out-dir ${{ env.BUILD_WRAPPER_OUT_DIR }} cmake --build cpp_build/
6679
6780
- name: C++ test and coverage
@@ -74,7 +87,8 @@ jobs:
7487
sed -i -r "s/\s*branchesToCover\s*=\s*\"[0-9]+\"\s+coveredBranches\s*=\s*\"[0-9]+\"//g" cpp_coverage.xml
7588
7689
- name: Run sonar-scanner
77-
if: github.event_name == 'push' # only run sonar server in push event
90+
# only run sonar server in push event or pull request event from own repo
91+
if: github.event_name == 'push' || ${{ github.event.pull_request.head.repo.owner.login }} == 'alliander-opensource'
7892
env:
7993
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
8094
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}

CMakeSettings.json

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,7 @@
99
"installRoot": "${projectDir}\\install\\${name}",
1010
"cmakeCommandArgs": "-DPOWER_GRID_MODEL_BUILD_BENCHMARK=1",
1111
"buildCommandArgs": "-v",
12-
"ctestCommandArgs": "",
13-
"cmakeToolchain": "${env.VCPKG_ROOT}\\scripts\\buildsystems\\vcpkg.cmake"
12+
"ctestCommandArgs": ""
1413
},
1514
{
1615
"name": "x64-Release",
@@ -21,8 +20,7 @@
2120
"cmakeCommandArgs": "-DPOWER_GRID_MODEL_BUILD_BENCHMARK=1",
2221
"buildCommandArgs": "-v",
2322
"ctestCommandArgs": "",
24-
"inheritEnvironments": [ "msvc_x64_x64" ],
25-
"cmakeToolchain": "${env.VCPKG_ROOT}\\scripts\\buildsystems\\vcpkg.cmake"
23+
"inheritEnvironments": [ "msvc_x64_x64" ]
2624
}
2725
]
2826
}

build.sh

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,16 +25,6 @@ fi
2525
BUILD_DIR=cpp_build_$1
2626
echo "Build dir: ${BUILD_DIR}"
2727

28-
if [[ ! -z "${VCPKG_ROOT}" ]]; then
29-
PATH_FOR_CMAKE=-DCMAKE_TOOLCHAIN_FILE=${VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake
30-
elif [[ ! -z "${CMAKE_PREFIX_PATH}" ]]; then
31-
PATH_FOR_CMAKE=-DCMAKE_PREFIX_PATH=${CMAKE_PREFIX_PATH}
32-
else
33-
PATH_FOR_CMAKE=
34-
fi
35-
36-
echo ${PATH_FOR_CMAKE}
37-
3828
rm -rf ${BUILD_DIR}/
3929
mkdir ${BUILD_DIR}
4030
cd ${BUILD_DIR}

dev-requirements.txt

Lines changed: 0 additions & 6 deletions
This file was deleted.

0 commit comments

Comments
 (0)