Skip to content

Commit

Permalink
Merge pull request #1 from PowerGridModel/feature/add-framework
Browse files Browse the repository at this point in the history
add framework
  • Loading branch information
mgovers authored Aug 20, 2024
2 parents f4bfa74 + 401d524 commit 1330359
Show file tree
Hide file tree
Showing 58 changed files with 3,650 additions and 1 deletion.
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
35 changes: 35 additions & 0 deletions .clang-tidy
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# 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-*,
-cppcoreguidelines-owning-memory,
darwin-*,
hiccp-*,
llvm-*,
-llvm-header-guard,
google-*,
-google-build-using-namespace,
misc-*,
modernize-*,
-modernize-use-trailing-return-type,
performance-*,
portability-*,
readability-*,
-readability-identifier-length,
'

WarningsAsErrors: '*'


HeaderFilterRegex: '.*'

FormatStyle: file
...
22 changes: 22 additions & 0 deletions .github/conda_pgm_env.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: conda-pgm-env
dependencies:
# build env
- python=3.11
- pip
- wheel
- setuptools
# build deps
- libboost-headers
- eigen
- nlohmann_json
- msgpack-cxx
- numpy
- power-grid-model
# 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"
79 changes: 79 additions & 0 deletions .github/workflows/check-code-quality.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
# 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
with:
submodules: 'true'

- 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
mkdir -p .mypy_cache
mypy .
- name: Install and run pylint
run: |
pip install pylint .
pylint power_grid_model_io_native
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 --ignore-submodules=dirty` ]]; then
echo "Formatting not correct! See below the files which need to be reformatted!"
git status --porcelain --untracked-files=no --ignore-submodules=dirty
exit 1
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
78 changes: 78 additions & 0 deletions .github/workflows/clang-tidy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
# 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_io_native_c
options:
- all
- power_grid_model_io_native_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
with:
submodules: 'true'

- 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_io_native_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 1330359

Please sign in to comment.