test: add mq cdc and registry unit tests #129
This file contains hidden or 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
| name: CI | |
| permissions: | |
| contents: read | |
| on: | |
| push: | |
| branches: [ main ] | |
| tags: [ 'v*' ] | |
| pull_request: | |
| branches: [ main ] | |
| release: | |
| types: [ published ] | |
| workflow_dispatch: | |
| inputs: | |
| version: | |
| description: 'Version to publish (e.g., 0.1.0)' | |
| required: true | |
| concurrency: | |
| group: ci-${{ github.ref }} | |
| cancel-in-progress: true | |
| jobs: | |
| ci: | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 60 | |
| env: | |
| CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Set up JDK 17 | |
| uses: actions/setup-java@v4 | |
| with: | |
| distribution: temurin | |
| java-version: '17' | |
| cache: gradle | |
| - name: Verify Java | |
| run: | | |
| set -euo pipefail | |
| java -version | |
| javac -version | |
| - name: Start test environment (Redis, MySQL, PostgreSQL, Elasticsearch) | |
| run: | | |
| set -euo pipefail | |
| docker compose -f docker-compose.test.yml up -d | |
| # 等待所有服务就绪(使用 healthcheck) | |
| timeout 120 bash -c 'until docker compose -f docker-compose.test.yml ps | grep -q "healthy"; do sleep 2; done' | |
| docker compose -f docker-compose.test.yml ps | |
| - name: Build & Test (unit + integration) | |
| run: | | |
| set -euo pipefail | |
| ./gradlew clean check jacocoRootReport --warning-mode=all | |
| env: | |
| REDIS_URL: redis://127.0.0.1:6379 | |
| MYSQL_URL: jdbc:mysql://127.0.0.1:3306/test_db | |
| MYSQL_USER: test_user | |
| MYSQL_PASSWORD: test_password | |
| POSTGRES_URL: jdbc:postgresql://127.0.0.1:5432/test_db | |
| POSTGRES_USER: test_user | |
| POSTGRES_PASSWORD: test_password | |
| ELASTICSEARCH_URL: http://127.0.0.1:9200 | |
| - name: Upload coverage to Codecov | |
| uses: codecov/codecov-action@v5 | |
| with: | |
| token: ${{ env.CODECOV_TOKEN }} | |
| files: build/reports/jacoco/jacocoRootReport/jacocoRootReport.xml | |
| fail_ci_if_error: false | |
| verbose: true | |
| - name: Shutdown test environment | |
| if: always() | |
| run: | | |
| set -euo pipefail | |
| docker compose -f docker-compose.test.yml down -v || true | |
| - name: Publish to Maven Central | |
| if: ${{ (github.event_name == 'release' && github.event.action == 'published') || (github.event_name == 'workflow_dispatch' && github.event.inputs.version != '') || startsWith(github.ref, 'refs/tags/v') }} | |
| env: | |
| # Vanniktech Maven Publish (Central Portal) expects Gradle properties below | |
| ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.CENTRAL_PORTAL_USERNAME }} | |
| ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.CENTRAL_PORTAL_TOKEN }} | |
| # Also expose centralPortal* for newer plugin variants | |
| ORG_GRADLE_PROJECT_centralPortalUsername: ${{ secrets.CENTRAL_PORTAL_USERNAME }} | |
| ORG_GRADLE_PROJECT_centralPortalPassword: ${{ secrets.CENTRAL_PORTAL_TOKEN }} | |
| # In-memory GPG signing (multi-line ASCII armored private key) | |
| ORG_GRADLE_PROJECT_signingInMemoryKey: ${{ secrets.GPG_PRIVATE_KEY }} | |
| ORG_GRADLE_PROJECT_signingInMemoryKeyPassword: ${{ secrets.GPG_PASSWORD }} | |
| run: | | |
| set -euo pipefail | |
| ./gradlew -q checkCentralPortalCreds || true | |
| # If manually dispatched with an explicit version, allow override; otherwise axion uses git tag (e.g., v1.2.3) | |
| if [[ "${GITHUB_EVENT_NAME}" == "workflow_dispatch" && -n "${{ github.event.inputs.version }}" ]]; then | |
| EXTRA_ARGS=("-Pversion=${{ github.event.inputs.version }}") | |
| echo "Publishing with explicit version override: ${{ github.event.inputs.version }}" | |
| else | |
| EXTRA_ARGS=() | |
| echo "Publishing with axion-release derived version from git tags" | |
| fi | |
| ./gradlew "${EXTRA_ARGS[@]}" publishAllPublicationsToMavenCentralRepository --warning-mode=all --stacktrace |