Skip to content

Commit fe2e12f

Browse files
Merge pull request #87 from alliander-opensource/release/1.4
Release version 1.4
2 parents abc71c5 + f5f9519 commit fe2e12f

File tree

158 files changed

+9245
-4533
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

158 files changed

+9245
-4533
lines changed

.clang-format

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,5 @@ AllowShortLoopsOnASingleLine: false
1515
BreakBeforeBraces: Custom
1616
BraceWrapping:
1717
BeforeCatch: true
18-
BeforeElse: true
18+
BeforeElse: true
19+

.github/workflows/black-and-clang-format.yml renamed to .github/workflows/check-code-quality.yml

Lines changed: 30 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@
44

55

66
# GitHub Action that uses
7-
# Black to reformat the Python code in an incoming pull request.
7+
# isort, black, mypy and pylint to reformat the Python code in an incoming pull request.
88
# clang-format to reformat the C++ code in an incoming pull request.
99
# If all code in the pull request is compliant with Black and clang-format then this Action
1010
# does nothing. Otherwise, it will print the files which need to be reformatted and raise an error.
1111

12-
name: Format Code
12+
name: Check Code Quality
1313

1414
on:
1515
# run pipeline on push event of main or release branch
@@ -21,8 +21,8 @@ on:
2121
pull_request:
2222

2323
jobs:
24-
code-format-check:
25-
24+
check-code-quality:
25+
if: (github.event_name == 'push') || (!startsWith(github.head_ref, 'release'))
2626
runs-on: ubuntu-latest
2727

2828
steps:
@@ -33,23 +33,41 @@ jobs:
3333
uses: actions/setup-python@v4
3434
with:
3535
python-version: 3.8
36-
37-
- name: Install Black and clang-format
36+
37+
- name: Upgrade pip
38+
run: pip install --upgrade pip
39+
40+
- name: Install and run isort
41+
run: |
42+
pip install isort
43+
isort .
44+
45+
- name: Install and run black
3846
run: |
3947
pip install black
40-
sudo apt-get update && sudo apt-get install -y clang-format
48+
black .
4149
42-
- name: Run black
43-
run: black .
50+
- name: Install and run mypy
51+
run: |
52+
pip install mypy
53+
mypy .
54+
55+
- name: Install and run pylint
56+
run: |
57+
pip install pylint .
58+
pylint power_grid_model
59+
git restore README.md
4460
45-
- name: Run clang-format
46-
run: find . -regex '.*\.\(cpp\|hpp\|cc\|cxx\)' -exec clang-format -style=file -i {} \;
61+
- name: Install and run clang-format
62+
run: |
63+
sudo apt-get update && sudo apt-get install -y clang-format
64+
find . -regex '.*\.\(cpp\|hpp\|cc\|cxx\)' -exec clang-format -style=file -i {} \;
4765
4866
- name: If needed raise error
4967
run: |
5068
5169
if [[ `git status --porcelain --untracked-files=no` ]]; then
52-
echo "Formatting not correct! See blow the files which need to be reformatted!"
70+
echo "Formatting not correct! See below the files which need to be reformatted!"
5371
git status --porcelain --untracked-files=no
5472
exit 1
5573
fi

.github/workflows/main.yml

Lines changed: 28 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -22,29 +22,34 @@ on:
2222
jobs:
2323

2424
build-cpp-test-linux:
25-
runs-on: ubuntu-latest
26-
container: ghcr.io/alliander-opensource/power-grid-model-build-env:latest
25+
if: (github.event_name == 'push') || (github.event_name == 'workflow_dispatch') || (!startsWith(github.head_ref, 'release'))
26+
runs-on: ubuntu-22.04
2727
strategy:
2828
matrix:
2929
build-option: [ Debug, Release ]
30-
sparse-solver: [ EIGEN, MKL, MKL_RUNTIME ]
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
36-
run: ./build.sh ${{ matrix.build-option }} ${{ matrix.sparse-solver }}
37-
45+
run: ./build.sh ${{ matrix.build-option }}
3846

3947
build-cpp-test-windows:
48+
if: (github.event_name == 'push') || (github.event_name == 'workflow_dispatch') || (!startsWith(github.head_ref, 'release'))
4049
runs-on: windows-latest
4150
strategy:
4251
matrix:
4352
build-option: [ Debug, Release ]
44-
sparse-solver: [ EIGEN, MKL, MKL_RUNTIME ]
45-
env:
46-
MKL_INCLUDE: C:\conda_envs\cpp_pkgs\Library\include
47-
MKL_LIB: C:\conda_envs\cpp_pkgs\Library\lib
4853

4954
steps:
5055
- uses: actions/checkout@v3
@@ -54,61 +59,48 @@ jobs:
5459
& "$env:CONDA\condabin\conda" init
5560
5661
- name: Install conda environment
57-
# TODO removed pinned v2 of catch2, see https://github.com/alliander-opensource/power-grid-model/issues/73
5862
run: |
59-
conda create --yes -p C:\conda_envs\cpp_pkgs -c conda-forge boost-cpp eigen nlohmann_json mkl mkl-devel mkl-include catch2==2.13.9
63+
conda create --yes -p C:\conda_envs\cpp_pkgs -c conda-forge boost-cpp eigen nlohmann_json doctest
6064
6165
- name: Build and test
6266
run: |
6367
$vsPath = &(Join-Path ${env:ProgramFiles(x86)} '\Microsoft Visual Studio\Installer\vswhere.exe') -property installationpath
6468
Import-Module (Join-Path $vsPath 'Common7\Tools\Microsoft.VisualStudio.DevShell.dll')
6569
Enter-VsDevShell -VsInstallPath $vsPath -SkipAutomaticLocation -DevCmdArguments '-arch=x64 -host_arch=x64'
66-
$env:Path += ";C:\conda_envs\cpp_pkgs\Library\bin"
67-
mkdir cpp_build_${{ matrix.build-option }}_${{ matrix.sparse-solver }}
68-
cd cpp_build_${{ matrix.build-option }}_${{ matrix.sparse-solver }}
70+
mkdir cpp_build_${{ matrix.build-option }}
71+
cd cpp_build_${{ matrix.build-option }}
6972
# generate cmake cache
7073
cmake .. `
7174
-G "Ninja" `
7275
-DCMAKE_BUILD_TYPE=${{ matrix.build-option }} `
73-
-DPOWER_GRID_MODEL_SPARSE_SOLVER=${{ matrix.sparse-solver }} `
7476
-DCMAKE_PREFIX_PATH=C:\conda_envs\cpp_pkgs\Library `
7577
-DPOWER_GRID_MODEL_BUILD_BENCHMARK=1
7678
# build
77-
cmake --build . --verbose
79+
cmake --build . --verbose -j 1
7880
# test
7981
.\tests\cpp_unit_tests\power_grid_model_unit_tests.exe
8082
81-
8283
build-cpp-test-macos:
84+
if: (github.event_name == 'push') || (github.event_name == 'workflow_dispatch') || (!startsWith(github.head_ref, 'release'))
8385
runs-on: macos-latest
8486
strategy:
8587
matrix:
8688
build-option: [ Debug, Release ]
87-
sparse-solver: [ EIGEN, MKL, MKL_RUNTIME ]
8889
env:
8990
CC: clang
9091
CXX: clang++
91-
MKL_INCLUDE: /usr/local/include
92-
MKL_LIB: /usr/local/lib
9392
CMAKE_PREFIX_PATH: /usr/local
9493

9594
steps:
9695
- uses: actions/checkout@v3
9796

9897
- name: Install cpp dependencies
99-
# TODO removed pinned v2 of catch2, see https://github.com/alliander-opensource/power-grid-model/issues/73
10098
run: |
101-
brew install ninja boost eigen nlohmann-json
102-
curl https://raw.githubusercontent.com/Homebrew/homebrew-core/5e5abb11bf49787d01164c4066119365262c21ed/Formula/catch2.rb > $(find $(brew --repository) -name catch2.rb) && brew reinstall catch2
103-
sudo pip3 install mkl mkl-devel mkl-include
99+
brew install ninja boost eigen nlohmann-json doctest
104100
105101
- name: Build and test
106102
run: |
107-
# environment
108-
export LD_LIBRARY_PATH=${MKL_LIB}:${LD_LIBRARY_PATH}
109-
# bash
110-
./build.sh ${{ matrix.build-option }} ${{ matrix.sparse-solver }}
111-
103+
./build.sh ${{ matrix.build-option }}
112104
113105
build-and-test-python:
114106
strategy:
@@ -119,61 +111,39 @@ jobs:
119111
os: ubuntu-latest
120112
cc: gcc
121113
cxx: g++
122-
boost:
123-
eigen:
124114
cibw_build: "cp*-manylinux_x86_64 cp*-manylinux_aarch64"
125-
test_cmd: >
126-
pytest {package}/tests &&
127-
LD_LIBRARY_PATH= pytest {package}/tests
128115
archs: "x86_64 aarch64"
129116
- platform: macos
130117
os: macos-latest
131118
cc: clang
132119
cxx: clang++
133-
boost: /usr/local/include
134-
eigen: /usr/local/include/eigen3
135120
cibw_build: cp*-macosx_*
136121
archs: "x86_64 arm64"
137-
test_cmd: >
138-
pytest {package}/tests &&
139-
LD_LIBRARY_PATH=/usr/local/lib:${LD_LIBRARY_PATH} pytest {package}/tests
140122
- platform: windows
141123
os: windows-latest
142124
cc:
143125
cxx:
144-
boost: C:\conda_envs\cpp_pkgs\Library\include
145-
eigen: C:\conda_envs\cpp_pkgs\Library\include\eigen3
146126
cibw_build: cp*-win_amd64
147127
archs: AMD64
148-
test_cmd: pytest {package}/tests
149128

150129
runs-on: ${{ matrix.os }}
151130
needs: [build-cpp-test-linux, build-cpp-test-windows, build-cpp-test-macos]
152131

153132
env:
154133
CC: ${{ matrix.cc }}
155134
CXX: ${{ matrix.cxx }}
156-
BOOST_INCLUDE: ${{ matrix.boost }}
157-
EIGEN_INCLUDE: ${{ matrix.eigen }}
158135
CIBW_BUILD_VERBOSITY: 1
159136
CIBW_BUILD_FRONTEND: "build"
160137
CIBW_BUILD: ${{ matrix.cibw_build }}
161138
CIBW_ARCHS: ${{ matrix.archs }}
162-
CIBW_TEST_REQUIRES: pytest pytest-cov
163-
CIBW_TEST_COMMAND: ${{ matrix.test_cmd }}
139+
CIBW_TEST_EXTRAS: "dev"
140+
CIBW_TEST_COMMAND: pytest {package}/tests
164141
# Skip trying to test arm64 builds on Intel Macs
165142
CIBW_TEST_SKIP: "*-macosx_arm64 *-macosx_universal2:arm64"
166-
CIBW_MANYLINUX_X86_64_IMAGE: ghcr.io/alliander-opensource/power-grid-model-build-env
167-
CIBW_MANYLINUX_AARCH64_IMAGE: ghcr.io/alliander-opensource/power-grid-model-build-env-arm64
168-
CIBW_ENVIRONMENT_PASS_LINUX: GITHUB_SHA GITHUB_REF GITHUB_RUN_NUMBER
169-
CIBW_BEFORE_ALL_MACOS: >
170-
which clang++ &&
171-
clang++ --version &&
172-
brew install boost eigen &&
173-
sudo pip3 install mkl mkl-devel mkl-include
143+
CIBW_ENVIRONMENT_PASS_LINUX: GITHUB_SHA GITHUB_REF GITHUB_RUN_NUMBER CC CXX
174144
MACOSX_DEPLOYMENT_TARGET: 10.15
175-
CIBW_BEFORE_ALL_WINDOWS : >
176-
conda create --yes -p C:\conda_envs\cpp_pkgs -c conda-forge boost-cpp eigen mkl
145+
CIBW_MANYLINUX_X86_64_IMAGE: manylinux2014
146+
CIBW_MANYLINUX_AARCH64_IMAGE: manylinux2014
177147

178148
steps:
179149
- uses: actions/checkout@v3
@@ -182,11 +152,6 @@ jobs:
182152
if: matrix.platform == 'linux'
183153
uses: docker/setup-qemu-action@v2
184154

185-
- name: Activate conda for windows
186-
if: matrix.platform == 'windows'
187-
run: |
188-
& "$env:CONDA\condabin\conda" init
189-
190155
- name: Build wheels
191156
uses: pypa/[email protected]
192157

@@ -196,7 +161,6 @@ jobs:
196161
name: wheelhouse
197162
path: ./wheelhouse/*.whl
198163

199-
200164
publish-wheels:
201165
needs: build-and-test-python
202166
runs-on: ubuntu-latest
@@ -247,3 +211,4 @@ jobs:
247211
tag_name: ${{ steps.tag.outputs.tag }}
248212
prerelease: ${{ contains(steps.tag.outputs.tag, 'rc') }}
249213
generate_release_notes: true
214+
target_commitish: ${{ github.sha }}

.github/workflows/reuse-compliance.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ on:
1616

1717
jobs:
1818
reuse-compliance-check:
19+
if: (github.event_name == 'push') || (!startsWith(github.head_ref, 'release'))
1920
runs-on: ubuntu-latest
2021
steps:
2122
- name: checkout

.github/workflows/sonar.yml

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,28 +9,45 @@ on:
99
push:
1010
branches:
1111
- main
12+
- 'release/**'
13+
1214
# run pipeline on pull request
1315
pull_request:
1416

1517

1618
jobs:
1719
sonar-cloud:
20+
if: (github.event_name == 'push') || (!startsWith(github.head_ref, 'release'))
1821
name: SonarCloud
19-
runs-on: ubuntu-latest
20-
container: ghcr.io/alliander-opensource/power-grid-model-build-env-sonar:latest
22+
runs-on: ubuntu-22.04
2123
env:
2224
SONAR_SCANNER_VERSION: 4.4.0.2170
2325
SONAR_SERVER_URL: "https://sonarcloud.io"
2426
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
2531
steps:
2632
- uses: actions/checkout@v3
2733
with:
2834
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
2942
- name: Set up JDK 11
3043
uses: actions/setup-java@v3
3144
with:
3245
java-version: 11
3346
distribution: 'microsoft'
47+
- name: Set up Python
48+
uses: actions/setup-python@v4
49+
with:
50+
python-version: "3.10"
3451
- name: Download and set up sonar-scanner
3552
env:
3653
SONAR_SCANNER_DOWNLOAD_URL: https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-${{ env.SONAR_SCANNER_VERSION }}-linux.zip
@@ -49,16 +66,15 @@ jobs:
4966
5067
- name: Python test and coverage
5168
run: |
52-
/opt/venv/bin/pip install -e .
53-
/opt/venv/bin/pip install -r dev-requirements.txt
54-
/opt/venv/bin/pytest
69+
pip install -e .[dev]
70+
pytest
5571
# remove cython generated cpp file
5672
rm -rf src/power_grid_model/*.cpp
5773
5874
- name: Run build-wrapper for C++
5975
run: |
6076
mkdir cpp_build
61-
cmake -S . -B cpp_build -GNinja -DCMAKE_BUILD_TYPE=Debug -DPOWER_GRID_MODEL_SPARSE_SOLVER=EIGEN -DCMAKE_PREFIX_PATH=${CMAKE_PREFIX_PATH}
77+
cmake -S . -B cpp_build -GNinja -DCMAKE_BUILD_TYPE=Debug -DPOWER_GRID_MODEL_COVERAGE=1
6278
VERBOSE=1 build-wrapper-linux-x86-64 --out-dir ${{ env.BUILD_WRAPPER_OUT_DIR }} cmake --build cpp_build/
6379
6480
- name: C++ test and coverage
@@ -71,7 +87,8 @@ jobs:
7187
sed -i -r "s/\s*branchesToCover\s*=\s*\"[0-9]+\"\s+coveredBranches\s*=\s*\"[0-9]+\"//g" cpp_coverage.xml
7288
7389
- name: Run sonar-scanner
74-
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'
7592
env:
7693
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
7794
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}

0 commit comments

Comments
 (0)