Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
a4ae17b
Converting pekko classic to typed.
staudtMarius Jan 7, 2025
bc7f4df
Small improvements.
staudtMarius Jan 8, 2025
7ca7863
Merge branch 'dev' into ms/#232-converting-actor-ref-to-typed
staudtMarius Jan 9, 2025
0382a2f
Merge branch 'dev' into ms/#232-converting-actor-ref-to-typed
staudtMarius Feb 27, 2025
a3b5b34
Merge branch 'dev' into ms/#232-converting-actor-ref-to-typed
staudtMarius Mar 11, 2025
a54ff0d
Merge pull request #262 from ie3-institute/sp/#000-merge-back-0.7.0
sebastian-peter Mar 11, 2025
4450890
Increasing working version to 0.8.0
sebastian-peter Mar 11, 2025
48c03cb
Bump org.sonarqube from 6.0.1.5171 to 6.1.0.5360 (#264)
dependabot[bot] Mar 26, 2025
2212205
Merge branch 'dev' into ms/#232-converting-actor-ref-to-typed
staudtMarius Mar 26, 2025
ac7f39b
Adapting to reviewer's comments.
staudtMarius Mar 26, 2025
3a7b1d2
Merge pull request #233 from ie3-institute/ms/#232-converting-actor-r…
sebastian-peter Mar 31, 2025
0e385a0
Bump com.diffplug.spotless from 7.0.2 to 7.0.3 (#272)
dependabot[bot] Apr 8, 2025
8df364f
auto merge
PhilippSchmelter Apr 9, 2025
9e86dfb
GHA
PhilippSchmelter Apr 9, 2025
740a4b8
spotless
PhilippSchmelter Apr 9, 2025
a3a9405
permissions
PhilippSchmelter Apr 9, 2025
63e3826
Merge pull request #274 from ie3-institute/ps/#273-autoMerge
sebastian-peter Apr 10, 2025
a6676a2
Merge branch 'dev' into ps/#247-GitHubActions
sebastian-peter Apr 15, 2025
45c5f64
Merge pull request #275 from ie3-institute/ps/#247-GitHubActions
sebastian-peter Apr 15, 2025
02c930c
Preparing changelog for release
sebastian-peter Apr 17, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
102 changes: 102 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
# © 2025. TU Dortmund University,
# Institute of Energy Systems, Energy Efficiency and Energy Economics,
# Research group Distribution grid planning and operation
#

name: CI

on:
push:
paths-ignore:
- 'docs/**'
branches:
- main
- dev
- 'hotfix/*'
- 'rel/*'
- 'dependabot/*'
pull_request:
branches:
- main
- dev

jobs:
buildAndTest:
runs-on: ubuntu-latest

steps:
- name: Checkout Source
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Setup Java
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: 17

- name: Setup Gradle
uses: gradle/actions/setup-gradle@v4

- name: Check Branch
run: |
if [ "${{ github.event_name }}" == "pull_request" ]; then
BRANCH_NAME="${{ github.head_ref }}"
else
BRANCH_NAME="${{ github.ref_name }}"
fi

if [[ "$BRANCH_NAME" == refs/heads/* ]]; then
BRANCH_NAME="${BRANCH_NAME#refs/heads/}"
fi

export BRANCH_NAME

echo "BRANCH_NAME=$BRANCH_NAME" >> $GITHUB_ENV

./gradlew checkBranchName -PbranchName="$BRANCH_NAME" --warning-mode=none

bash scripts/branch_type.sh

- name: Version Check
if: ${{ github.event_name == 'pull_request' }}
env:
BASE_BRANCH: ${{ github.event.pull_request.base.ref }}
run: bash scripts/run-version-check.sh

- name: Build Project
run: ./gradlew --refresh-dependencies clean assemble spotlessCheck

- name: Run Tests
run: ./gradlew pmdMain pmdTest test jacocoTestReport jacocoTestCoverageVerification

- name: Build Java-Docs
run: ./gradlew javadoc

- name: SonarQube
run: |
./gradlew sonar \
-Dsonar.projectKey=${{ vars.SONAR_PROJECT_KEY }} \
-Dsonar.host.url=${{ vars.SONAR_HOST_URL }} \
-Dsonar.login=${{ secrets.SONAR_TOKEN }} \
-Dsonar.qualitygate.wait=true

#Deployment
- name: Deploy
if: github.ref == 'refs/heads/main' || github.ref == 'refs/heads/dev'
env:
ORG_GRADLE_PROJECT_signingKey: ${{ secrets.MAVENCENTRAL_SIGNINGKEY }}
ORG_GRADLE_PROJECT_signingPassword: ${{ secrets.MAVENCENTRAL_SIGNINGPASS }}
ORG_GRADLE_PROJECT_user: ${{ secrets.MAVENCENTRAL_USER }}
ORG_GRADLE_PROJECT_password: ${{ secrets.MAVENCENTRAL_PASS }}
run: |
if [ "${GITHUB_REF}" == "refs/heads/main" ]; then
currentVersion=$(./gradlew -q currentVersion)
else
currentVersion=$(./gradlew -q devVersion)
fi

echo "currentVersion=$currentVersion"

./gradlew publish -PdeployVersion=$currentVersion
24 changes: 24 additions & 0 deletions .github/workflows/dependabot-auto-merge.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Dependabot auto-merge
on: pull_request

permissions:
contents: write
pull-requests: write

jobs:
dependabot:
runs-on: ubuntu-latest
if: github.event.pull_request.user.login == 'dependabot[bot]' && github.repository == 'ie3-institute/simonaAPI'
steps:
- name: Dependabot metadata
id: metadata
uses: dependabot/fetch-metadata@d7267f607e9d3fb96fc2fbe83e0af444713e90b7
with:
github-token: "${{ secrets.GITHUB_TOKEN }}"

- name: Enable auto-merge for Dependabot PRs
if: steps.metadata.outputs.update-type == 'version-update:semver-patch'
run: gh pr merge --auto --merge "$PR_URL"
env:
PR_URL: ${{ github.event.pull_request.html_url }}
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
12 changes: 11 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,15 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased/Snapshot]

## [0.8.0] - 2025-04-17

### Added
- Implementing auto-merge for dependabot PRs [#273](https://github.com/ie3-institute/simonaAPI/issues/273)
- Implemented GitHub Actions pipeline [#247](https://github.com/ie3-institute/simonaAPI/issues/247)

### Changed
- Converting pekko classic to typed [#232](https://github.com/ie3-institute/simonaAPI/issues/232)

## [0.7.0] - 2025-03-11

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

[Unreleased/Snapshot]: https://github.com/ie3-institute/simonaapi/compare/0.7.0...HEAD
[Unreleased/Snapshot]: https://github.com/ie3-institute/simonaapi/compare/0.8.0...HEAD
[0.8.0]: https://github.com/ie3-institute/powersystemdatamodel/compare/0.7.0...0.8.0
[0.7.0]: https://github.com/ie3-institute/powersystemdatamodel/compare/0.6.0...0.7.0
[0.6.0]: https://github.com/ie3-institute/powersystemdatamodel/compare/0.5.0...0.6.0
[0.5.0]: https://github.com/ie3-institute/powersystemdatamodel/compare/0.4.0...0.5.0
Expand Down
10 changes: 6 additions & 4 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
plugins {
id 'groovy' // groovy support
id 'java' // java support
id 'com.diffplug.spotless' version '7.0.2'//code format
id 'com.diffplug.spotless' version '7.0.3'//code format
id 'pmd' // code check, working on source code
id 'com.github.spotbugs' version '6.1.7' // code check, working on byte code
id "org.sonarqube" version "6.0.1.5171" // sonarqube
id "org.sonarqube" version "6.1.0.5360" // sonarqube
id 'signing'
id 'maven-publish' // publish to a maven repo (local or mvn central, has to be defined)
id 'jacoco' // java code coverage plugin
Expand Down Expand Up @@ -40,6 +40,7 @@ apply from: scriptsLocation + 'mavenCentralPublish.gradle'
apply from: scriptsLocation + 'jacoco.gradle'
apply from: scriptsLocation + 'documentation.gradle'
apply from: scriptsLocation + 'test.gradle'
apply from: scriptsLocation + 'branchName.gradle'

repositories {
mavenCentral()
Expand Down Expand Up @@ -75,8 +76,9 @@ dependencies{
implementation 'org.apache.logging.log4j:log4j-slf4j-impl' // log4j -> slf4j

// pekko
implementation "org.apache.pekko:pekko-actor_${scalaVersion}:${pekkoVersion}"
testImplementation "org.apache.pekko:pekko-testkit_${scalaVersion}:${pekkoVersion}" // pekko testkit
implementation "org.apache.pekko:pekko-actor-typed_${scalaVersion}:${pekkoVersion}"

testImplementation "org.apache.pekko:pekko-actor-testkit-typed_${scalaVersion}:${pekkoVersion}" // pekko typed testkit

// TESTING
testImplementation 'org.spockframework:spock-core:2.3-groovy-4.0'
Expand Down
26 changes: 26 additions & 0 deletions gradle/scripts/branchName.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
tasks.register('checkBranchName') {
doLast {
if (!project.hasProperty('branchName')) {
throw new GradleException("Error: Missing required property 'branchName'.")
}

def branchName = project.property('branchName')

def patterns = [
~/^(developer|develop|dev)$/,
~/.*rel\/.*/,
~/^dependabot\/.*$/,
~/.*hotfix\/\pL{2}\/#\d+.*/,
~/.*main/,
~/^[a-z]{2}\/#[0-9]+(?:-.+)?$/
]

def isValid = patterns.any { pattern -> branchName ==~ pattern }

if (!isValid) {
throw new GradleException("Error: Check Branch name format (e.g., ps/#1337-FeatureName). Current branch name is $branchName.")
}

println "Branch name is $branchName"
}
}
8 changes: 4 additions & 4 deletions gradle/scripts/semVer.gradle
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
// tasks for semantic versioning using semver-gradle https://github.com/ethauvin/semver-gradle

task currentVersion {
doFirst{
tasks.register('currentVersion') {
doFirst {
println semver.semver
}
}

task devVersion {
doFirst{
tasks.register('devVersion') {
doFirst {
println "${semver.major}.${semver.minor}-SNAPSHOT"
}
}
39 changes: 39 additions & 0 deletions scripts/branch_type.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#!/usr/bin/env bash
set -euo pipefail

if [ -z "${BRANCH_NAME:-}" ]; then
echo "Error: BRANCH_NAME variable is not set."
exit 1
fi


pattern_dev='^(developer|develop|dev)$'
pattern_release='.*rel/.*'
pattern_dependabot='^dependabot/.*'
pattern_hotfix='.*hotfix/.*'
pattern_main='.*main'
pattern_feature='^[a-z]{2}/#[0-9]+(-.+)?$'

BRANCH_TYPE="unknown"

if [[ "$BRANCH_NAME" =~ $pattern_dev ]]; then
BRANCH_TYPE="dev"
elif [[ "$BRANCH_NAME" =~ $pattern_release ]]; then
BRANCH_TYPE="release"
elif [[ "$BRANCH_NAME" =~ $pattern_dependabot ]]; then
BRANCH_TYPE="dependabot"
elif [[ "$BRANCH_NAME" =~ $pattern_hotfix ]]; then
BRANCH_TYPE="hotfix"
elif [[ "$BRANCH_NAME" =~ $pattern_main ]]; then
BRANCH_TYPE="main"
elif [[ "$BRANCH_NAME" =~ $pattern_feature ]]; then
BRANCH_TYPE="feature"
else
echo "Error:'$BRANCH_NAME' does not match any pattern."
exit 1
fi

echo "========================="
echo "Branch type: $BRANCH_TYPE"
echo "BRANCH_TYPE=$BRANCH_TYPE" >> "$GITHUB_ENV"
echo "========================="
38 changes: 38 additions & 0 deletions scripts/get_versions.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#!/bin/bash
set -euo pipefail

cd "$(dirname "$0")/.."

REPO_URL=$(git config --get remote.origin.url)
export REPO_URL
echo "REPO_URL=$REPO_URL" >> $GITHUB_ENV

echo "Fetching current version of PR..."
PR_VERSION=$(./gradlew -q currentVersion)
echo "PR_VERSION=$PR_VERSION"
echo "export PR_VERSION=$PR_VERSION" >> versions.env
echo "PR_VERSION=$PR_VERSION" >> "$GITHUB_ENV"

get_branch_version() {
local BRANCH_NAME=$1
local DIR_NAME="${BRANCH_NAME}-branch"

git clone --depth 1 --branch "$BRANCH_NAME" "$REPO_URL" "$DIR_NAME"
cd "$DIR_NAME"

echo "Fetching version from $BRANCH_NAME branch..."
BRANCH_VERSION=$(./gradlew -q currentVersion)
cd ..

echo "${BRANCH_NAME^^}_VERSION=$BRANCH_VERSION"
echo "export ${BRANCH_NAME^^}_VERSION=$BRANCH_VERSION" >> versions.env
echo "${BRANCH_NAME^^}_VERSION=$BRANCH_VERSION" >> "$GITHUB_ENV"

rm -rf "$DIR_NAME"
}


get_branch_version "dev"
get_branch_version "main"

echo "Get Versions: OK!"
10 changes: 10 additions & 0 deletions scripts/run-version-check.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/bash
set -euo pipefail

rm -f versions.env

scripts/get_versions.sh

source versions.env

scripts/version_check.sh
76 changes: 76 additions & 0 deletions scripts/version_check.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
#!/bin/bash
set -euo pipefail

cd "$(dirname "$0")/.."

echo "========================="
echo "LOADED ENV VARIABLES:"
echo "PR_VERSION: $PR_VERSION"
echo "DEV_VERSION: $DEV_VERSION"
echo "MAIN_VERSION: $MAIN_VERSION"
echo "BASE_BRANCH: $BASE_BRANCH"
echo "========================="

semver_gt() {
IFS='.' read -r major1 minor1 patch1 <<< "$1"
IFS='.' read -r major2 minor2 patch2 <<< "$2"

# Compare major version
if [ "$major1" -gt "$major2" ]; then
return 0
elif [ "$major1" -lt "$major2" ]; then
return 1
fi

# Compare minor version
if [ "$minor1" -gt "$minor2" ]; then
return 0
elif [ "$minor1" -lt "$minor2" ]; then
return 1
fi

# Compare patch version
if [ "$patch1" -gt "$patch2" ]; then
return 0
else
return 1
fi
}

# Version Checking Logic
if [ "$BASE_BRANCH" = "dev" ]; then
echo "PR into dev => applying dev rules"
if [ "$DEV_VERSION" = "$PR_VERSION" ]; then
echo "OK: PR version ($PR_VERSION) matches the current dev version ($DEV_VERSION)."
exit 0
else
if [ "$MAIN_VERSION" = "$DEV_VERSION" ]; then
if semver_gt "$PR_VERSION" "$DEV_VERSION"; then
echo "OK: Increasing working version in dev from $DEV_VERSION to $PR_VERSION"
exit 0
else
echo "FAIL: Release and working version are $MAIN_VERSION, but PR is not increasing the working version in dev"
exit 1
fi
else
echo "FAIL: PR version ($PR_VERSION) does not match the current dev version ($DEV_VERSION)."
echo "Regular PRs must not update the working version. The working version should only change in controlled updates."
exit 1
fi
fi

elif [ "$BASE_BRANCH" = "main" ]; then
echo "PR into main => applying main rules"
if semver_gt "$PR_VERSION" "$MAIN_VERSION"; then
echo "OK: PR version ($PR_VERSION) is greater than the current main version ($MAIN_VERSION)."
exit 0
else
echo "FAIL: PR version ($PR_VERSION) is NOT greater than the current main version ($MAIN_VERSION)."
echo "A new release must have a higher version than the existing main version."
exit 1
fi

else
echo "Skipping version check: Base branch is '$BASE_BRANCH'. No version enforcement required."
exit 0
fi
Loading