Skip to content

#4 test: ci 스크립트 수정 #6

#4 test: ci 스크립트 수정

#4 test: ci 스크립트 수정 #6

Workflow file for this run

name: develop CI check
on:
push:
branches: [ "develop" ]
pull_request:
branches: [ "develop" ]
permissions:
checks: write
pull-requests: write
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: 레포지토리 체크아웃
uses: actions/checkout@v3
- name: 기본 MySQL 종료 (SUDO 필요)
run: sudo service mysql stop # 기본 MySQL 종료
- name: JDK 17 설치
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'adopt'
- 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-
- name: MySQL 설치
uses: mirromutth/mysql-action@v1.1
with:
character set server: 'utf8' # Optional, default value is 'utf8mb4'. The '--character-set-server' option for mysqld
mysql version: '8.0' # Optional, default value is "latest". The version of the MySQL
mysql database: market_db # Optional, default value is "test". The specified database which will be create
mysql user: actions # Required if "mysql root password" is empty, default is empty. The superuser for the specified database. Of course you can use secrets, too
mysql password: ${{ secrets.DB_PASSWORD }}
# - name: MySQL 설치
## uses: stamina/mysql-action@v1
# uses: mirromutth/mysql-action@v1
# with:
# host port: 3306 # Optional, default value is 3306. The port of host
# character set server: 'utf8' # Optional, default value is 'utf8mb4'. The '--character-set-server' option for mysqld
# collation server: 'utf8_general_ci' # Optional, default value is 'utf8mb4_general_ci'. The '--collation-server' option for mysqld
# mysql version: '8.0' # Optional, default value is "latest". The version of the MySQL
# mysql database: market_db # Optional, default value is "test". The specified database which will be create
# mysql user: root # Required if "mysql root password" is empty, default is empty. The superuser for the specified database. Of course you can use secrets, too
# mysql password: ${{ secrets.DB_PASSWORD }}
- name: properties 파일 생성
run: |
cd ./src/main
mkdir resources
cd ./resources
touch ./application.properties
echo "${{ secrets.APPLICATION_PROPERTIES }}" > ./application.properties
- name: Verify MySQL is running
run: sudo netstat -tlnp | grep 3306
- name: Verify application.properties
run: cat ./src/main/resources/application.properties
shell: bash
# gradle 실행 허가
- name: Run chmod to make gradlew executable
run: chmod +x ./gradlew
- name: 빌드 진행
# run: ./gradlew clean build --exclude-task test
run: ./gradlew build -x test
- name: Wait for MySQL
run: |
while ! mysqladmin ping --host=127.0.0.1 --password=$DB_PASSWORD --silent; do
sleep 1
done
- name: 테스트 코드 실행
run: ./gradlew --info test
- name: 테스트 결과 PR에 코멘트 작성
uses: EnricoMi/publish-unit-test-result-action@v2
if: always() # 테스트가 실패했을때만 or 테스트가 성공했을때만 알려주기(여기선 둘다!)
with:
files: |
**/build/test-results/**/*.xml
# Files changed에서 어디에서 잘못되었는지 가르쳐준다.
- name: Publish Test Report
uses: mikepenz/action-junit-report@v3
if: success() || failure() # always run even if the previous step fails
with:
report_paths: '**/build/test-results/test/TEST-*.xml'