Skip to content

snapshot ci

snapshot ci #31

Workflow file for this run

name: Snapshot CI
on:
push:
branches:
# on all branches except main where full build will be run
- '*'
- '!main'
jobs:
setup:
runs-on: ubuntu-latest
steps:
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '17'
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.8'
- 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 }}
- name: Cache Maven packages
uses: actions/cache@v3
with:
path: ~/.m2
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
restore-keys: ${{ runner.os }}-m2
build_core:
needs: setup
runs-on: ubuntu-latest
steps:
- name: Checkout core-sources
uses: actions/checkout@v4
with:
repository: powsybl/powsybl-core
ref: main
fetch-depth: 1
- name: Build with Maven
run: mvn -batch-mode --no-transfer-progress clean install -DskipTests
- name: Get core version
run: echo "CORE_VERSION=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)" >> $GITHUB_ENV
outputs:
core_version: ${{ env.CORE_VERSION }}
build_components:
needs: build_core
runs-on: ubuntu-latest
strategy:
matrix:
component: [ open-loadflow, diagram, entsoe, open-rao, dynawo ]
steps:
- name: Check for SNAPSHOT branch
run: |
SNAPSHOT_BRANCH=$(git ls-remote --sort=-committerdate --heads https://github.com/powsybl/powsybl-${{ matrix.component }}.git | grep 'refs/heads/.*SNAPSHOT' | head -n 1 | sed 's/.*refs\/heads\///')
if [ -n "$SNAPSHOT_BRANCH" ]; then
echo "SNAPSHOT_BRANCH=$SNAPSHOT_BRANCH" >> $GITHUB_ENV
else
echo "SNAPSHOT_BRANCH=main" >> $GITHUB_ENV
fi
- name: Checkout ${{ matrix.component }}-sources
uses: actions/checkout@v4
with:
repository: powsybl/powsybl-${{ matrix.component }}
ref: ${{ env.SNAPSHOT_BRANCH }}
fetch-depth: 1
- name: Update dependencies
run: |
sed -i 's|<powsybl-core.version>.*</powsybl-core.version>|<powsybl-core.version>${{ needs.build_core.outputs.core_version }}</powsybl-core.version>|' pom.xml
if [ "${{ matrix.component }}" = "entsoe" ]; then
sed -i 's|<powsyblcore.version>.*</powsyblcore.version>|<powsyblcore.version>'"$CORE_VERSION"'</powsyblcore.version>|' pom.xml
sed -i 's|<powsyblopenloadflow.version>.*</powsyblopenloadflow.version>|<powsyblopenloadflow.version>'"$LOADFLOW_VERSION"'</powsyblopenloadflow.version>|' pom.xml
fi
if [ "${{ matrix.component }}" = "open-rao" ]; then
sed -i 's|<powsybl.core.version>.*</powsybl.core.version>|<powsybl.core.version>'"$CORE_VERSION"'</powsybl.core.version>|' pom.xml
sed -i 's|<powsybl.entsoe.version>.*</powsybl.entsoe.version>|<powsybl.entsoe.version>'"$ENTSOE_VERSION"'</powsybl.entsoe.version>|' pom.xml
sed -i 's|<powsybl.openloadflow.version>.*</powsybl.openloadflow.version>|<powsybl.openloadflow.version>'"$LOADFLOW_VERSION"'</powsybl.openloadflow.version>|' pom.xml
fi
- name: Build with Maven
run: mvn -batch-mode --no-transfer-progress clean install -DskipTests
- name: Get component version
run: |
COMPONENT_VERSION=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)
echo "${matrix.component^^}_VERSION=$COMPONENT_VERSION" >> $GITHUB_ENV
outputs:
loadflow_version: ${{ env.LOADFLOW_VERSION }}
diagram_version: ${{ env.DIAGRAM_VERSION }}
entsoe_version: ${{ env.ENTSOE_VERSION }}
open_rao_version: ${{ env.OPEN_RAO_VERSION }}
dynawo_version: ${{ env.DYNAWO_VERSION }}
build_dependencies:
needs: build_components
runs-on: ubuntu-latest
steps:
- 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=${{ needs.build_components.outputs.loadflow_version }} -DgenerateBackupPoms=false
mvn versions:set-property -Dproperty=powsybl-core.version -DnewVersion=${{ needs.build_core.outputs.core_version }} -DgenerateBackupPoms=false
mvn versions:set-property -Dproperty=powsybl-diagram.version -DnewVersion=${{ needs.build_components.outputs.diagram_version }} -DgenerateBackupPoms=false
mvn versions:set-property -Dproperty=powsybl-dynawo.version -DnewVersion=${{ needs.build_components.outputs.dynawo_version }} -DgenerateBackupPoms=false
mvn versions:set-property -Dproperty=powsybl-entsoe.version -DnewVersion=${{ needs.build_components.outputs.entsoe_version }} -DgenerateBackupPoms=false
mvn versions:set-property -Dproperty=powsybl-open-rao.version -DnewVersion=${{ needs.build_components.outputs.open_rao_version }} -DgenerateBackupPoms=false
- name: Install powsybl-dependencies
run: mvn -batch-mode --no-transfer-progress clean install -DskipTests
- name: Get dependencies version
run: echo "DEPENDENCIES_VERSION=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)" >> $GITHUB_ENV
outputs:
dependencies_version: ${{ env.DEPENDENCIES_VERSION }}
build_and_test_pypowsybl:
needs: build_dependencies
runs-on: ubuntu-latest
steps:
- name: Checkout sources
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=${{ needs.build_dependencies.outputs.dependencies_version }} -DgenerateBackupPoms=false
- name: Install dependencies
run: pip3 install -r requirements.txt
- name: Build wheel
run: python3 setup.py bdist_wheel
- name: Install wheel
run: pip3 install dist/*.whl --user
- name: Run basic pypowsybl import
working-directory: ./tests
run: python3 basic_import_test.py
- name: Run tests
working-directory: ./tests
run: pytest