Skip to content

Snapshot CI

Snapshot CI #123

Workflow file for this run

name: Snapshot CI
on:
workflow_dispatch:
schedule:
- cron: '0 3 * * *'
env:
BUILD_STATUS: ${{ github.workspace }}/build_status.txt
jobs:
build_pypowsybl:
name: Build ${{ matrix.config.name }} ${{ matrix.python.name }} wheel
runs-on: ${{ matrix.config.os }}
outputs:
build_status_output: ${{ steps.build_status_step.outputs.build_status_output }} #Output job with build_status.txt content created in Read Build Status step
strategy:
matrix:
config:
- { name: ubuntu, os: ubuntu-latest}
python:
- { name: cp312, version: '3.12' }
fail-fast: false
defaults:
run:
shell: bash
steps:
#SETUP PYTHON
- name: Set up Python ${{ matrix.python.version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python.version }}
- name: Install Python dependencies
run: python -m pip install --upgrade pip
#SETUP GRAALVM
- name: Setup GraalVM
uses: graalvm/setup-graalvm@v1
with:
java-version: '17'
distribution: 'graalvm'
github-token: ${{ secrets.GITHUB_TOKEN }}
#DEFINE SCRIPTS PATH
- name: Set up script path
run: |
SCRIPTS_PATH="${GITHUB_WORKSPACE}/scripts/.github/workflows/scripts"
if [[ "${{ matrix.config.name }}" == "windows" ]]; then
SCRIPTS_PATH=$(echo "$SCRIPTS_PATH" | sed 's/\\/\//g')
fi
echo "SCRIPTS_PATH=$SCRIPTS_PATH" >> $GITHUB_ENV
#CHECKOUT SCRIPT
#The script check_snapshot_branch.sh is located in the workflow folder of the pypowsybl repository
#It is necessary for checking out the integration branch if it exists (pypowsybl include)
- name: Checkout script
uses: actions/checkout@v4
with:
sparse-checkout: |
.github
sparse-checkout-cone-mode: false
path: scripts
#CHECKOUT_PYPOWSYBL_DEPENCIES
- name: Checkout powsybl-dependencies sources
uses: actions/checkout@v4
with:
repository: powsybl/powsybl-dependencies
ref: main
path: powsybl-dependencies
- name: Get DEPENDENCIES_VERSION
run: echo "DEPENDENCIES_VERSION=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)" >> $GITHUB_ENV
working-directory: ./powsybl-dependencies
- name: Install powsybl-dependencies
continue-on-error: true
run: mvn -batch-mode --no-transfer-progress clean install
working-directory: ./powsybl-dependencies
#BUILD PYPOWSYBL
- name: Checkout pypowsybl
uses: actions/checkout@v4
with:
repository: powsybl/pypowsybl
path: pypowsybl
submodules: true
- name: update java/pom.xml
run: mvn versions:set-property -Dproperty=powsybl-dependencies.version -DnewVersion=$DEPENDENCIES_VERSION -DgenerateBackupPoms=false
working-directory: ./pypowsybl/java
- name: Install requirement.txt
run: pip3 install -r requirements.txt
working-directory: ./pypowsybl
- name: Build wheel
run: python3 setup.py bdist_wheel
working-directory: ./pypowsybl
- name: Install wheel
run: python -m pip install dist/*.whl --user
working-directory: ./pypowsybl
- name: check pypowsybl versions
working-directory: ./pypowsybl/tests
run: python3 basic_import_test.py
- name: Run tests
working-directory: ./pypowsybl/tests
run: pytest
- name: Upload wheel
uses: actions/upload-artifact@v4
with:
name: pypowsybl-wheel-${{ matrix.config.name }}-${{ matrix.python.name }}
path: ./pypowsybl/dist/*.whl
- name: Record Job Name
if: failure()
run: |
echo "Failed job : Build ${{ matrix.config.name }} ${{ matrix.python.name }} wheel" >> $BUILD_STATUS
- name: Read Build Status
if: always()
id: build_status_step
run: |
echo "=== BUILD STATUS REPORT ==="
cat $BUILD_STATUS
echo "=========================="
echo "build_status_output<<EOF" >> $GITHUB_OUTPUT
cat $BUILD_STATUS >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
#SLACK NOTIFICATION ON FAILURE
notify_slack:
needs: build_pypowsybl
runs-on: ubuntu-latest
if: failure()
steps:
- name: Send Slack Notification
uses: 8398a7/action-slack@v3
with:
status: ${{ job.status }}
text: |
:x: *Failed workflow ${{ github.workflow }}*
*Failure details:*
```
${{ needs.build_pypowsybl.outputs.build_status_output }}
```
See logs: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}