diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml index a358103a..7eb36f8c 100644 --- a/.github/workflows/cd.yml +++ b/.github/workflows/cd.yml @@ -1,6 +1,3 @@ -# This workflow will build a package using Maven and then publish it to GitHub packages when a release is created -# For more information see: https://github.com/actions/setup-java#apache-maven-with-a-settings-path - name: Maven Package on: @@ -8,29 +5,70 @@ on: types: [created] jobs: - publish: - name: Publish Maven package + build: + name: Build project runs-on: ubuntu-latest steps: - name: Checkout code uses: actions/checkout@v3 + - name: Set up JDK 17 uses: actions/setup-java@v3 with: distribution: 'zulu' java-version: '17' - server-id: github # Value of the distributionManagement/repository/id field of the pom.xml - settings-path: ${{ github.workspace }} # location for the settings.xml file - - name: Grant execute permission for gradlew - run: chmod +x gradlew - - name: Build with Gradle + + - 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: Run ktlint + run: ./gradlew sdk:ktlintCheck + + - name: Build project run: ./gradlew sdk:build -x test - - name: Unit tests - run: ./gradlew sdk:testProductionDebugUnitTest - - name: Publish package + + unit-test-maven-publish: + name: Unit test and Publish Maven package + runs-on: ubuntu-latest + needs: build + steps: + - name: Checkout code + uses: actions/checkout@v3 + with: + fetch-depth: 0 # required for SonarCloud + + - name: Set up JDK 17 + uses: actions/setup-java@v3 + with: + distribution: 'zulu' + java-version: '17' + + - 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: Run unit tests + # Switch to jacocoTestReport when instrumentation flakiness is fixed + run: ./gradlew sdk:jacocoUnitTestReport + + - name: Publish Maven package run: ./gradlew sdk:publish env: PGP_SIGNING_KEY: ${{ secrets.PGP_SIGNING_KEY }} PGP_SIGNING_PASSWORD: ${{ secrets.PGP_SIGNING_PASSWORD }} SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }} SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }} + diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 05393cc3..3edab9c0 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -32,15 +32,6 @@ jobs: run: ./gradlew sdk:ktlintCheck - name: Build project - env: - NETCETERA_LICENSE_KEY: ${{ secrets.NETCETERA_LICENSE_KEY }} - SCHEME_NAME: ${{ secrets.SCHEME_NAME }} - DS_ID: ${{ secrets.DS_ID }} - MESSAGE_VERSION: ${{ secrets.MESSAGE_VERSION }} - ACS_REF_NUMBER: ${{ secrets.ACS_REF_NUMBER }} - DS_PUBLIC_KEY: ${{ secrets.DS_PUBLIC_KEY }} - NETCETERA_API_KEY: ${{ secrets.NETCETERA_API_KEY }} - run: ./gradlew sdk:build -x test unit-test: