Skip to content

Commit

Permalink
add framework
Browse files Browse the repository at this point in the history
Signed-off-by: Martijn Govers <[email protected]>
  • Loading branch information
mgovers committed Aug 19, 2024
1 parent f4bfa74 commit ae5f884
Show file tree
Hide file tree
Showing 58 changed files with 3,766 additions and 321 deletions.
14 changes: 14 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# SPDX-FileCopyrightText: Contributors to the Power Grid Model project <[email protected]>
#
# SPDX-License-Identifier: MPL-2.0

Language: Cpp
BasedOnStyle: LLVM
ColumnLimit: 120
IndentWidth: 4

# New settings

AlwaysBreakTemplateDeclarations: MultiLine
PackConstructorInitializers: NextLine
PointerAlignment: Left
30 changes: 30 additions & 0 deletions .clang-tidy
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# SPDX-FileCopyrightText: Contributors to the Power Grid Model project <[email protected]>
#
# SPDX-License-Identifier: MPL-2.0
---
Checks: '
-*,
boost-*,
bugprone-*,
cert-*,
clang-analyzer-*,
concurrency-*,
cppcoreguidelines-*,
darwin-*,
hiccp-*,
llvm-*,
google-*,
misc-*,
modernize-*,
performance-*,
portability-*,
readability-*,
'

WarningsAsErrors: '*'


HeaderFilterRegex: '.*'

FormatStyle: file
...
21 changes: 21 additions & 0 deletions .github/conda_pgm_env.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# SPDX-FileCopyrightText: Contributors to the Power Grid Model project <[email protected]>
#
# SPDX-License-Identifier: MPL-2.0

name: conda-pgm-env
dependencies:
# build env
- python=3.11
- pip
- wheel
- setuptools
# build deps
- libboost-headers
- eigen
- nlohmann_json
- msgpack-cxx
- numpy
# test deps
- pytest
- pytest-cov
- msgpack-python
8 changes: 8 additions & 0 deletions .github/dco.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# SPDX-FileCopyrightText: Contributors to the Power Grid Model project <[email protected]>
#
# SPDX-License-Identifier: MPL-2.0

allowRemediationCommits:
individual: true
thirdParty: true

10 changes: 10 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# SPDX-FileCopyrightText: Contributors to the Power Grid Model project <[email protected]>
#
# SPDX-License-Identifier: MPL-2.0

version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"
92 changes: 92 additions & 0 deletions .github/workflows/check-code-quality.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
# SPDX-FileCopyrightText: Contributors to the Power Grid Model project <[email protected]>
#
# SPDX-License-Identifier: MPL-2.0

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

name: Check Code Quality

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:

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

jobs:
check-code-quality:

runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.10'

- name: Upgrade pip
run: pip install --upgrade pip

- name: Install and run isort
run: |
pip install isort
isort .
- name: Install and run black
run: |
pip install black
black .
- name: Install and run mypy
run: |
pip install mypy
mypy .
- name: Install and run pylint
run: |
pip install pylint .
pylint power_grid_model
git restore README.md
- name: Install and run clang-format
run: |
sudo apt-get update && sudo apt-get install -y clang-format-15
find . -regex '.*\.\(h\|c\|cpp\|hpp\|cc\|cxx\)' -exec clang-format-15 -style=file -i {} \;
- name: If needed raise error
run: |
if [[ `git status --porcelain --untracked-files=no` ]]; then
echo "Formatting not correct! See below the files which need to be reformatted!"
git status --porcelain --untracked-files=no
exit 1
fi
- name: Check generated code
if: success()
run: |
pip install -r code_generation/requirements.txt
python code_generation/code_gen.py
if [ -n "$(git status --porcelain)" ]; then
echo
echo "The following files are outdated or were manually updated:"
git status --porcelain
exit 1
else
echo
echo "All the generated files are up to date."
fi
34 changes: 34 additions & 0 deletions .github/workflows/citations.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# SPDX-FileCopyrightText: Contributors to the Power Grid Model project <[email protected]>
#
# SPDX-License-Identifier: MPL-2.0

name: Validate citation

on:
# run pipeline on push event of main branch, or when CITATIONS path has changed
push:
branches:
- main
paths:
- CITATION.cff
- .github/workflows/citations.yml

pull_request:
paths:
- CITATION.cff
- .github/workflows/citations.yml

workflow_dispatch:

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

jobs:
validate-citations:
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout@v4
- name: Validate CITATION.cff
uses: dieghernan/cff-validator@v3
76 changes: 76 additions & 0 deletions .github/workflows/clang-tidy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
# SPDX-FileCopyrightText: Contributors to the Power Grid Model project <[email protected]>
#
# SPDX-License-Identifier: MPL-2.0

name: Clang Tidy

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:
target:
type: choice
description: The CMake target to run
default: power_grid_model_c
options:
- all
- power_grid_model_c
required: true

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

jobs:
clang-tidy:
runs-on: ubuntu-latest
strategy:
matrix:
build-option: [ debug, release ]

env:
CMAKE_PREFIX_PATH: /home/linuxbrew/.linuxbrew
PRESET: ci-clang-tidy-${{ matrix.build-option }}
TARGET: nonexistent # will be overwritten later in this action

steps:
- uses: actions/checkout@v4

- name: Install packages
run: |
sudo apt-get update
sudo apt-get install -y ninja-build clang-15 clang-tidy-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/clang-tidy-15 /usr/local/bin/clang-tidy
- 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: Set build target in case of push
if: github.event_name != 'workflow_dispatch'
run: |
echo "TARGET=power_grid_model_c" >> $GITHUB_ENV
- name: Set build target in case of workflow dispatch
if: github.event_name == 'workflow_dispatch'
run: |
echo "TARGET=${{ github.event.inputs.target }}" >> $GITHUB_ENV
- name: Build
run: |
cmake --preset ${{ env.PRESET }}
cmake --build --preset ${{ env.PRESET }} --target ${{ env.TARGET }}
22 changes: 22 additions & 0 deletions .github/workflows/dco-merge-group.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# SPDX-FileCopyrightText: Contributors to the Power Grid Model project <[email protected]>
#
# SPDX-License-Identifier: MPL-2.0

name: DCO for merge groups
# Workaround because DCO plugin does not run on merge group. See https://github.com/dcoapp/app/issues/199

# Controls when the workflow will run
on:
# run pipeline on merge queue because DCO plugin does not
merge_group:
# Any other signals are handled by the actual DCO plugin

jobs:
dco-merge-group:
name: DCO
runs-on: ubuntu-latest
if: ${{ github.actor != 'dependabot[bot]' }}
steps:
- name: "Workaround for DCO on merge groups"
run: |
echo "Workaround: signal DCO for merge queues because DCO plugin does not run for merge queues. See https://github.com/dcoapp/app/issues/199"
Loading

0 comments on commit ae5f884

Please sign in to comment.