Skip to content

Commit 378d007

Browse files
Merge pull request #277 from ie3-institute/rel/sp/#276-release-0.8.0
Release 0.8.0
2 parents 51dd8d1 + 02c930c commit 378d007

24 files changed

+504
-179
lines changed

.github/workflows/ci.yml

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
# © 2025. TU Dortmund University,
2+
# Institute of Energy Systems, Energy Efficiency and Energy Economics,
3+
# Research group Distribution grid planning and operation
4+
#
5+
6+
name: CI
7+
8+
on:
9+
push:
10+
paths-ignore:
11+
- 'docs/**'
12+
branches:
13+
- main
14+
- dev
15+
- 'hotfix/*'
16+
- 'rel/*'
17+
- 'dependabot/*'
18+
pull_request:
19+
branches:
20+
- main
21+
- dev
22+
23+
jobs:
24+
buildAndTest:
25+
runs-on: ubuntu-latest
26+
27+
steps:
28+
- name: Checkout Source
29+
uses: actions/checkout@v4
30+
with:
31+
fetch-depth: 0
32+
33+
- name: Setup Java
34+
uses: actions/setup-java@v4
35+
with:
36+
distribution: 'temurin'
37+
java-version: 17
38+
39+
- name: Setup Gradle
40+
uses: gradle/actions/setup-gradle@v4
41+
42+
- name: Check Branch
43+
run: |
44+
if [ "${{ github.event_name }}" == "pull_request" ]; then
45+
BRANCH_NAME="${{ github.head_ref }}"
46+
else
47+
BRANCH_NAME="${{ github.ref_name }}"
48+
fi
49+
50+
if [[ "$BRANCH_NAME" == refs/heads/* ]]; then
51+
BRANCH_NAME="${BRANCH_NAME#refs/heads/}"
52+
fi
53+
54+
export BRANCH_NAME
55+
56+
echo "BRANCH_NAME=$BRANCH_NAME" >> $GITHUB_ENV
57+
58+
./gradlew checkBranchName -PbranchName="$BRANCH_NAME" --warning-mode=none
59+
60+
bash scripts/branch_type.sh
61+
62+
- name: Version Check
63+
if: ${{ github.event_name == 'pull_request' }}
64+
env:
65+
BASE_BRANCH: ${{ github.event.pull_request.base.ref }}
66+
run: bash scripts/run-version-check.sh
67+
68+
- name: Build Project
69+
run: ./gradlew --refresh-dependencies clean assemble spotlessCheck
70+
71+
- name: Run Tests
72+
run: ./gradlew pmdMain pmdTest test jacocoTestReport jacocoTestCoverageVerification
73+
74+
- name: Build Java-Docs
75+
run: ./gradlew javadoc
76+
77+
- name: SonarQube
78+
run: |
79+
./gradlew sonar \
80+
-Dsonar.projectKey=${{ vars.SONAR_PROJECT_KEY }} \
81+
-Dsonar.host.url=${{ vars.SONAR_HOST_URL }} \
82+
-Dsonar.login=${{ secrets.SONAR_TOKEN }} \
83+
-Dsonar.qualitygate.wait=true
84+
85+
#Deployment
86+
- name: Deploy
87+
if: github.ref == 'refs/heads/main' || github.ref == 'refs/heads/dev'
88+
env:
89+
ORG_GRADLE_PROJECT_signingKey: ${{ secrets.MAVENCENTRAL_SIGNINGKEY }}
90+
ORG_GRADLE_PROJECT_signingPassword: ${{ secrets.MAVENCENTRAL_SIGNINGPASS }}
91+
ORG_GRADLE_PROJECT_user: ${{ secrets.MAVENCENTRAL_USER }}
92+
ORG_GRADLE_PROJECT_password: ${{ secrets.MAVENCENTRAL_PASS }}
93+
run: |
94+
if [ "${GITHUB_REF}" == "refs/heads/main" ]; then
95+
currentVersion=$(./gradlew -q currentVersion)
96+
else
97+
currentVersion=$(./gradlew -q devVersion)
98+
fi
99+
100+
echo "currentVersion=$currentVersion"
101+
102+
./gradlew publish -PdeployVersion=$currentVersion
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
name: Dependabot auto-merge
2+
on: pull_request
3+
4+
permissions:
5+
contents: write
6+
pull-requests: write
7+
8+
jobs:
9+
dependabot:
10+
runs-on: ubuntu-latest
11+
if: github.event.pull_request.user.login == 'dependabot[bot]' && github.repository == 'ie3-institute/simonaAPI'
12+
steps:
13+
- name: Dependabot metadata
14+
id: metadata
15+
uses: dependabot/fetch-metadata@d7267f607e9d3fb96fc2fbe83e0af444713e90b7
16+
with:
17+
github-token: "${{ secrets.GITHUB_TOKEN }}"
18+
19+
- name: Enable auto-merge for Dependabot PRs
20+
if: steps.metadata.outputs.update-type == 'version-update:semver-patch'
21+
run: gh pr merge --auto --merge "$PR_URL"
22+
env:
23+
PR_URL: ${{ github.event.pull_request.html_url }}
24+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

CHANGELOG.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,15 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
66

77
## [Unreleased/Snapshot]
88

9+
## [0.8.0] - 2025-04-17
10+
11+
### Added
12+
- Implementing auto-merge for dependabot PRs [#273](https://github.com/ie3-institute/simonaAPI/issues/273)
13+
- Implemented GitHub Actions pipeline [#247](https://github.com/ie3-institute/simonaAPI/issues/247)
14+
15+
### Changed
16+
- Converting pekko classic to typed [#232](https://github.com/ie3-institute/simonaAPI/issues/232)
17+
918
## [0.7.0] - 2025-03-11
1019

1120
### Added
@@ -56,7 +65,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
5665
- Renamed messages to ease understanding [#62](https://github.com/ie3-institute/simonaAPI/issues/62)
5766
- Separating departures and arrivals in message protocol, properly handling exceptions [#77](https://github.com/ie3-institute/simonaAPI/issues/77)
5867

59-
[Unreleased/Snapshot]: https://github.com/ie3-institute/simonaapi/compare/0.7.0...HEAD
68+
[Unreleased/Snapshot]: https://github.com/ie3-institute/simonaapi/compare/0.8.0...HEAD
69+
[0.8.0]: https://github.com/ie3-institute/powersystemdatamodel/compare/0.7.0...0.8.0
6070
[0.7.0]: https://github.com/ie3-institute/powersystemdatamodel/compare/0.6.0...0.7.0
6171
[0.6.0]: https://github.com/ie3-institute/powersystemdatamodel/compare/0.5.0...0.6.0
6272
[0.5.0]: https://github.com/ie3-institute/powersystemdatamodel/compare/0.4.0...0.5.0

build.gradle

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
plugins {
22
id 'groovy' // groovy support
33
id 'java' // java support
4-
id 'com.diffplug.spotless' version '7.0.2'//code format
4+
id 'com.diffplug.spotless' version '7.0.3'//code format
55
id 'pmd' // code check, working on source code
66
id 'com.github.spotbugs' version '6.1.7' // code check, working on byte code
7-
id "org.sonarqube" version "6.0.1.5171" // sonarqube
7+
id "org.sonarqube" version "6.1.0.5360" // sonarqube
88
id 'signing'
99
id 'maven-publish' // publish to a maven repo (local or mvn central, has to be defined)
1010
id 'jacoco' // java code coverage plugin
@@ -40,6 +40,7 @@ apply from: scriptsLocation + 'mavenCentralPublish.gradle'
4040
apply from: scriptsLocation + 'jacoco.gradle'
4141
apply from: scriptsLocation + 'documentation.gradle'
4242
apply from: scriptsLocation + 'test.gradle'
43+
apply from: scriptsLocation + 'branchName.gradle'
4344

4445
repositories {
4546
mavenCentral()
@@ -75,8 +76,9 @@ dependencies{
7576
implementation 'org.apache.logging.log4j:log4j-slf4j-impl' // log4j -> slf4j
7677

7778
// pekko
78-
implementation "org.apache.pekko:pekko-actor_${scalaVersion}:${pekkoVersion}"
79-
testImplementation "org.apache.pekko:pekko-testkit_${scalaVersion}:${pekkoVersion}" // pekko testkit
79+
implementation "org.apache.pekko:pekko-actor-typed_${scalaVersion}:${pekkoVersion}"
80+
81+
testImplementation "org.apache.pekko:pekko-actor-testkit-typed_${scalaVersion}:${pekkoVersion}" // pekko typed testkit
8082

8183
// TESTING
8284
testImplementation 'org.spockframework:spock-core:2.3-groovy-4.0'

gradle/scripts/branchName.gradle

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
tasks.register('checkBranchName') {
2+
doLast {
3+
if (!project.hasProperty('branchName')) {
4+
throw new GradleException("Error: Missing required property 'branchName'.")
5+
}
6+
7+
def branchName = project.property('branchName')
8+
9+
def patterns = [
10+
~/^(developer|develop|dev)$/,
11+
~/.*rel\/.*/,
12+
~/^dependabot\/.*$/,
13+
~/.*hotfix\/\pL{2}\/#\d+.*/,
14+
~/.*main/,
15+
~/^[a-z]{2}\/#[0-9]+(?:-.+)?$/
16+
]
17+
18+
def isValid = patterns.any { pattern -> branchName ==~ pattern }
19+
20+
if (!isValid) {
21+
throw new GradleException("Error: Check Branch name format (e.g., ps/#1337-FeatureName). Current branch name is $branchName.")
22+
}
23+
24+
println "Branch name is $branchName"
25+
}
26+
}

gradle/scripts/semVer.gradle

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
// tasks for semantic versioning using semver-gradle https://github.com/ethauvin/semver-gradle
22

3-
task currentVersion {
4-
doFirst{
3+
tasks.register('currentVersion') {
4+
doFirst {
55
println semver.semver
66
}
77
}
88

9-
task devVersion {
10-
doFirst{
9+
tasks.register('devVersion') {
10+
doFirst {
1111
println "${semver.major}.${semver.minor}-SNAPSHOT"
1212
}
1313
}

scripts/branch_type.sh

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
if [ -z "${BRANCH_NAME:-}" ]; then
5+
echo "Error: BRANCH_NAME variable is not set."
6+
exit 1
7+
fi
8+
9+
10+
pattern_dev='^(developer|develop|dev)$'
11+
pattern_release='.*rel/.*'
12+
pattern_dependabot='^dependabot/.*'
13+
pattern_hotfix='.*hotfix/.*'
14+
pattern_main='.*main'
15+
pattern_feature='^[a-z]{2}/#[0-9]+(-.+)?$'
16+
17+
BRANCH_TYPE="unknown"
18+
19+
if [[ "$BRANCH_NAME" =~ $pattern_dev ]]; then
20+
BRANCH_TYPE="dev"
21+
elif [[ "$BRANCH_NAME" =~ $pattern_release ]]; then
22+
BRANCH_TYPE="release"
23+
elif [[ "$BRANCH_NAME" =~ $pattern_dependabot ]]; then
24+
BRANCH_TYPE="dependabot"
25+
elif [[ "$BRANCH_NAME" =~ $pattern_hotfix ]]; then
26+
BRANCH_TYPE="hotfix"
27+
elif [[ "$BRANCH_NAME" =~ $pattern_main ]]; then
28+
BRANCH_TYPE="main"
29+
elif [[ "$BRANCH_NAME" =~ $pattern_feature ]]; then
30+
BRANCH_TYPE="feature"
31+
else
32+
echo "Error:'$BRANCH_NAME' does not match any pattern."
33+
exit 1
34+
fi
35+
36+
echo "========================="
37+
echo "Branch type: $BRANCH_TYPE"
38+
echo "BRANCH_TYPE=$BRANCH_TYPE" >> "$GITHUB_ENV"
39+
echo "========================="

scripts/get_versions.sh

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
#!/bin/bash
2+
set -euo pipefail
3+
4+
cd "$(dirname "$0")/.."
5+
6+
REPO_URL=$(git config --get remote.origin.url)
7+
export REPO_URL
8+
echo "REPO_URL=$REPO_URL" >> $GITHUB_ENV
9+
10+
echo "Fetching current version of PR..."
11+
PR_VERSION=$(./gradlew -q currentVersion)
12+
echo "PR_VERSION=$PR_VERSION"
13+
echo "export PR_VERSION=$PR_VERSION" >> versions.env
14+
echo "PR_VERSION=$PR_VERSION" >> "$GITHUB_ENV"
15+
16+
get_branch_version() {
17+
local BRANCH_NAME=$1
18+
local DIR_NAME="${BRANCH_NAME}-branch"
19+
20+
git clone --depth 1 --branch "$BRANCH_NAME" "$REPO_URL" "$DIR_NAME"
21+
cd "$DIR_NAME"
22+
23+
echo "Fetching version from $BRANCH_NAME branch..."
24+
BRANCH_VERSION=$(./gradlew -q currentVersion)
25+
cd ..
26+
27+
echo "${BRANCH_NAME^^}_VERSION=$BRANCH_VERSION"
28+
echo "export ${BRANCH_NAME^^}_VERSION=$BRANCH_VERSION" >> versions.env
29+
echo "${BRANCH_NAME^^}_VERSION=$BRANCH_VERSION" >> "$GITHUB_ENV"
30+
31+
rm -rf "$DIR_NAME"
32+
}
33+
34+
35+
get_branch_version "dev"
36+
get_branch_version "main"
37+
38+
echo "Get Versions: OK!"

scripts/run-version-check.sh

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/bin/bash
2+
set -euo pipefail
3+
4+
rm -f versions.env
5+
6+
scripts/get_versions.sh
7+
8+
source versions.env
9+
10+
scripts/version_check.sh

scripts/version_check.sh

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
#!/bin/bash
2+
set -euo pipefail
3+
4+
cd "$(dirname "$0")/.."
5+
6+
echo "========================="
7+
echo "LOADED ENV VARIABLES:"
8+
echo "PR_VERSION: $PR_VERSION"
9+
echo "DEV_VERSION: $DEV_VERSION"
10+
echo "MAIN_VERSION: $MAIN_VERSION"
11+
echo "BASE_BRANCH: $BASE_BRANCH"
12+
echo "========================="
13+
14+
semver_gt() {
15+
IFS='.' read -r major1 minor1 patch1 <<< "$1"
16+
IFS='.' read -r major2 minor2 patch2 <<< "$2"
17+
18+
# Compare major version
19+
if [ "$major1" -gt "$major2" ]; then
20+
return 0
21+
elif [ "$major1" -lt "$major2" ]; then
22+
return 1
23+
fi
24+
25+
# Compare minor version
26+
if [ "$minor1" -gt "$minor2" ]; then
27+
return 0
28+
elif [ "$minor1" -lt "$minor2" ]; then
29+
return 1
30+
fi
31+
32+
# Compare patch version
33+
if [ "$patch1" -gt "$patch2" ]; then
34+
return 0
35+
else
36+
return 1
37+
fi
38+
}
39+
40+
# Version Checking Logic
41+
if [ "$BASE_BRANCH" = "dev" ]; then
42+
echo "PR into dev => applying dev rules"
43+
if [ "$DEV_VERSION" = "$PR_VERSION" ]; then
44+
echo "OK: PR version ($PR_VERSION) matches the current dev version ($DEV_VERSION)."
45+
exit 0
46+
else
47+
if [ "$MAIN_VERSION" = "$DEV_VERSION" ]; then
48+
if semver_gt "$PR_VERSION" "$DEV_VERSION"; then
49+
echo "OK: Increasing working version in dev from $DEV_VERSION to $PR_VERSION"
50+
exit 0
51+
else
52+
echo "FAIL: Release and working version are $MAIN_VERSION, but PR is not increasing the working version in dev"
53+
exit 1
54+
fi
55+
else
56+
echo "FAIL: PR version ($PR_VERSION) does not match the current dev version ($DEV_VERSION)."
57+
echo "Regular PRs must not update the working version. The working version should only change in controlled updates."
58+
exit 1
59+
fi
60+
fi
61+
62+
elif [ "$BASE_BRANCH" = "main" ]; then
63+
echo "PR into main => applying main rules"
64+
if semver_gt "$PR_VERSION" "$MAIN_VERSION"; then
65+
echo "OK: PR version ($PR_VERSION) is greater than the current main version ($MAIN_VERSION)."
66+
exit 0
67+
else
68+
echo "FAIL: PR version ($PR_VERSION) is NOT greater than the current main version ($MAIN_VERSION)."
69+
echo "A new release must have a higher version than the existing main version."
70+
exit 1
71+
fi
72+
73+
else
74+
echo "Skipping version check: Base branch is '$BASE_BRANCH'. No version enforcement required."
75+
exit 0
76+
fi

0 commit comments

Comments
 (0)