diff --git a/.github/workflows/test.yml b/.github/workflows/test-dev.yml similarity index 100% rename from .github/workflows/test.yml rename to .github/workflows/test-dev.yml diff --git a/.github/workflows/test-main.yml b/.github/workflows/test-main.yml new file mode 100644 index 00000000..0b54b36f --- /dev/null +++ b/.github/workflows/test-main.yml @@ -0,0 +1,72 @@ +# This workflow uses actions that are not certified by GitHub. +# They are provided by a third-party and are governed by +# separate terms of service, privacy policy, and support +# documentation. +# This workflow will build a Java project with Gradle and cache/restore any dependencies to improve the workflow execution time +# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-java-with-gradle + +name: Test main branch + +on: + pull_request: + branches: [ "main" ] + + +jobs: + test: + runs-on: ubuntu-latest + + permissions: + contents: read + + # set up java + steps: + - uses: actions/checkout@v4 + - name: Set up JDK 17 + uses: actions/setup-java@v4 + with: + java-version: '17' + distribution: 'temurin' + + # set up application file + - name: Create application.yml + run: | + mkdir -p ./src/main/resources + cd ./src/main/resources + echo "${{ secrets.APPLICATION }}" > application.yml + echo "${{ secrets.APPLICATION_MAIN }}" > application-test.yml + + # apply caching + - name: Gradle Caching + uses: actions/cache@v3 + with: + path: | + ~/.gradle/caches + ~/.gradle/wrapper + key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} + restore-keys: | + ${{ runner.os }}-gradle- + + # gradle grant execution permission and build project + - name: Setup Gradle + run: | + chmod +x ./gradlew + ./gradlew clean build -Pprofile=test + + - name: Error Report + if : ${{ failure() }} + run: | + echo "Error Report..." + mkdir error-report + REPORT_DIRS=$(find . -type d -path '*/build/reports/tests/test') + for dir in $REPORT_DIRS; do + module_path=$(echo $dir | awk -F'/build/' '{print $1}' | cut -c 3-) + cp -r $dir error-report/$module_path/$(basename $(dirname $dir)) + done + - name: Upload Report to Artifact + if: ${{ failure() }} + uses: actions/upload-artifact@v2 + with: + name: error-report + path: error-report +