|
| 1 | +name: log4u-dev-build |
| 2 | +on: |
| 3 | + pull_request: |
| 4 | + branches: |
| 5 | + - develop # develop pr |
| 6 | + types: [ opened, synchronize, reopened ] |
| 7 | + workflow_dispatch: |
| 8 | +jobs: |
| 9 | + build: |
| 10 | + name: Build and analyze |
| 11 | + runs-on: ubuntu-latest |
| 12 | + steps: |
| 13 | + - uses: actions/checkout@v4 |
| 14 | + with: |
| 15 | + fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis |
| 16 | + |
| 17 | + - name: Set up JDK 21 |
| 18 | + uses: actions/setup-java@v4 |
| 19 | + with: |
| 20 | + java-version: 21 |
| 21 | + distribution: 'zulu' # Alternative distribution options are available |
| 22 | + |
| 23 | + - name: Cache Gradle packages |
| 24 | + uses: actions/cache@v4 |
| 25 | + with: |
| 26 | + path: ~/.gradle/caches |
| 27 | + key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }} |
| 28 | + restore-keys: ${{ runner.os }}-gradle |
| 29 | + |
| 30 | + - name: Cache SonarCloud packages |
| 31 | + uses: actions/cache@v4 |
| 32 | + with: |
| 33 | + path: ~/.sonar/cache |
| 34 | + key: ${{ runner.os }}-sonar |
| 35 | + restore-keys: ${{ runner.os }}-sonar |
| 36 | + |
| 37 | + |
| 38 | + - name: MySQL 컨테이너 실행 |
| 39 | + run: | |
| 40 | + docker run --name log4u-mysql \ |
| 41 | + -e MYSQL_ROOT_PASSWORD=root \ |
| 42 | + -e MYSQL_DATABASE=log4u \ |
| 43 | + -e MYSQL_USER=dev \ |
| 44 | + -e MYSQL_PASSWORD=devcos4-team08 \ |
| 45 | + -d \ |
| 46 | + -p 3307:3306 \ |
| 47 | + mysql:8.0.33 |
| 48 | +
|
| 49 | + - name: Build and analyze |
| 50 | + env: |
| 51 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 52 | + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} |
| 53 | + DB_URL: jdbc:mysql://localhost:3307/log4u |
| 54 | + DB_USERNAME: dev |
| 55 | + DB_PASSWORD: devcos4-team08 |
| 56 | + |
| 57 | + # dev 프로필 사용 |
| 58 | + run: | |
| 59 | + chmod +x ./gradlew |
| 60 | + # 소나클라우드 임시 비활성화 ./gradlew build jacocoTestReport sonar --info -Pprofile=dev -Dsonar.branch.name=${{ github.ref_name }} |
| 61 | + ./gradlew build jacocoTestReport -Pprofile=dev |
| 62 | +
|
| 63 | + - name: Docker MySQL 종료 및 제거 |
| 64 | + run: | |
| 65 | + docker stop log4u-mysql |
| 66 | + docker rm log4u-mysql |
| 67 | +
|
| 68 | + - name: Upload Test Report |
| 69 | + uses: actions/upload-artifact@v4 |
| 70 | + with: |
| 71 | + name: problems-report |
| 72 | + path: build/reports/problems/problems-report.html |
0 commit comments