Implementing GitHub Actions Pipeline #83
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
# © 2024. TU Dortmund University, | |
# Institute of Energy Systems, Energy Efficiency and Energy Economics, | |
# Research group Distribution grid planning and operation | |
# | |
name: CI | |
on: | |
push: | |
branches: | |
- main | |
- dev | |
- 'feature/*' | |
- 'hotfix/*' | |
- 'release/*' | |
pull_request: | |
branches: | |
- main | |
- dev | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
container: | |
image: gradle:8.10-jdk17 | |
steps: | |
- name: Checkout Code | |
uses: actions/checkout@v4 | |
with: | |
# Check if it's a pull request | |
ref: ${{ github.event.pull_request.head.ref || github.ref }} | |
repository: ${{ github.event.pull_request.head.repo.full_name || github.repository }} | |
- name: Cache Gradle packages | |
uses: actions/cache@v3 | |
with: | |
path: | | |
~/.gradle/caches | |
~/.gradle/wrapper | |
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} | |
restore-keys: | | |
${{ runner.os }}-gradle- | |
- name: Check Branch & Files | |
run: | | |
git config --global --add safe.directory /__w/simona/simona | |
git rev-parse --abbrev-ref HEAD | |
pwd | |
ls -la | |
- name: Checking Gradle & Java | |
run: | | |
java -version && gradle --version | |
- name: Building Project | |
run: | | |
./gradlew clean assemble | |
ls -la | |
- name: Upload Artifact | |
uses: actions/upload-artifact@v3 | |
with: | |
name: simona-build | |
path: | | |
./build/classes/** | |
./build/resources/test/** | |
./build/libs/** | |
gradle/wrapper/** | |
gradle/scripts/** | |
gradlew | |
build.gradle | |
settings.gradle | |
test: | |
needs: build | |
runs-on: ubuntu-latest | |
container: | |
image: gradle:8.10-jdk17 | |
steps: | |
- name: Cache Gradle dependencies | |
uses: actions/cache@v3 | |
with: | |
path: | | |
~/.gradle/caches | |
~/.gradle/wrapper | |
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} | |
restore-keys: | | |
${{ runner.os }}-gradle | |
- name: Checking Gradle & Java | |
run: | | |
java -version && gradle --version | |
- name: Download Build Artifact | |
uses: actions/download-artifact@v3 | |
with: | |
name: simona-build | |
- name: Running tests | |
run: | | |
gradle --no-daemon --info --refresh-dependencies spotlessCheck pmdMain pmdTest | |
- name: Generate JavaDoc | |
run: | | |
set +x | |
cd simona | |
./gradlew javadoc |