Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create snapshot CI #4

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions .github/workflows/scripts/check_integration_branch.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/bash

repo=$1
core_version=$2

# Add "-SNAPSHOT" to powsybl-core version if not already there
core_snapshot_version=$(echo "$core_version" | grep -q SNAPSHOT && echo "$core_version" || echo "$core_version-SNAPSHOT")

# Check if an integration branch exists
INTEGRATION_BRANCH=$(git ls-remote --heads "$repo" | grep -E "refs/heads/integration/powsyblcore-$core_snapshot_version" | sed 's/.*refs\/heads\///')
if [ -n "$INTEGRATION_BRANCH" ]; then
echo "Integration branch found: $INTEGRATION_BRANCH"
echo "INTEGRATION_BRANCH=$INTEGRATION_BRANCH" >> "$GITHUB_ENV"
else
echo "No integration branch found, using main branch"
echo "INTEGRATION_BRANCH=main" >> "$GITHUB_ENV"
fi
125 changes: 125 additions & 0 deletions .github/workflows/snapshot-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
name: Snapshot CI

on:
workflow_dispatch:
schedule:
- cron: '30 3 * * *'

jobs:
build:
name: Build OS ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest] # macos-latest : Knitro does not yet support Java API on macOS, to be tried later on
fail-fast: false
defaults:
run:
shell: bash
steps:
- name: Install Knitro (Linux)
if: matrix.os == 'ubuntu-latest'
run: |
wget -nv -O knitro.tar.gz --user "$KNITRO_DOWNLOAD_USER" --password "$KNITRO_DOWNLOAD_PASSWORD" "$KNITRO_LINUX_URL"
mkdir -p $RUNNER_TEMP/knitro
tar xzf knitro.tar.gz -C $RUNNER_TEMP/knitro
echo "KNITRODIR=$RUNNER_TEMP/knitro/knitro-14.1.0-Linux64" >> "$GITHUB_ENV"
env:
KNITRO_DOWNLOAD_USER: ${{ secrets.KNITRO_DOWNLOAD_USER }}
KNITRO_DOWNLOAD_PASSWORD: ${{ secrets.KNITRO_DOWNLOAD_PASSWORD }}
KNITRO_LINUX_URL: ${{ secrets.KNITRO_LINUX_URL }}

- name: Install Knitro (Windows)
if: matrix.os == 'windows-latest'
shell: powershell
run: |
C:\msys64\usr\bin\wget.exe -nv -O knitro.zip --user "$env:KNITRO_DOWNLOAD_USER" --password "$env:KNITRO_DOWNLOAD_PASSWORD" "$env:KNITRO_WINDOWS_URL"
7z x -y knitro.zip -oC:\knitro
echo "KNITRODIR=C:\knitro\knitro-14.1.0-Win64" >> "$env:GITHUB_ENV"
env:
KNITRO_DOWNLOAD_USER: ${{ secrets.KNITRO_DOWNLOAD_USER }}
KNITRO_DOWNLOAD_PASSWORD: ${{ secrets.KNITRO_DOWNLOAD_PASSWORD }}
KNITRO_WINDOWS_URL: ${{ secrets.KNITRO_WINDOWS_URL }}

- name: Set up JDK 17
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '17'

# Define script path variable
- name: Set up script path
shell: bash
run: |
SCRIPTS_PATH="${GITHUB_WORKSPACE}/scripts/.github/workflows/scripts"
if [[ "${{ matrix.os }}" == "windows-latest" ]]; then
SCRIPTS_PATH=$(echo "$SCRIPTS_PATH" | sed 's/\\/\//g')
fi
echo "SCRIPTS_PATH=$SCRIPTS_PATH" >> $GITHUB_ENV
git config --global core.longpaths true

# Build powsybl-core on main branch
- name: Checkout core sources
uses: actions/checkout@v4
with:
repository: powsybl/powsybl-core
ref: main
path: powsybl-core

- name: Build powsybl-core
run: |
mvn -batch-mode --no-transfer-progress clean install -DskipTests
echo "CORE_VERSION=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)" >> $GITHUB_ENV
working-directory: ./powsybl-core

# Checkout script
# The script check_integration_branch.sh is located in the workflow folder of the repository
# It is necessary for checking out the integration branch if it exists
- name: Checkout script
uses: actions/checkout@v4
with:
sparse-checkout: |
.github
sparse-checkout-cone-mode: false
path: scripts

# Build powsybl-open-loadflow snapshot
- name: Checking for open-loadflow snapshot branch
run : ${{ env.SCRIPTS_PATH }}/check_integration_branch.sh "https://github.com/powsybl/powsybl-open-loadflow.git" ${{ env.CORE_VERSION }}
- name: Checkout open-loadflow sources
uses: actions/checkout@v4
with:
repository: powsybl/powsybl-open-loadflow
ref: ${{ env.INTEGRATION_BRANCH }}
path: powsybl-open-loadflow
- name: Build open-loadflow snapshot
run: |
mvn versions:set-property -Dproperty=powsybl-core.version -DnewVersion=${{ env.CORE_VERSION}} -DgenerateBackupPoms=false
mvn -batch-mode --no-transfer-progress clean install -DskipTests
echo "LOADFLOW_VERSION=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)" >> $GITHUB_ENV
working-directory: ./powsybl-open-loadflow

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

- name: update pom.xml with snapshot versions
run: |
mvn versions:set-property -Dproperty=powsybl-core.version -DnewVersion=$CORE_VERSION -DgenerateBackupPoms=false
mvn versions:set-property -Dproperty=powsybl-open-loadflow.version -DnewVersion=$LOADFLOW_VERSION -DgenerateBackupPoms=false

- name: Build with Maven (Ubuntu)
if: matrix.os != 'windows-latest'
run: |
./mvnw install:install-file -Dfile="$KNITRODIR/examples/Java/lib/Knitro-Interfaces-2.5-KN_14.1.0.jar" -DgroupId=com.artelys -DartifactId=knitro-interfaces -Dversion=14.1.0 -Dpackaging=jar -DgeneratePom=true
./mvnw --batch-mode -Pjacoco install
env:
ARTELYS_LICENSE: ${{ secrets.ARTELYS_LICENSE }}

- name: Build with Maven (Windows)
if: matrix.os == 'windows-latest'
run: |
call mvnw.cmd install:install-file -Dfile="%KNITRODIR%\examples\Java\lib\Knitro-Interfaces-2.5-KN_14.1.0.jar" -DgroupId=com.artelys -DartifactId=knitro-interfaces -Dversion=14.1.0 -Dpackaging=jar -DgeneratePom=true
mvnw.cmd --batch-mode install
shell: cmd
env:
ARTELYS_LICENSE: ${{ secrets.ARTELYS_LICENSE }}
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
# PowSyBl Open Load Flow - Knitro Solver

[![Actions Status](https://github.com/powsybl/powsybl-open-loadflow-knitro-solver/workflows/CI/badge.svg)](https://github.com/powsybl/powsybl-open-loadflow-knitro-solver/actions)
[![Actions Status](https://github.com/powsybl/powsybl-open-loadflow-knitro-solver/workflows/CI/badge.svg)](https://github.com/powsybl/powsybl-open-loadflow-knitro-solver/actions/workflows/maven.yml)
[![Snapshot Status](https://github.com/powsybl/powsybl-open-loadflow-knitro-solver/workflows/Snapshot%20CI/badge.svg)](https://github.com/powsybl/powsybl-open-loadflow-knitro-solver/actions/workflows/snapshot-ci.yml)
[![Coverage Status](https://sonarcloud.io/api/project_badges/measure?project=com.powsybl%3Apowsybl-open-loadflow-knitro-solver&metric=coverage)](https://sonarcloud.io/component_measures?id=com.powsybl%3Apowsybl-open-loadflow-knitro-solver&metric=coverage)
[![Quality Gate](https://sonarcloud.io/api/project_badges/measure?project=com.powsybl%3Apowsybl-open-loadflow-knitro-solver&metric=alert_status)](https://sonarcloud.io/dashboard?id=com.powsybl%3Apowsybl-open-loadflow-knitro-solver)
[![MPL-2.0 License](https://img.shields.io/badge/license-MPL_2.0-blue.svg)](https://www.mozilla.org/en-US/MPL/2.0/)
[![Slack](https://img.shields.io/badge/slack-powsybl-blueviolet.svg?logo=slack)](https://join.slack.com/t/powsybl/shared_invite/zt-rzvbuzjk-nxi0boim1RKPS5PjieI0rA)


PowSyBl (**Pow**er **Sy**stem **Bl**ocks) is an open source library written in Java, that makes it easy to write complex
software for power systems’ simulations and analysis. Its modular approach allows developers to extend or customize its
features.
Expand Down
Loading