Skip to content

Merge pull request #9 from Rurutia1027/b_support-mysql #17

Merge pull request #9 from Rurutia1027/b_support-mysql

Merge pull request #9 from Rurutia1027/b_support-mysql #17

name: Persistence Sharding CI
on:
push:
branches: [ main, develop ]
paths:
- 'persistence-sharding/**'
- 'persistence-common/**'
- '.github/workflows/persistence-sharding-ci.yml'
pull_request:
branches: [ main, develop ]
paths:
- 'persistence-sharding/**'
- 'persistence-common/**'
- '.github/workflows/persistence-sharding-ci.yml'
workflow_dispatch:
jobs:
test:
name: Test Persistence Sharding
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'
cache: maven
- name: Cache Maven dependencies
uses: actions/cache@v4
with:
path: ~/.m2
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
restore-keys: ${{ runner.os }}-m2
- name: Build persistence-common first
working-directory: ./persistence-common
run: mvn clean install -DskipTests
- name: Compile code
working-directory: ./persistence-sharding
run: mvn clean compile
- name: Run unit tests
working-directory: ./persistence-sharding
run: mvn test
- name: Package application
working-directory: ./persistence-sharding
run: mvn package -DskipTests
- name: Run integration tests with Testcontainers
working-directory: ./persistence-sharding
run: mvn failsafe:integration-test
env:
# Testcontainers configuration
TESTCONTAINERS_RYUK_DISABLED: false
TESTCONTAINERS_DOCKER_SOCKET_OVERRIDE: /var/run/docker.sock
- name: Verify integration tests
working-directory: ./persistence-sharding
run: mvn failsafe:verify
- name: Upload unit test results
if: always()
uses: actions/upload-artifact@v4
with:
name: unit-test-results-sharding
path: persistence-sharding/target/surefire-reports/
retention-days: 30
- name: Upload integration test results
if: always()
uses: actions/upload-artifact@v4
with:
name: integration-test-results-sharding
path: persistence-sharding/target/failsafe-reports/
retention-days: 30
- name: Upload coverage reports
if: always()
uses: actions/upload-artifact@v4
with:
name: coverage-sharding
path: persistence-sharding/target/site/jacoco/
retention-days: 30
build:
name: Build Persistence Sharding
runs-on: ubuntu-latest
needs: test
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'
cache: maven
- name: Build persistence-common
working-directory: ./persistence-common
run: mvn clean install -DskipTests
- name: Build persistence-sharding
working-directory: ./persistence-sharding
run: mvn clean package -DskipTests
- name: Upload JAR artifact
uses: actions/upload-artifact@v4
with:
name: persistence-sharding-jar
path: persistence-sharding/target/*.jar
retention-days: 7
# For now we don't need publish jars to maven center
# publish:
# name: Publish to Maven Central
# runs-on: ubuntu-latest
# needs: [test, build]
# # Only run if secrets are configured and on main branch
# if: github.event_name == 'push' && github.ref == 'refs/heads/main' && secrets.MAVEN_USERNAME != ''
# steps:
# - name: Checkout code
# uses: actions/checkout@v4
# - name: Set up JDK 17
# uses: actions/setup-java@v4
# with:
# java-version: '17'
# distribution: 'temurin'
# cache: maven
# # GPG signing is required for Maven Central publication
# # Maven Central requires all artifacts to be GPG signed for security
# # If you don't need to publish to Maven Central, you can remove this job entirely
# - name: Configure GPG Key for Artifact Signing
# env:
# GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }}
# GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
# run: |
# if [ -z "$GPG_PRIVATE_KEY" ] || [ -z "$GPG_PASSPHRASE" ]; then
# echo "GPG keys not configured. Skipping Maven Central publication."
# exit 0
# fi
# echo "$GPG_PRIVATE_KEY" | gpg --batch --import
# echo "default-cache-ttl 600" >> ~/.gnupg/gpg.conf
# - name: Build and publish persistence-common
# working-directory: ./persistence-common
# env:
# MAVEN_USERNAME: ${{ secrets.MAVEN_USERNAME }}
# MAVEN_PASSWORD: ${{ secrets.MAVEN_PASSWORD }}
# run: |
# if [ -z "$MAVEN_USERNAME" ] || [ -z "$MAVEN_PASSWORD" ]; then
# echo "Maven Central credentials not configured. Skipping publication."
# exit 0
# fi
# mvn clean deploy -P release \
# -DskipTests \
# -Dgpg.passphrase=$GPG_PASSPHRASE
# - name: Publish persistence-sharding to Maven Central
# working-directory: ./persistence-sharding
# env:
# MAVEN_USERNAME: ${{ secrets.MAVEN_USERNAME }}
# MAVEN_PASSWORD: ${{ secrets.MAVEN_PASSWORD }}
# run: |
# if [ -z "$MAVEN_USERNAME" ] || [ -z "$MAVEN_PASSWORD" ]; then
# echo "Maven Central credentials not configured. Skipping publication."
# exit 0
# fi
# mvn clean deploy -P release \
# -DskipTests \
# -Dgpg.passphrase=$GPG_PASSPHRASE