From 3bfe8f8b914386af0fc0844061c95126ac1b97d6 Mon Sep 17 00:00:00 2001 From: Damien Jeandemange Date: Mon, 16 Dec 2024 11:08:36 +0100 Subject: [PATCH 1/9] Create snapshot CI Signed-off-by: Damien Jeandemange --- .github/scripts/check_integration_branch.sh | 17 +++ .github/workflows/snapshot-ci.yml | 120 ++++++++++++++++++++ 2 files changed, 137 insertions(+) create mode 100644 .github/scripts/check_integration_branch.sh create mode 100644 .github/workflows/snapshot-ci.yml diff --git a/.github/scripts/check_integration_branch.sh b/.github/scripts/check_integration_branch.sh new file mode 100644 index 0000000..0ffd0c9 --- /dev/null +++ b/.github/scripts/check_integration_branch.sh @@ -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") + +# Find 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 "SNAPSHOT VERSION EXIST: $INTEGRATION_BRANCH" + echo "INTEGRATION_BRANCH=$INTEGRATION_BRANCH" >> "$GITHUB_ENV" +else + echo "No SNAPSHOT branch found" + echo "INTEGRATION_BRANCH=main" >> "$GITHUB_ENV" +fi diff --git a/.github/workflows/snapshot-ci.yml b/.github/workflows/snapshot-ci.yml new file mode 100644 index 0000000..1045ffc --- /dev/null +++ b/.github/workflows/snapshot-ci.yml @@ -0,0 +1,120 @@ +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 + + 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 }} + + # Define script path variable + - name: Set up script path + 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 + + # 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_snapshot_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.SNAPSHOT_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: Set up JDK 17 + uses: actions/setup-java@v4 + with: + distribution: 'temurin' + java-version: '17' + + - 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 }} From c9c3e84c3238059496fdc358096e1ccfdadddf07 Mon Sep 17 00:00:00 2001 From: Damien Jeandemange Date: Mon, 16 Dec 2024 11:12:57 +0100 Subject: [PATCH 2/9] Create snapshot CI Signed-off-by: Damien Jeandemange --- .github/workflows/snapshot-ci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/snapshot-ci.yml b/.github/workflows/snapshot-ci.yml index 1045ffc..af83ac4 100644 --- a/.github/workflows/snapshot-ci.yml +++ b/.github/workflows/snapshot-ci.yml @@ -2,6 +2,7 @@ name: Snapshot CI on: workflow_dispatch: + push: #tmp schedule: - cron: '30 3 * * *' From b3882848b129e490d6b2fb30cebed0019966c6af Mon Sep 17 00:00:00 2001 From: Damien Jeandemange Date: Mon, 16 Dec 2024 11:16:26 +0100 Subject: [PATCH 3/9] fix Signed-off-by: Damien Jeandemange --- .github/workflows/snapshot-ci.yml | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/.github/workflows/snapshot-ci.yml b/.github/workflows/snapshot-ci.yml index af83ac4..446bfbb 100644 --- a/.github/workflows/snapshot-ci.yml +++ b/.github/workflows/snapshot-ci.yml @@ -41,6 +41,7 @@ jobs: # 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 @@ -92,17 +93,17 @@ jobs: - 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: Set up JDK 17 uses: actions/setup-java@v4 with: distribution: 'temurin' java-version: '17' + - 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: | From f87cc610729a4e946b8f442d5432ad9a41ba442e Mon Sep 17 00:00:00 2001 From: Damien Jeandemange Date: Mon, 16 Dec 2024 11:26:08 +0100 Subject: [PATCH 4/9] fix Signed-off-by: Damien Jeandemange --- .github/workflows/snapshot-ci.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/snapshot-ci.yml b/.github/workflows/snapshot-ci.yml index 446bfbb..4478c40 100644 --- a/.github/workflows/snapshot-ci.yml +++ b/.github/workflows/snapshot-ci.yml @@ -13,7 +13,10 @@ jobs: 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' From f98215b50abce4d5219bfae9c346735d26fbe47b Mon Sep 17 00:00:00 2001 From: Damien Jeandemange Date: Mon, 16 Dec 2024 11:33:13 +0100 Subject: [PATCH 5/9] fix Signed-off-by: Damien Jeandemange --- .github/{ => workflows}/scripts/check_integration_branch.sh | 0 .github/workflows/snapshot-ci.yml | 3 ++- 2 files changed, 2 insertions(+), 1 deletion(-) rename .github/{ => workflows}/scripts/check_integration_branch.sh (100%) diff --git a/.github/scripts/check_integration_branch.sh b/.github/workflows/scripts/check_integration_branch.sh similarity index 100% rename from .github/scripts/check_integration_branch.sh rename to .github/workflows/scripts/check_integration_branch.sh diff --git a/.github/workflows/snapshot-ci.yml b/.github/workflows/snapshot-ci.yml index 4478c40..92986bd 100644 --- a/.github/workflows/snapshot-ci.yml +++ b/.github/workflows/snapshot-ci.yml @@ -50,7 +50,8 @@ jobs: if [[ "${{ matrix.os }}" == "windows-latest" ]]; then SCRIPTS_PATH=$(echo "$SCRIPTS_PATH" | sed 's/\\/\//g') fi - echo "SCRIPTS_PATH=$SCRIPTS_PATH" >> $GITHUB_ENV + echo "SCRIPTS_PATH=$SCRIPTS_PATH" >> $GITHUB_ENV + git config --system core.longpaths true # Build powsybl-core on main branch - name: Checkout core sources From 890c79431255435e800be5167b71c9c8e644cef9 Mon Sep 17 00:00:00 2001 From: Damien Jeandemange Date: Mon, 16 Dec 2024 11:44:44 +0100 Subject: [PATCH 6/9] fix Signed-off-by: Damien Jeandemange --- .github/workflows/snapshot-ci.yml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/workflows/snapshot-ci.yml b/.github/workflows/snapshot-ci.yml index 92986bd..06041be 100644 --- a/.github/workflows/snapshot-ci.yml +++ b/.github/workflows/snapshot-ci.yml @@ -42,6 +42,12 @@ jobs: 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 @@ -51,7 +57,7 @@ jobs: SCRIPTS_PATH=$(echo "$SCRIPTS_PATH" | sed 's/\\/\//g') fi echo "SCRIPTS_PATH=$SCRIPTS_PATH" >> $GITHUB_ENV - git config --system core.longpaths true + git config --global core.longpaths true # Build powsybl-core on main branch - name: Checkout core sources @@ -97,12 +103,6 @@ jobs: - name: Checkout sources uses: actions/checkout@v4 - - name: Set up JDK 17 - uses: actions/setup-java@v4 - with: - distribution: 'temurin' - java-version: '17' - - name: update pom.xml with snapshot versions run: | mvn versions:set-property -Dproperty=powsybl-core.version -DnewVersion=$CORE_VERSION -DgenerateBackupPoms=false From 5d941a7f79f150243e6646330b71dd68f9658b21 Mon Sep 17 00:00:00 2001 From: Damien Jeandemange Date: Mon, 16 Dec 2024 12:04:51 +0100 Subject: [PATCH 7/9] fix Signed-off-by: Damien Jeandemange --- .github/workflows/scripts/check_integration_branch.sh | 0 .github/workflows/snapshot-ci.yml | 4 ++-- 2 files changed, 2 insertions(+), 2 deletions(-) mode change 100644 => 100755 .github/workflows/scripts/check_integration_branch.sh diff --git a/.github/workflows/scripts/check_integration_branch.sh b/.github/workflows/scripts/check_integration_branch.sh old mode 100644 new mode 100755 diff --git a/.github/workflows/snapshot-ci.yml b/.github/workflows/snapshot-ci.yml index 06041be..ace29a3 100644 --- a/.github/workflows/snapshot-ci.yml +++ b/.github/workflows/snapshot-ci.yml @@ -86,12 +86,12 @@ jobs: # Build powsybl-open-loadflow snapshot - name: Checking for open-loadflow snapshot branch - run : ${{ env.SCRIPTS_PATH }}/check_snapshot_branch.sh "https://github.com/powsybl/powsybl-open-loadflow.git" ${{ env.CORE_VERSION }} + 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.SNAPSHOT_BRANCH }} + ref: ${{ env.INTEGRATION_BRANCH }} path: powsybl-open-loadflow - name: Build open-loadflow snapshot run: | From 0ecfbfe20ea195b3683b3d32ec632fdaf93d9ae3 Mon Sep 17 00:00:00 2001 From: Damien Jeandemange Date: Mon, 16 Dec 2024 12:11:07 +0100 Subject: [PATCH 8/9] clean Signed-off-by: Damien Jeandemange --- .github/workflows/scripts/check_integration_branch.sh | 6 +++--- .github/workflows/snapshot-ci.yml | 1 - 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/.github/workflows/scripts/check_integration_branch.sh b/.github/workflows/scripts/check_integration_branch.sh index 0ffd0c9..ea95c19 100755 --- a/.github/workflows/scripts/check_integration_branch.sh +++ b/.github/workflows/scripts/check_integration_branch.sh @@ -6,12 +6,12 @@ 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") -# Find if an integration branch exists +# 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 "SNAPSHOT VERSION EXIST: $INTEGRATION_BRANCH" + echo "Integration branch found: $INTEGRATION_BRANCH" echo "INTEGRATION_BRANCH=$INTEGRATION_BRANCH" >> "$GITHUB_ENV" else - echo "No SNAPSHOT branch found" + echo "No integration branch found, using main branch" echo "INTEGRATION_BRANCH=main" >> "$GITHUB_ENV" fi diff --git a/.github/workflows/snapshot-ci.yml b/.github/workflows/snapshot-ci.yml index ace29a3..0ad3a71 100644 --- a/.github/workflows/snapshot-ci.yml +++ b/.github/workflows/snapshot-ci.yml @@ -2,7 +2,6 @@ name: Snapshot CI on: workflow_dispatch: - push: #tmp schedule: - cron: '30 3 * * *' From e62a9dac7d4f803f4222ea2865ee1ffc917fbc98 Mon Sep 17 00:00:00 2001 From: Damien Jeandemange Date: Mon, 16 Dec 2024 12:18:57 +0100 Subject: [PATCH 9/9] snapshot ci badge Signed-off-by: Damien Jeandemange --- README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 2ed0d83..db6e470 100644 --- a/README.md +++ b/README.md @@ -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.