๐ค [ci] ้ๆ ci ๆต็จ #2
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 | |
| on: | |
| push: | |
| branches: [ main ] | |
| pull_request: | |
| branches: [ main ] | |
| env: | |
| GRADLE_OPTS: "-Dorg.gradle.daemon=false -Dorg.gradle.parallel=true -Dorg.gradle.workers.max=4 -Dkotlin.incremental=false" | |
| jobs: | |
| test: | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 45 | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Cache Gradle dependencies | |
| uses: actions/cache@v4 | |
| with: | |
| path: | | |
| ~/.gradle/caches | |
| ~/.gradle/wrapper | |
| ~/.konan | |
| key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties', 'gradle/libs.versions.toml') }} | |
| restore-keys: | | |
| ${{ runner.os }}-gradle- | |
| - name: Set up JDK 17 | |
| uses: actions/setup-java@v4 | |
| with: | |
| java-version: '17' | |
| distribution: 'temurin' | |
| - name: Setup Gradle | |
| uses: gradle/actions/setup-gradle@v4 | |
| with: | |
| gradle-version: '9.0.0-rc-3' | |
| cache-read-only: ${{ github.ref != 'refs/heads/main' }} | |
| cache-cleanup: on-success | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Cache Docker layers | |
| uses: actions/cache@v4 | |
| with: | |
| path: /tmp/.buildx-cache | |
| key: ${{ runner.os }}-docker-${{ hashFiles('**/Dockerfile*', '**/docker-compose*') }} | |
| restore-keys: | | |
| ${{ runner.os }}-docker- | |
| - name: Verify Docker installation | |
| run: | | |
| docker --version | |
| docker info | |
| docker ps | |
| - name: Grant execute permission for gradlew | |
| run: chmod +x gradlew | |
| - name: Warm up Gradle daemon | |
| run: ./gradlew --version | |
| - name: Run build and tests | |
| run: ./gradlew clean build test --no-daemon --stacktrace --parallel --build-cache --configuration-cache | |
| env: | |
| # Testcontainers ไผๅ้ ็ฝฎ | |
| TESTCONTAINERS_RYUK_DISABLED: false | |
| TESTCONTAINERS_CHECKS_DISABLE: false | |
| TESTCONTAINERS_REUSE_ENABLE: true | |
| TESTCONTAINERS_HUB_IMAGE_NAME_PREFIX: "" | |
| # Docker ๆง่ฝไผๅ | |
| DOCKER_HOST: unix:///var/run/docker.sock | |
| TESTCONTAINERS_DOCKER_SOCKET_OVERRIDE: /var/run/docker.sock | |
| TESTCONTAINERS_HOST_OVERRIDE: localhost | |
| # JVM ๆง่ฝ่ฐไผ | |
| MAVEN_OPTS: "-Xmx2g -XX:+UseG1GC" | |
| # CI ็ฏๅข้ ็ฝฎ | |
| CI: true | |
| GRADLE_BUILD_ACTION_CACHE_DEBUG_ENABLED: true | |
| - name: Upload test results | |
| uses: actions/upload-artifact@v4 | |
| if: always() | |
| with: | |
| name: test-results | |
| path: | | |
| **/build/test-results/test/ | |
| **/build/reports/tests/test/ | |
| **/build/reports/jacoco/ | |
| - name: Upload coverage reports | |
| uses: actions/upload-artifact@v4 | |
| if: always() | |
| with: | |
| name: coverage-reports | |
| path: | | |
| **/build/reports/jacoco/test/html/ | |
| **/build/reports/jacoco/test/jacocoTestReport.xml | |
| - name: Cleanup Docker containers | |
| if: always() | |
| run: | | |
| docker container prune -f --filter "until=1h" | |
| docker image prune -f --filter "until=24h" | |
| docker volume prune -f --filter "label!=keep" | |
| - name: Cache cleanup | |
| if: always() | |
| run: | | |
| # ๆธ ็ๆง็ Gradle ็ผๅญๆไปถ | |
| find ~/.gradle/caches -name "*.lock" -delete || true | |
| find ~/.gradle/caches -type d -name "tmp" -exec rm -rf {} + || true |