-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add snapshot ci Signed-off-by: Nicolas Rol <[email protected]> * fix workflow status determination Signed-off-by: Nicolas Rol <[email protected]> * remove test on PR Signed-off-by: Nicolas Rol <[email protected]> --------- Signed-off-by: Nicolas Rol <[email protected]>
- Loading branch information
Showing
2 changed files
with
222 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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") | ||
|
||
# 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,205 @@ | ||
name: Snapshot CI | ||
|
||
on: | ||
workflow_dispatch: | ||
schedule: | ||
- cron: '50 3 * * *' | ||
|
||
jobs: | ||
build_powsybl_hpc: | ||
name: Build Java ${{ matrix.os }} | ||
runs-on: ${{ matrix.os }} | ||
strategy: | ||
matrix: | ||
os: [ubuntu-latest, windows-latest, macos-latest] | ||
fail-fast: false | ||
defaults: | ||
run: | ||
shell: bash | ||
|
||
steps: | ||
- name: Set up JDK 17 | ||
uses: actions/setup-java@99b8673ff64fbf99d8d325f52d9a5bdedb8483e9 # v4.2.1 | ||
with: | ||
distribution: 'temurin' | ||
java-version: '17' | ||
|
||
# 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@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4 | ||
with: | ||
repository: powsybl/powsybl-core | ||
ref: main | ||
path: powsybl-core | ||
|
||
- name: Build powsybl-core | ||
run: mvn -batch-mode --no-transfer-progress clean install -DskipTests | ||
working-directory: ./powsybl-core | ||
|
||
- name: Get powsybl-core version | ||
run: 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@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4 | ||
with: | ||
sparse-checkout: | | ||
.github | ||
sparse-checkout-cone-mode: false | ||
path: scripts | ||
|
||
# Build powsybl-hpc | ||
- name: Checking for powsybl-hpc snapshot branch | ||
run: ${{ env.SCRIPTS_PATH }}/check_integration_branch.sh "https://github.com/powsybl/powsybl-hpc.git" ${{ env.CORE_VERSION }} | ||
|
||
- name: Checkout powsybl-hpc | ||
uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4 | ||
with: | ||
repository: powsybl/powsybl-hpc | ||
ref: ${{ env.INTEGRATION_BRANCH }} | ||
path: powsybl-hpc | ||
submodules: true | ||
|
||
- name: update pom.xml | ||
run: mvn versions:set-property -Dproperty=powsyblcore.version -DnewVersion=$CORE_VERSION -DgenerateBackupPoms=false | ||
working-directory: ./powsybl-hpc | ||
|
||
- name: Build with Maven (Ubuntu) | ||
if: matrix.os == 'ubuntu-latest' | ||
working-directory: ./powsybl-hpc | ||
run: ./mvnw --batch-mode -Pjacoco install | ||
|
||
- name: Build with Maven (Windows) | ||
if: matrix.os == 'windows-latest' | ||
working-directory: .\powsybl-hpc | ||
run: mvnw.cmd --batch-mode install | ||
shell: cmd | ||
|
||
- name: Build with Maven (MacOS) | ||
if: matrix.os == 'macos-latest' | ||
working-directory: ./powsybl-hpc | ||
run: ./mvnw --batch-mode install | ||
|
||
- name: Store job result | ||
if: always() | ||
run: | | ||
echo "${{ matrix.os }}=${{ job.status }}" >> job_result_${{ matrix.os }}.txt | ||
- name: Upload job result | ||
if: always() | ||
uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808 # 4.3.3 | ||
with: | ||
name: job-results_${{ matrix.os }} | ||
path: job_result_${{ matrix.os }}.txt | ||
|
||
outputs: | ||
core-version: ${{ env.CORE_VERSION }} | ||
hpc-branch: ${{ env.INTEGRATION_BRANCH }} | ||
|
||
# Slack notification | ||
notify_slack: | ||
needs: build_powsybl_hpc | ||
runs-on: ubuntu-latest | ||
if: always() | ||
steps: | ||
- name: Download job results | ||
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8 | ||
|
||
- name: Combine job results | ||
run: | | ||
for dir in job-results_*; do | ||
cat "$dir"/* >> combined_job_results.txt | ||
done | ||
- name: Determine workflow status | ||
id: workflow_status | ||
run: | | ||
if grep -q "failure" combined_job_results.txt; then | ||
echo "icon=❌" >> $GITHUB_OUTPUT | ||
echo "status=Failed" >> $GITHUB_OUTPUT | ||
else | ||
echo "icon=✅" >> $GITHUB_OUTPUT | ||
echo "status=Successful" >> $GITHUB_OUTPUT | ||
fi | ||
- name: Format job results | ||
id: format_results | ||
run: | | ||
formatted="" | ||
while IFS='=' read -r os status; do | ||
icon=$([ "$status" == "success" ] && echo ":white_check_mark:" || echo ":x:") | ||
formatted+="${icon} Build powsybl-hpc on *${os}*\\n" | ||
done < combined_job_results.txt | ||
formatted="${formatted%\\n}" # Remove the last newline | ||
echo "formatted_results=${formatted}" >> $GITHUB_OUTPUT | ||
- name: Prepare Slack payload | ||
id: prepare_payload | ||
run: | | ||
if [ "${{ steps.workflow_status.outputs.status }}" == "Successful" ]; then | ||
echo 'payload<<EOF' >> $GITHUB_OUTPUT | ||
echo '{ | ||
"attachments": [{ | ||
"color": "#319f4b", | ||
"blocks": [ | ||
{ | ||
"type": "section", | ||
"text": { | ||
"type": "mrkdwn", | ||
"text": "${{ steps.workflow_status.outputs.icon }} *${{ steps.workflow_status.outputs.status }} workflow: Snapshot-CI on <https://github.com/powsybl/powsybl-hpc|powsybl-hpc>*\n\nBranch built: ${{ needs.build_powsybl_hpc.outputs.hpc-branch }}\nPowSyBl-Core version used: ${{ needs.build_powsybl_hpc.outputs.core-version }}\n\nSee logs on <https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}|GitHub>" | ||
} | ||
} | ||
] | ||
}] | ||
}' >> $GITHUB_OUTPUT | ||
echo 'EOF' >> $GITHUB_OUTPUT | ||
else | ||
echo 'payload<<EOF' >> $GITHUB_OUTPUT | ||
echo '{ | ||
"attachments": [{ | ||
"color": "#f64538", | ||
"blocks": [ | ||
{ | ||
"type": "section", | ||
"text": { | ||
"type": "mrkdwn", | ||
"text": "${{ steps.workflow_status.outputs.icon }} *${{ steps.workflow_status.outputs.status }} workflow: Snapshot-CI on <https://github.com/powsybl/powsybl-hpc|powsybl-hpc>*\n\nBranch built: ${{ needs.build_powsybl_hpc.outputs.hpc-branch }}\nPowSyBl-Core version used: ${{ needs.build_powsybl_hpc.outputs.core-version }}" | ||
} | ||
}, | ||
{ | ||
"type": "divider" | ||
}, | ||
{ | ||
"type": "section", | ||
"text": { | ||
"type": "mrkdwn", | ||
"text": "*Workflow details:*\n\n${{ steps.format_results.outputs.formatted_results }}\n\nSee logs on <https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}|GitHub>" | ||
} | ||
} | ||
] | ||
}] | ||
}' >> $GITHUB_OUTPUT | ||
echo 'EOF' >> $GITHUB_OUTPUT | ||
fi | ||
- name: Send Slack Notification | ||
uses: 8398a7/action-slack@28ba43ae48961b90635b50953d216767a6bea486 # v3.16.2 | ||
with: | ||
author_name: 'powsybl-hpc on GitHub' | ||
status: custom | ||
custom_payload: ${{ steps.prepare_payload.outputs.payload }} | ||
env: | ||
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_POWSYBL_WEBHOOK_URL }} |