Skip to content

Change python to python3 to run the building #2046

Change python to python3 to run the building

Change python to python3 to run the building #2046

name: Build & Test Fedora
on:
push:
## Build ##
jobs:
linux-fedora-dpsimpy:
name: Build dpsimpy on Fedora Linux
runs-on: ubuntu-latest
container: sogno/dpsim:dev
steps:
- name: Checkout
uses: actions/checkout@v3
with:
submodules: recursive
- name: Create Build Environment
run: mkdir build
- name: Configure CMake
shell: bash
working-directory: ${{ github.workspace }}/build
run: cmake -DCIM_VERSION=CGMES_2.4.15_16FEB2016 $GITHUB_WORKSPACE
- name: Build dpsimpy and test examples
shell: bash
working-directory: ${{ github.workspace }}/build
run: cmake --build . --target dpsimpy --target tests --target dpsimpyvillas
env:
MAKEFLAGS: "-j2"
- name: Archive build directory
uses: actions/upload-artifact@v3
with:
path: ${{ github.workspace }}/build
name: build-cache
retention-days: 1
linux-fedora-examples:
name: Build Cxx examples on Fedora Linux
runs-on: ubuntu-latest
needs: [linux-fedora-dpsimpy]
container: sogno/dpsim:dev
steps:
- name: Checkout
uses: actions/checkout@v3
with:
submodules: recursive
- name: Restore build archive
uses: actions/download-artifact@v3
with:
name: build-cache
path: ${{ github.workspace }}/build
- name: Build every target
shell: bash
working-directory: ${{ github.workspace }}/build
run: cmake --build .
env:
MAKEFLAGS: "-j2"
- name: Archive build directory
uses: actions/upload-artifact@v3
with:
path: ${{ github.workspace }}/build
name: build-cache
retention-days: 1
## Tests ##
test-jupyter-notebooks:
name: Run pytest over all notebooks
runs-on: ubuntu-latest
needs: [linux-fedora-dpsimpy]
container: sogno/dpsim:dev
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Restore build archive
uses: actions/download-artifact@v3
with:
name: build-cache
path: ${{ github.workspace }}/build
- name: Prepare binary permissions
shell: bash
working-directory: ${{ github.workspace }}
run: |
chmod -R +x ./build/dpsim/examples/cxx
- name: Work around permission issue
run: git config --global --add safe.directory /__w/dpsim/dpsim
- name: Check for test binaries
shell: bash
working-directory: ${{ github.workspace }}
run: ls -l ./build/dpsim/examples/cxx/
- name: Run pytest
shell: bash
working-directory: ${{ github.workspace }}
env:
PYTHONPATH: "${{ github.workspace }}/build"
run: |
cp -r python/src/dpsim build/
pytest -v examples/Notebooks
- name: Archive notebook outputs
uses: actions/upload-artifact@v3
with:
name: pytest-output
path: outputs/examples/Notebooks/
compare-notebook-results:
name: Compare Notebook results
runs-on: ubuntu-latest
needs: [test-jupyter-notebooks]
steps:
- name: Download new notebook results
uses: actions/download-artifact@v3
with:
name: pytest-output
path: ${{ github.workspace }}/notebooks-new
- name: Download master notebook results
uses: actions/cache@v3
with:
path: ${{ github.workspace }}/notebooks-master
key: notebook-output-cache-master-${{ github.sha }}
restore-keys: |
notebook-output-cache-master-
- name: Download previous commit notebook results
uses: actions/cache@v3
with:
path: ${{ github.workspace }}/notebooks-previous
key: notebook-output-cache-commit-${{ github.ref }}-${{ github.sha }}
restore-keys: |
notebook-output-cache-commit-${{ github.ref }}-
- name: Compare current results with master
shell: bash
run: diff --color -r ${{ github.workspace }}/notebooks-new ${{ github.workspace }}/notebooks-master
continue-on-error: true
- name: Compare current results with previous commit
shell: bash
run: diff --color -r ${{ github.workspace }}/notebooks-new ${{ github.workspace }}/notebooks-previous
continue-on-error: true
- name: Cache new notebook results 1/2
shell: bash
run: |
rm -rf ${{ github.workspace }}/notebooks-previous
cp -R ${{ github.workspace }}/notebooks-new ${{ github.workspace }}/notebooks-previous
- name: Cache new notebook results 2/2
if: github.ref_name == 'master'
shell: bash
run: |
rm -rf ${{ github.workspace }}/notebooks-master
cp -R ${{ github.workspace }}/notebooks-new ${{ github.workspace }}/notebooks-master
test-binaries:
name: Execute Example
runs-on: ubuntu-latest
container: sogno/dpsim:dev
needs: [linux-fedora-examples]
steps:
- name: Restore build archive
uses: actions/download-artifact@v3
with:
name: build-cache
path: ${{ github.workspace }}/build
- name: Prepare binary permissions
shell: bash
run: |
chmod -R +x ./build/dpsim/examples/cxx
- name: Run Binaries 1/2
run: ./build/dpsim/examples/cxx/WSCC_9bus_mult_coupled
- name: Run Binaries 2/2
run: ./build/dpsim/examples/cxx/WSCC_9bus_mult_decoupled
cpp-check:
name: Scan Sourcecode with Cppcheck
runs-on: ubuntu-latest
container: sogno/dpsim:dev
#needs: [linux-fedora]
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Run cppcheck
working-directory: ${{ github.workspace }}
shell: bash
id: cppcheck
run: |
set -o pipefail
cppcheck --max-configs=32 -j 32 --inline-suppr --error-exitcode=1 -q --enable=warning,performance,portability,information,missingInclude --std=c++17 -I dpsim/include/ -I dpsim-models/include/ -I dpsim-villas/include dpsim/src/ dpsim-models/src/ dpsim-villas/src/ 2>&1 | tee cppcheck-output.log
continue-on-error: true
- name: Print cppcheck errors
if: ${{ always() && steps.cppcheck.outcome == 'failure' }}
working-directory: ${{ github.workspace }}
shell: bash
run: (! cat cppcheck-output.log | grep -A 2 "error:")
- name: Print cppcheck warnings
if: ${{ always() && steps.cppcheck.outcome == 'failure' }}
working-directory: ${{ github.workspace }}
shell: bash
run: (! cat cppcheck-output.log | grep -A 2 "warning:")
continue-on-error: true
- name: Print cppcheck performance
if: ${{ always() && steps.cppcheck.outcome == 'failure' }}
working-directory: ${{ github.workspace }}
shell: bash
run: (! cat cppcheck-output.log | grep -A 2 "performance:")
continue-on-error: true
- name: Print cppcheck portability
if: ${{ always() && steps.cppcheck.outcome == 'failure' }}
working-directory: ${{ github.workspace }}
shell: bash
run: (! cat cppcheck-output.log | grep -A 2 "portability:")
continue-on-error: true
- name: Print cppcheck missingInclude
if: ${{ always() && steps.cppcheck.outcome == 'failure' }}
working-directory: ${{ github.workspace }}
shell: bash
run: (! cat cppcheck-output.log | grep -A 2 "missingInclude:")
continue-on-error: true
- name: Print cppcheck information
if: ${{ always() && steps.cppcheck.outcome == 'failure' }}
working-directory: ${{ github.workspace }}
shell: bash
run: (! cat cppcheck-output.log | grep -A 2 "information:")
continue-on-error: true
- name: Print cppcheck notes
if: ${{ always() && steps.cppcheck.outcome == 'failure' }}
working-directory: ${{ github.workspace }}
shell: bash
run: (! cat cppcheck-output.log | grep -A 2 "note:")
continue-on-error: true
- name: Archive cppcheck output
uses: actions/upload-artifact@v3
if: ${{ always() && steps.cppcheck.outcome == 'failure' }}
with:
name: cppcheck-output
path: cppcheck-output.log
test-villas-examples-1:
name: Run dpsim-mqtt VILLASnode example
needs: [linux-fedora-dpsimpy]
uses: ./.github/workflows/run_villas_example.yaml
with:
compose_file_path: examples/villas/docker-compose-tests
container_commands: |
docker exec dpsim-compose_dpsim_1 /bin/bash -c "pip install paho-mqtt"
docker exec dpsim-compose_mqtt_1 mosquitto_sub -t "/dpsim-mqtt" -u wildcard -v&
docker exec dpsim-compose_dpsim_1 /bin/bash -c "cd /dpsim && python3 /dpsim/examples/villas/dpsim-mqtt-producer.py"&
docker exec dpsim-compose_dpsim_1 /bin/bash -c "cd /dpsim && python3 /dpsim/examples/villas/dpsim-mqtt.py"
test-villas-examples-2:
name: Run dpsim-mqtt-import-export VILLASnode example
needs: [linux-fedora-dpsimpy]
uses: ./.github/workflows/run_villas_example.yaml
with:
compose_file_path: examples/villas/docker-compose-tests
container_commands: |
docker exec dpsim-compose_mqtt_1 mosquitto_sub -t "#" -u wildcard -v&
docker exec dpsim-compose_dpsim_1 /bin/bash -c "cd /dpsim && python3 /dpsim/examples/villas/dpsim-mqtt-import-export.py"
test-villas-examples-3:
name: Run dpsim-mqtt-import-export-MIMO VILLASnode example
needs: [linux-fedora-dpsimpy]
uses: ./.github/workflows/run_villas_example.yaml
with:
compose_file_path: examples/villas/docker-compose-tests
continue_on_error: true
container_commands: |
docker exec dpsim-compose_mqtt_1 mosquitto_sub -t "#" -u wildcard -v&
docker exec dpsim-compose_dpsim_1 /bin/bash -c "cd /dpsim && python3 /dpsim/examples/villas/dpsim-mqtt-import-export-MIMO.py"
test-villas-examples-4:
name: Run dpsim-file VILLASnode example
needs: [linux-fedora-dpsimpy]
uses: ./.github/workflows/run_villas_example.yaml
with:
compose_file_path: examples/villas/docker-compose-tests
continue_on_error: true
container_commands: |
docker exec dpsim-compose_dpsim_1 /bin/bash -c "sleep 3 && tail -f /dpsim/logs/output.csv"&
docker exec dpsim-compose_dpsim_1 /bin/bash -c "cd /dpsim && python3 /dpsim/examples/villas/dpsim-file.py"
test-villas-examples-5:
name: Run mqtt-cigre-mv-pf-profiles VILLASnode example
needs: [linux-fedora-dpsimpy]
uses: ./.github/workflows/run_villas_example.yaml
with:
compose_file_path: examples/villas/docker-compose-tests
container_commands: |
docker exec dpsim-compose_mqtt_1 mosquitto_sub -t "#" -u wildcard -v&
docker exec dpsim-compose_dpsim_1 /bin/bash -c "cd /dpsim && python3 /dpsim/examples/villas/dpsim-mqtt-cigre-mv-pf-profiles.py"