Skip to content

[Feature] Check generated code #2

[Feature] Check generated code

[Feature] Check generated code #2

# SPDX-FileCopyrightText: Contributors to the Power Grid Model project <powergridmodel@lfenergy.org>
#
# SPDX-License-Identifier: MPL-2.0
name: Check Generated Code
on:
# run pipeline on push event of main branch
push:
branches:
- main
paths:
- code_generation/**
- .github/workflows/*
- power_grid_model_c/power_grid_model/include/power_grid_model/auxiliary/**
- power_grid_model_c/power_grid_model_c/**
- src/power_grid_model/core/**
- pyproject.toml
# run pipeline on pull request
pull_request:
paths:
- code_generation/**
- .github/workflows/*
- power_grid_model_c/power_grid_model/include/power_grid_model/auxiliary/**
- power_grid_model_c/power_grid_model_c/**
- src/power_grid_model/core/**
- pyproject.toml
# run pipeline on merge queue
merge_group:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
check-generated-code:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: 3.9
- name: Install dependencies
run: |
pip install --upgrade pip
pip install -r code_generation/requirements.txt
- name: Generate code
run: python code_generation/code_gen.py
- name: Check generated code
run: |
if [ -n "$(git status --porcelain)" ]; then
echo "The following files are outdated or were manually updated:"
git status --porcelain
exit 1
else
echo "All the generated files are up to date."
fi