Skip to content

snapshot ci

snapshot ci #17

Workflow file for this run

name: Snapshot CI
env:
CORE_VERSION: ''
LOADFLOW_VERSION: ''
DIAGRAM_VERSION: ''
ENTSOE_VERSION: ''
OPENRAO_VERSION: ''
DYNAWO_VERSION: ''
DEPENDENCIES_VERSION: ''
on:
workflow_dispatch:
schedule:
- cron: '0 3 * * *'
push:
branches:
- snapshot_ci
jobs:
build_pypowsybl:
name: Build ${{ matrix.config.name }} ${{ matrix.python.name }} wheel
runs-on: ${{ matrix.config.os }}
strategy:
matrix:
config:
- { name: ubuntu, os: ubuntu-latest, sed_inplace: "-i" }
python:
- { name: cp38, version: '3.8' }
steps:
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '17'
- name: Set up Python ${{ matrix.python.version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python.version }}
- name: Install Python dependencies
run: python -m pip install --upgrade pip
- name: Setup GraalVM
uses: graalvm/setup-graalvm@v1.1.5
with:
java-version: '17'
distribution: 'graalvm'
github-token: ${{ secrets.GITHUB_TOKEN }}
#BUILD CORE
- name: Checkout core-sources
uses: actions/checkout@v4
with:
repository: powsybl/powsybl-core
ref: main
- name: Build with Maven
run: mvn -batch-mode --no-transfer-progress clean install -DskipTests
shell: bash
- name: Get core version
run: echo "CORE_VERSION=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)" >> $GITHUB_ENV
shell: bash
- name: Build and install dependencies
id: build_deps
run: |
REPOS="powsybl/powsybl-open-loadflow powsybl/powsybl-diagram powsybl/powsybl-entsoe powsybl/powsybl-open-rao powsybl/powsybl-dynawo"
for repo in $REPOS
do
echo "Processing $repo"
SNAPSHOT_BRANCH=$(git ls-remote --heads https://github.com/$repo.git | grep -E "refs/heads/$(echo $CORE_VERSION | grep -q SNAPSHOT && echo "$CORE_VERSION" || echo "$CORE_VERSION-SNAPSHOT")" | sed 's/.*refs\/heads\///')
if [ -n "$SNAPSHOT_BRANCH" ]; then
echo "SNAPSHOT VERSION EXIST: $SNAPSHOT_BRANCH"
BRANCH="$SNAPSHOT_BRANCH"
else
echo "No SNAPSHOT branch found"
BRANCH="main"
fi
git clone -b $BRANCH https://github.com/$repo.git
cd $(basename $repo)
if [ "$repo" == "powsybl/powsybl-open-loadflow" ] || [ "$repo" == "powsybl/powsybl-diagram" ] || [ "$repo" == "powsybl/powsybl-dynawo" ]; then
sed ${{ matrix.config.sed_inplace }} 's|<powsybl-core.version>.*</powsybl-core.version>|<powsybl-core.version>'"$CORE_VERSION"'</powsybl-core.version>|' pom.xml
fi
if [ "$repo" == "powsybl/powsybl-entsoe" ]; then
sed ${{ matrix.config.sed_inplace }} 's|<powsyblcore.version>.*</powsyblcore.version>|<powsyblcore.version>'"$CORE_VERSION"'</powsyblcore.version>|' pom.xml
sed ${{ matrix.config.sed_inplace }} 's|<powsyblopenloadflow.version>.*</powsyblopenloadflow.version>|<powsyblopenloadflow.version>'"$POWSYBL_OPEN_LOADFLOW_VERSION"'</powsyblopenloadflow.version>|' pom.xml
fi
if [ "$repo" == "powsybl/powsybl-open-rao" ]; then
sed ${{ matrix.config.sed_inplace }} 's|<powsybl.core.version>.*</powsybl.core.version>|<powsybl.core.version>'"$CORE_VERSION"'</powsybl.core.version>|' pom.xml
sed ${{ matrix.config.sed_inplace }} 's|<powsybl-entsoe.version>.*</powsybl-entsoe.version>|<powsybl-entsoe.version>'"$POWSYBL_ENTSOE_VERSION"'</powsybl-entsoe.version>|' pom.xml
sed ${{ matrix.config.sed_inplace }} 's|<powsybl.openloadflow.version>.*</powsybl.openloadflow.version>|<powsybl.openloadflow.version>'"$POWSYBL_OPEN_LOADFLOW_VERSION"'</powsybl.openloadflow.version>|' pom.xml
fi
mvn -batch-mode --no-transfer-progress clean install -DskipTests
VERSION=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)
repo_name=$(echo $repo | cut -d'/' -f2 | tr '-' '_' | tr '[:lower:]' '[:upper:]')
echo "${repo_name}_VERSION=$VERSION" >> $GITHUB_ENV
echo "${repo_name}_VERSION=$VERSION"
cd ..
done
shell: bash
- name: Checkout powsybl-dependencies
uses: actions/checkout@v4
with:
repository: powsybl/powsybl-dependencies
ref: main
- name: Update dependencies versions
run: |
mvn versions:set-property -Dproperty=powsybl-open-loadflow.version -DnewVersion=$POWSYBL_OPEN_LOADFLOW_VERSION -DgenerateBackupPoms=false
mvn versions:set-property -Dproperty=powsybl-core.version -DnewVersion=$POWSYBL_CORE_VERSION -DgenerateBackupPoms=false
mvn versions:set-property -Dproperty=powsybl-diagram.version -DnewVersion=$POWSYBL_DIAGRAM_VERSION -DgenerateBackupPoms=false
mvn versions:set-property -Dproperty=powsybl-dynawo.version -DnewVersion=$POWSYBL_DYNAWO_VERSION -DgenerateBackupPoms=false
mvn versions:set-property -Dproperty=powsybl-entsoe.version -DnewVersion=$POWSYBL_ENTSOE_VERSION -DgenerateBackupPoms=false
mvn versions:set-property -Dproperty=powsybl-open-rao.version -DnewVersion=$POWSYBL_OPEN_RAO_VERSION -DgenerateBackupPoms=false
shell: bash
- name: Install powsybl-dependencies
run: |
mvn -batch-mode --no-transfer-progress clean install -DskipTests
echo "DEPENDENCIES_VERSION=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)" >> $GITHUB_ENV
shell: bash
- name: Checkout PyPowSyBl
uses: actions/checkout@v4
with:
submodules: true
- name: Change java-pom.xml
working-directory: ./java
run: mvn versions:set-property -Dproperty=powsybl-dependencies.version -DnewVersion=$DEPENDENCIES_VERSION -DgenerateBackupPoms=false
shell: bash
- name: Install dependencies
run: pip3 install -r requirements.txt
- name: Build wheel
run: python3 setup.py bdist_wheel ${{ matrix.config.bdist_wheel_args }}
shell: bash
- name: Install wheel
run: python -m pip install dist/*.whl --user
shell: bash
- name: Run tests
working-directory: ./tests
run: pytest
- name: Check pypowsybl versions
working-directory: ./tests
run: python3 basic_import_test.py
- name: Upload wheel
uses: actions/upload-artifact@v3
with:
name: pypowsybl-wheel-${{ matrix.config.name }}-${{ matrix.python.name }}
path: dist/*.whl
package:
name: Package wheels
runs-on: ubuntu-latest
needs: [build_pypowsybl]
steps:
- name: Download wheels
uses: actions/download-artifact@v3
with:
path: download
- name: Upload wheels
uses: actions/upload-artifact@v3
with:
name: pypowsybl-wheels
path: |
download/**/*.whl
- name: Release on PyPi
if: startsWith(github.ref, 'refs/tags/')
shell: bash
run: |
python -m pip install --user --upgrade twine
python -m twine upload --username __token__ --password ${{ secrets.PYPI_TOKEN }} download/*/*.whl