Some checks are pending
Gradle CI with MySQL and Jacoco / build (push) Has started running
73 lines
1.8 KiB
YAML
73 lines
1.8 KiB
YAML
name: Gradle CI with MySQL and Jacoco
|
|
|
|
on:
|
|
push:
|
|
branches: [ main ]
|
|
pull_request:
|
|
branches: [ main ]
|
|
|
|
jobs:
|
|
build:
|
|
runs-on: ubuntu-latest
|
|
|
|
services:
|
|
mysql:
|
|
image: mysql:8.0
|
|
env:
|
|
MYSQL_ROOT_PASSWORD: root
|
|
MYSQL_DATABASE: hhn
|
|
MYSQL_USER: hhn
|
|
MYSQL_PASSWORD: "!9oSmhsiwYO.m)_x"
|
|
ports:
|
|
- 3306:3306
|
|
options: >-
|
|
--health-cmd="mysqladmin ping -h localhost -uroot -proot"
|
|
--health-interval=10s
|
|
--health-timeout=5s
|
|
--health-retries=10
|
|
|
|
steps:
|
|
- name: Checkout repository
|
|
uses: actions/checkout@v3
|
|
|
|
- name: Set up Java 17
|
|
uses: actions/setup-java@v3
|
|
with:
|
|
distribution: temurin
|
|
java-version: 17
|
|
cache: gradle
|
|
|
|
- name: Cache Gradle Wrapper
|
|
uses: actions/cache@v3
|
|
with:
|
|
path: ~/.gradle/wrapper/dists
|
|
key: gradle-wrapper-${{ runner.os }}-${{ hashFiles('gradle/wrapper/gradle-wrapper.properties') }}
|
|
|
|
- name: Wait for MySQL to be ready
|
|
run: |
|
|
for i in `seq 1 30`; do
|
|
if mysqladmin ping -h 127.0.0.1 -u root -proot --silent; then
|
|
echo "MySQL is up!"
|
|
exit 0
|
|
fi
|
|
echo "Waiting for MySQL..."
|
|
sleep 2
|
|
done
|
|
echo "MySQL did not start in time" >&2
|
|
exit 1
|
|
|
|
- name: Install MySQL client
|
|
run: sudo apt-get update && sudo apt-get install -y mysql-client
|
|
|
|
- name: Setup DB schema
|
|
run: mysql -h 127.0.0.1 -u root -proot hhn < schema.sql
|
|
|
|
- name: Build & Test
|
|
run: ./gradlew --no-daemon test jacocoTestReport
|
|
|
|
- name: Upload Jacoco HTML Report
|
|
uses: actions/upload-artifact@v3
|
|
with:
|
|
name: jacoco-html-report
|
|
path: build/jacocoHtml
|