|
| 1 | +name: Persistence Common CI |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [ main, develop ] |
| 6 | + paths: |
| 7 | + - 'persistence-common/**' |
| 8 | + - '.github/workflows/persistence-common-ci.yml' |
| 9 | + pull_request: |
| 10 | + branches: |
| 11 | + - '*' |
| 12 | + paths: |
| 13 | + - 'persistence-common/**' |
| 14 | + - '.github/workflows/persistence-common-ci.yml' |
| 15 | + workflow_dispatch: |
| 16 | + |
| 17 | +jobs: |
| 18 | + test: |
| 19 | + name: Test Persistence Common |
| 20 | + runs-on: ubuntu-latest |
| 21 | + |
| 22 | + steps: |
| 23 | + - name: Checkout code |
| 24 | + uses: actions/checkout@v4 |
| 25 | + |
| 26 | + - name: Set up JDK 17 |
| 27 | + uses: actions/setup-java@v4 |
| 28 | + with: |
| 29 | + java-version: '17' |
| 30 | + distribution: 'temurin' |
| 31 | + cache: maven |
| 32 | + |
| 33 | + - name: Cache Maven dependencies |
| 34 | + uses: actions/cache@v4 |
| 35 | + with: |
| 36 | + path: ~/.m2 |
| 37 | + key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }} |
| 38 | + restore-keys: ${{ runner.os }}-m2 |
| 39 | + |
| 40 | + - name: Compile code |
| 41 | + working-directory: ./persistence-common |
| 42 | + run: mvn clean compile |
| 43 | + |
| 44 | + - name: Run unit tests |
| 45 | + working-directory: ./persistence-common |
| 46 | + run: mvn test |
| 47 | + |
| 48 | + - name: Package application |
| 49 | + working-directory: ./persistence-common |
| 50 | + run: mvn package -DskipTests |
| 51 | + |
| 52 | + - name: Run integration tests with Testcontainers |
| 53 | + working-directory: ./persistence-common |
| 54 | + run: mvn failsafe:integration-test |
| 55 | + env: |
| 56 | + # Testcontainers configuration |
| 57 | + TESTCONTAINERS_RYUK_DISABLED: false |
| 58 | + TESTCONTAINERS_DOCKER_SOCKET_OVERRIDE: /var/run/docker.sock |
| 59 | + |
| 60 | + - name: Verify integration tests |
| 61 | + working-directory: ./persistence-common |
| 62 | + run: mvn failsafe:verify |
| 63 | + |
| 64 | + - name: Upload unit test results |
| 65 | + if: always() |
| 66 | + uses: actions/upload-artifact@v4 |
| 67 | + with: |
| 68 | + name: unit-test-results-common |
| 69 | + path: persistence-common/target/surefire-reports/ |
| 70 | + retention-days: 30 |
| 71 | + |
| 72 | + - name: Upload integration test results |
| 73 | + if: always() |
| 74 | + uses: actions/upload-artifact@v4 |
| 75 | + with: |
| 76 | + name: integration-test-results-common |
| 77 | + path: persistence-common/target/failsafe-reports/ |
| 78 | + retention-days: 30 |
| 79 | + |
| 80 | + - name: Upload coverage reports |
| 81 | + if: always() |
| 82 | + uses: actions/upload-artifact@v4 |
| 83 | + with: |
| 84 | + name: coverage-common |
| 85 | + path: persistence-common/target/site/jacoco/ |
| 86 | + retention-days: 30 |
| 87 | + |
| 88 | + build: |
| 89 | + name: Build Persistence Common |
| 90 | + runs-on: ubuntu-latest |
| 91 | + needs: test |
| 92 | + |
| 93 | + steps: |
| 94 | + - name: Checkout code |
| 95 | + uses: actions/checkout@v4 |
| 96 | + |
| 97 | + - name: Set up JDK 17 |
| 98 | + uses: actions/setup-java@v4 |
| 99 | + with: |
| 100 | + java-version: '17' |
| 101 | + distribution: 'temurin' |
| 102 | + cache: maven |
| 103 | + |
| 104 | + - name: Build persistence-common |
| 105 | + working-directory: ./persistence-common |
| 106 | + run: mvn clean package -DskipTests |
| 107 | + |
| 108 | + - name: Upload JAR artifact |
| 109 | + uses: actions/upload-artifact@v4 |
| 110 | + with: |
| 111 | + name: persistence-common-jar |
| 112 | + path: persistence-common/target/*.jar |
| 113 | + retention-days: 7 |
| 114 | + |
| 115 | +# comments for publish job will be remove, until all integraiton and examples works fine |
| 116 | +# publish: |
| 117 | +# name: Publish to Maven Central |
| 118 | +# runs-on: ubuntu-latest |
| 119 | +# needs: [test, build] |
| 120 | +# # Only run if secrets are configured and on main branch |
| 121 | +# if: github.event_name == 'push' && github.ref == 'refs/heads/main' && secrets.MAVEN_USERNAME != '' |
| 122 | + |
| 123 | +# steps: |
| 124 | +# - name: Checkout code |
| 125 | +# uses: actions/checkout@v4 |
| 126 | + |
| 127 | +# - name: Set up JDK 17 |
| 128 | +# uses: actions/setup-java@v4 |
| 129 | +# with: |
| 130 | +# java-version: '17' |
| 131 | +# distribution: 'temurin' |
| 132 | +# cache: maven |
| 133 | + |
| 134 | +# # GPG signing is required for Maven Central publication |
| 135 | +# # Maven Central requires all artifacts to be GPG signed for security |
| 136 | +# # If you don't need to publish to Maven Central, you can remove this job entirely |
| 137 | +# - name: Configure GPG Key for Artifact Signing |
| 138 | +# env: |
| 139 | +# GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }} |
| 140 | +# GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }} |
| 141 | +# run: | |
| 142 | +# if [ -z "$GPG_PRIVATE_KEY" ] || [ -z "$GPG_PASSPHRASE" ]; then |
| 143 | +# echo "GPG keys not configured. Skipping Maven Central publication." |
| 144 | +# exit 0 |
| 145 | +# fi |
| 146 | +# echo "$GPG_PRIVATE_KEY" | gpg --batch --import |
| 147 | +# echo "default-cache-ttl 600" >> ~/.gnupg/gpg.conf |
| 148 | + |
| 149 | +# - name: Publish to Maven Central |
| 150 | +# working-directory: ./persistence-common |
| 151 | +# env: |
| 152 | +# MAVEN_USERNAME: ${{ secrets.MAVEN_USERNAME }} |
| 153 | +# MAVEN_PASSWORD: ${{ secrets.MAVEN_PASSWORD }} |
| 154 | +# run: | |
| 155 | +# if [ -z "$MAVEN_USERNAME" ] || [ -z "$MAVEN_PASSWORD" ]; then |
| 156 | +# echo "Maven Central credentials not configured. Skipping publication." |
| 157 | +# exit 0 |
| 158 | +# fi |
| 159 | +# mvn clean deploy -P release \ |
| 160 | +# -DskipTests \ |
| 161 | +# -Dgpg.passphrase=$GPG_PASSPHRASE |
0 commit comments