Skip to content

Commit

Permalink
Feat: main 브랜치 테스트 워크플로 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
kwonssshyeon committed Sep 2, 2024
1 parent 80704ff commit 2373fe8
Show file tree
Hide file tree
Showing 2 changed files with 73 additions and 0 deletions.
File renamed without changes.
73 changes: 73 additions & 0 deletions .github/workflows/test-main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
# 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-main.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=main
- name: Error Report
if : ${{ failure() }}
run: |
echo "Error Report..."
TIMESTAMP=$(date '+%Y%m%d%H%M%S')
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
tar czvf error-report_${TIMESTAMP}.tar.gz error-report
- name: Upload Report to Artifact
if: ${{ failure() }}
uses: actions/upload-artifact@v2
with:
name: error-report
path: error-report_*.tar.gz

0 comments on commit 2373fe8

Please sign in to comment.