Skip to content

Commit aca58ba

Browse files
Merge pull request #310 from ie3-institute/ps/#309-GitHubActions
Implementation of GitHub Actions
2 parents b7f390c + a72fac7 commit aca58ba

19 files changed

+464
-38
lines changed

.github/CODEOWNERS

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Reviewers for Dependabot PRs
2+
build.gradle @sebastian-peter @danielfeismann @staudtMarius
3+
4+
# Reviewers for CI/CD related PRs
5+
.github/workflows/ @sebastian-peter @PhilippSchmelter

.github/dependabot.yml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,6 @@ updates:
77
time: "05:00"
88
open-pull-requests-limit: 10
99
target-branch: main
10-
reviewers:
11-
- t-ober
12-
- jo-bao
13-
- sebastian-peter
14-
- danielfeismann
15-
- staudtMarius
1610
ignore:
1711
- dependency-name: org.jgrapht:jgrapht-core
1812
versions:

.github/workflows/ci.yml

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
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+
timeout-minutes: 30
27+
28+
steps:
29+
- name: Checkout Source
30+
uses: actions/checkout@v4
31+
with:
32+
fetch-depth: 0
33+
34+
- name: Setup Java
35+
uses: actions/setup-java@v4
36+
with:
37+
distribution: 'temurin'
38+
java-version: 17
39+
40+
- name: Setup Gradle
41+
uses: gradle/actions/setup-gradle@v4
42+
43+
- name: Check Branch
44+
run: |
45+
if [ "${{ github.event_name }}" == "pull_request" ]; then
46+
BRANCH_NAME="${{ github.head_ref }}"
47+
else
48+
BRANCH_NAME="${{ github.ref_name }}"
49+
fi
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+
- name: Version Check
62+
if: ${{ github.event_name == 'pull_request' }}
63+
env:
64+
BASE_BRANCH: ${{ github.event.pull_request.base.ref }}
65+
run: bash scripts/run-version-check.sh
66+
67+
- name: Build Project
68+
run: ./gradlew --refresh-dependencies clean assemble spotlessCheck
69+
70+
- name: Run Tests
71+
run: ./gradlew pmdMain pmdTest check reportScoverage checkScoverage
72+
- name: Build Scala-Docs
73+
run: ./gradlew scaladoc
74+
75+
- name: SonarQube
76+
run: |
77+
./gradlew sonar \
78+
-Dsonar.projectKey=${{ vars.SONAR_PROJECT_KEY }} \
79+
-Dsonar.host.url=${{ vars.SONAR_HOST_URL }} \
80+
-Dsonar.token=${{ secrets.SONAR_TOKEN }} \
81+
-Dsonar.qualitygate.wait=true
82+
#Deployment
83+
- name: Deploy
84+
if: github.ref == 'refs/heads/main' || github.ref == 'refs/heads/dev'
85+
env:
86+
ORG_GRADLE_PROJECT_signingKey: ${{ secrets.MAVENCENTRAL_SIGNINGKEY }}
87+
ORG_GRADLE_PROJECT_signingPassword: ${{ secrets.MAVENCENTRAL_SIGNINGPASS }}
88+
ORG_GRADLE_PROJECT_user: ${{ secrets.MAVENCENTRAL_USER }}
89+
ORG_GRADLE_PROJECT_password: ${{ secrets.MAVENCENTRAL_PASS }}
90+
run: |
91+
if [ "${GITHUB_REF}" == "refs/heads/main" ]; then
92+
currentVersion=$(./gradlew -q currentVersion)
93+
else
94+
currentVersion=$(./gradlew -q devVersion)
95+
fi
96+
97+
echo "currentVersion=$currentVersion"
98+
./gradlew publish -PdeployVersion=$currentVersion
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
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/simBench2psdm'
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: Check Snapshot
20+
if: contains(steps.metadata.outputs.new-version, 'snap')
21+
run: |
22+
echo "::error::Snapshot versions are not allowed – workflow stopped."
23+
exit 1
24+
25+
- name: Approve the PR
26+
if: steps.metadata.outputs.update-type == 'version-update:semver-patch'
27+
run: gh pr review --approve "$PR_URL"
28+
env:
29+
PR_URL: ${{github.event.pull_request.html_url}}
30+
GH_TOKEN: ${{secrets.GITHUB_TOKEN}}
31+
32+
- name: Enable auto-merge for Dependabot PRs
33+
if: steps.metadata.outputs.update-type == 'version-update:semver-patch'
34+
run: gh pr merge --auto --merge "$PR_URL"
35+
env:
36+
PR_URL: ${{ github.event.pull_request.html_url }}
37+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
88
### Added
99
- Added Bao and Staudt to list of reviewers [#277](https://github.com/ie3-institute/simBench2psdm/issues/277)
1010
- Added semantic versioning for GHA [#324](https://github.com/ie3-institute/simBench2psdm/issues/324)
11+
- Implemented GitHub Actions Pipeline [#309](https://github.com/ie3-institute/simBench2psdm/issues/309)
1112

1213
### Changed
1314
- Redesigned the `ExtractorSpec.scala`, to clear test files between different tests. [#299](https://github.com/ie3-institute/simBench2psdm/issues/299)

build.gradle

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ ext {
2727

2828
group = 'com.github.ie3-institute'
2929
description = 'simbench2psdm'
30-
version = '1.1-SNAPSHOT'
3130
sourceCompatibility = javaVersion
3231
targetCompatibility = javaVersion
3332

@@ -37,6 +36,8 @@ apply from: scriptsLocation + 'checkJavaVersion.gradle'
3736
apply from: scriptsLocation + 'tscfg.gradle' // config tasks
3837
apply from: scriptsLocation + 'scoverage.gradle'
3938
apply from: scriptsLocation + 'semVer.gradle'
39+
apply from: scriptsLocation + 'branchName.gradle'
40+
apply from: scriptsLocation + 'mavenCentralPublish.gradle'
4041

4142
repositories {
4243
mavenCentral()
@@ -99,10 +100,11 @@ dependencies {
99100
implementation "org.apache.commons:commons-compress:+"
100101
}
101102

102-
wrapper {
103-
gradleVersion = '7.6'
103+
tasks.withType(JavaCompile).configureEach {
104+
options.encoding = 'UTF-8'
104105
}
105106

106-
tasks.withType(JavaCompile) {
107-
options.encoding = 'UTF-8'
107+
tasks.named('test') {
108+
dependsOn tasks.named('compileScoverageGroovy')
109+
dependsOn tasks.named('processScoverageResources')
108110
}

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+
}
Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
/* Maven publish - start */
2+
tasks.register("sourcesJar", Jar) {
3+
archiveClassifier.set("sources")
4+
from(sourceSets.main.allJava)
5+
}
6+
7+
tasks.register("javadocJar", Jar) {
8+
dependsOn(tasks.named("javadoc"))
9+
archiveClassifier.set("javadoc")
10+
from(tasks.named("javadoc").get().destinationDir)
11+
}
12+
13+
if (project.hasProperty('user') && project.hasProperty('password')) {
14+
signing {
15+
required { !version.endsWith('SNAPSHOT') }
16+
if(required)
17+
sign(publishing.publications)
18+
}
19+
20+
publishing {
21+
publications {
22+
mavenJava(MavenPublication) {
23+
24+
versionMapping {
25+
// resolves dynamic versioning to current version number
26+
usage('java-api') {
27+
fromResolutionOf('runtimeClasspath')
28+
}
29+
usage('java-runtime') {
30+
fromResolutionResult()
31+
}
32+
}
33+
pom {
34+
description = 'Tool to convert SimBench data sets to ie³\'s power system data model'
35+
name = 'simBench2psdm'
36+
url = 'https:github.com/ie3-institute/simBench2psdm'
37+
organization {
38+
name = 'Institute of Energy Systems, Energy Efficiency and Energy Economics (ie3)/TU Dortmund University'
39+
url = 'https:www.ie3.tu-dortmund.de'
40+
}
41+
issueManagement {
42+
system = 'GitHub'
43+
url = 'https:github.com/ie3-institute/simBench2psdm/issues'
44+
}
45+
licenses {
46+
license {
47+
name = 'BSD 3-Clause License'
48+
url = 'https:github.com/ie3-institute/simBench2psdm/blob/main/LICENSE'
49+
}
50+
}
51+
developers {
52+
developer {
53+
organization = "Institute of Energy Systems, Energy Efficiency and Energy Economics (ie3)/TU Dortmund University"
54+
organizationUrl = "https:ie3.etit.tu-dortmund.de"
55+
}
56+
}
57+
scm {
58+
connection = 'scm:git:git:github.com/ie3-institute/simBench2psdm.git'
59+
developerConnection = 'scm:git:ssh:github.com:ie3-institute/simBench2psdm.git'
60+
url = 'https:github.com/ie3-institute/simBench2psdm'
61+
}
62+
}
63+
64+
removeTestDependenciesFromPom(pom)
65+
groupId group
66+
artifactId 'simBench2psdm'
67+
version version
68+
69+
from components.java
70+
artifact sourcesJar
71+
artifact javadocJar
72+
}
73+
}
74+
repositories {
75+
maven {
76+
def releasesRepoUrl = "https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/"
77+
def snapshotsRepoUrl = "https://s01.oss.sonatype.org/content/repositories/snapshots/"
78+
url = version.endsWith('SNAPSHOT') ? snapshotsRepoUrl : releasesRepoUrl
79+
credentials {
80+
username project.getProperty('user')
81+
password project.getProperty('password')
82+
}
83+
}
84+
}
85+
}
86+
87+
88+
model {
89+
tasks.generatePomFileForMavenJavaPublication {
90+
destination = file("$rootDir/build/generated-pom.xml")
91+
}
92+
}
93+
}
94+
95+
def removeTestDependenciesFromPom(pom) {
96+
97+
pom.withXml {
98+
def root = asNode()
99+
// eliminate test-scoped dependencies (no need in maven central POMs)
100+
root.dependencies.removeAll { dep ->
101+
dep.scope == "test"
102+
}
103+
}
104+
}
105+
106+
107+
/* Maven publish - end */

gradle/scripts/spotless.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ spotless {
3636
format 'misc', {
3737
target '**/*.md', '**/.gitignore', 'configs/**'
3838
trimTrailingWhitespace()
39-
indentWithTabs()
39+
leadingSpacesToTabs()
4040
endWithNewline()
4141
}
4242
}

gradle/wrapper/gradle-wrapper.jar

-16.7 KB
Binary file not shown.

0 commit comments

Comments
 (0)