From 96798b1014d60edb4196fd4118bfbb4f235dd5e5 Mon Sep 17 00:00:00 2001 From: Philipp Schmelter Date: Mon, 18 Nov 2024 13:35:11 +0100 Subject: [PATCH] Implementing GitHub Actions Pipeline (#982) * Testing Checkout * Fixed Syntax * Fixed Syntax * removed unnecessary steps * removed unnecessary steps * Syntax * Syntax * Test SSH * Testing Build ENV * Added wget * ENV * added shell * check java * check java * Created new Docker Image * Added Build and Test stage * Fix * Added right order * Fix * Fix * Fix * Fix * Fix * Fix * Fix * Added Volume * Set clean to false * Set clean to true * Fixed Volume Path * Fixed Volume Path * Fixed Volume Path * Fixed Volume Path * Fixed Volume Path * Fixed Volume Path * Bind Volume * Fixed Docker Image * Fix * Fix * Fix * Fix * Fix * Fix * Fix * Fix Volume * Fix Volume * Fix Volume * Fix Volume * Combined Checkout and Build * Fix * Fix * Fix Vol * Added Artifact * Added Artifact * Added Artifact * Fix syntax * Debug * Debug * Debug * STOP * test * Volume * Using Cache * Cache Fix * Cache Fix * Cache Fix * Cache Fix * Cache Fix * Cache Fix * Cache Fix * Cache Fix * Cache Fix * Cache Fix * Using artifacts * Changed approach in passing files * Changed approach in passing files * Debug * Fixed Path * Fixed Path * Fixed Path * Fixed Path * Fixed Path * Caching Gradle Dependencies * Removed workdir * Fixes * Fixes * Removed Artifacting Trying Cache * Seperated Build Artifact and Gradle Cache * All jobs in one stage test * Fixed permissions * Test * Test * Test * Changed approach * Added Sonar * Added Sonar * Added sonar credentials * Moved reportScoverage * Moved reportScoverage * Moved reportScoverage * Switched to action * Switched to action * Back to gradle * Removed dependencies from sonarqube.gradle * Added deployment step and sonar quality gate * fixed time format * debug * Added dependencie to sonarqube.gradle and changed workflow * sonar * Switched to action * Added path to binaries * Added path to binaries * Debug * Debug * Debug * Finished Prototype * Finished Prototype * Changed Java-Docs to Scala-Docs * Resolved Conversations * Changed branches * Switched from Sonarqube analysis Action to gradlew * Create Reports and changed path * fetch-depth * Quality-Gate status script * debug * debug * debug * Using reportScoverage * debug path * debug path * debug path * debug path * debug path * Merged some steps * rem debug * switched to sonarqube * Added CheckScov * Remove args * Outcommented sonar stage in jenkins * Testing Sonar * Prototype * Removed DummyCode * Jenkinsfile back to dev version * spotless back in test * Prototype * Resolved conversations * changed fetch depth * seperated spotlessCheck * debug spotless * debug spotless * resolved conversations * Removed PMDS and replaced with test * Added dependencies * fixes * empty line --- .github/workflows/ci.yml | 77 +++++++++++++++++++++++++++++++++ gradle/scripts/sonarqube.gradle | 2 - 2 files changed, 77 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/ci.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000000..182819f0a1 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,77 @@ +# © 2024. 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: 1 + ref: ${{ github.event.pull_request.head.ref || github.ref }} + repository: ${{ github.event.pull_request.head.repo.full_name || github.repository }} + + - name: Setup Java + uses: actions/setup-java@v4 + with: + distribution: 'temurin' + java-version: 17 + + - name: Setup Gradle + uses: gradle/actions/setup-gradle@v4 + + - name: Build Project + run: ./gradlew --refresh-dependencies clean assemble spotlessCheck + + - name: Run Tests + run: ./gradlew test reportScoverage checkScoverage + + - name: Build Scala-Docs + run: ./gradlew scaladoc + + - name: SonarQube + run: | + ./gradlew sonar \ + -Dsonar.projectKey=${{ vars.SONAR_PROJECT_KEY }} \ + -Dsonar.host.url=${{ vars.SONAR_HOST_URL }} \ + -Dsonar.login=${{ secrets.SONAR_TOKEN }} + + SONAR_STATUS_URL="${{ vars.SONAR_HOST_URL }}/api/qualitygates/project_status?projectKey=${{ vars.SONAR_PROJECT_KEY }}" + QUALITY_GATE_STATUS=$(curl -s -u "${{ secrets.SONAR_TOKEN }}:" "$SONAR_STATUS_URL" | jq -r '.projectStatus.status') + + echo "Quality Gate Status: $QUALITY_GATE_STATUS" + if [ "$QUALITY_GATE_STATUS" != "OK" ]; then + echo "Quality Gate failed!" + exit 1 + fi + + - name: Deploy + if: github.ref == 'refs/heads/main' || github.ref == 'refs/heads/dev' + run: | + ./gradlew publish\ + -Puser=${{ secrets.MAVENCENTRAL_USER }} \ + -Ppassword=${{ secrets.MAVENCENTRAL_PASS }} \ + -Psigning.keyId=${{ secrets.MAVENCENTRAL_SIGNINGKEYID }} \ + -Psigning.password=${{ secrets.MAVENCENTRAL_SIGNINGPASS }} \ + -Psigning.secretKeyRingFile=${{ secrets.MAVENCENTRAL_SIGNINGKEY }} diff --git a/gradle/scripts/sonarqube.gradle b/gradle/scripts/sonarqube.gradle index 80a9db4fd1..501bbbdc72 100644 --- a/gradle/scripts/sonarqube.gradle +++ b/gradle/scripts/sonarqube.gradle @@ -34,8 +34,6 @@ sonarqube { } // sonarqube task dependencies -project.tasks["sonarqube"].dependsOn "pmdMain" -project.tasks["sonarqube"].dependsOn "pmdTest" project.tasks["sonarqube"].dependsOn "test" project.tasks["sonarqube"].dependsOn "reportScoverage" project.tasks["sonarqube"].dependsOn "checkScoverage"