👷 chore: Added CI workflow and Jacoco test coverage reporting support.
This commit is contained in:
parent
37f9617d29
commit
ce18b75cd5
2 changed files with 95 additions and 0 deletions
80
.github/workflows/ci.yml
vendored
Normal file
80
.github/workflows/ci.yml
vendored
Normal file
|
|
@ -0,0 +1,80 @@
|
|||
name: CI
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ "dev", "main" ]
|
||||
paths:
|
||||
- 'api/**'
|
||||
pull_request:
|
||||
branches: [ "main", "dev" ]
|
||||
paths:
|
||||
- 'api/**'
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: 'ubuntu-24.04'
|
||||
permissions:
|
||||
contents: read
|
||||
defaults:
|
||||
run:
|
||||
working-directory: ./api
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Set up JDK 21
|
||||
uses: actions/setup-java@v4
|
||||
with:
|
||||
java-version: '21'
|
||||
distribution: 'temurin'
|
||||
|
||||
- name: Setup Gradle
|
||||
uses: gradle/gradle-build-action@v2
|
||||
|
||||
- name: Cache tdlib and config
|
||||
id: cache-tdlib
|
||||
uses: actions/cache@v3
|
||||
with:
|
||||
path: |
|
||||
../libs
|
||||
../.env.test
|
||||
key: ${{ runner.os }}-tdlib-1.15.0
|
||||
|
||||
- name: Download tdlib and create .env.test file
|
||||
if: steps.cache-tdlib.outputs.cache-hit != 'true'
|
||||
run: |
|
||||
cd ../ && \
|
||||
wget --no-check-certificate -q -O libs.zip https://github.com/p-vorobyev/spring-boot-starter-telegram/releases/download/1.15.0/libs.zip && \
|
||||
unzip -q libs.zip && \
|
||||
cat <<EOF > .env.test
|
||||
TDLIB_PATH=../libs/linux_x64
|
||||
APP_ENV=prod
|
||||
APP_ROOT=${{ github.workspace }}/data
|
||||
TELEGRAM_API_ID=94575
|
||||
TELEGRAM_API_HASH=a3406de8d171bb422bb6ddf3bbd800e2
|
||||
LOG_LEVEL=FINE
|
||||
EOF
|
||||
|
||||
- name: Grant execute permission for gradlew
|
||||
run: chmod +x gradlew
|
||||
|
||||
- name: Build with Gradle
|
||||
run: ./gradlew build
|
||||
|
||||
- name: Run tests
|
||||
run: ./gradlew test
|
||||
|
||||
- name: Cache Gradle packages
|
||||
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: Upload coverage to Codecov
|
||||
uses: codecov/codecov-action@v5
|
||||
env:
|
||||
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
|
||||
|
|
@ -1,6 +1,7 @@
|
|||
plugins {
|
||||
id 'java'
|
||||
id 'com.gradleup.shadow' version '8.3.5'
|
||||
id 'jacoco'
|
||||
}
|
||||
|
||||
group = 'telegram.files'
|
||||
|
|
@ -45,6 +46,20 @@ test {
|
|||
jvmArgs "-Djava.library.path=${System.getenv('TDLIB_PATH')}"
|
||||
environment "APP_ROOT", "${testClassesDirs.asPath}"
|
||||
useJUnitPlatform()
|
||||
finalizedBy jacocoTestReport
|
||||
}
|
||||
|
||||
jacocoTestReport {
|
||||
dependsOn test
|
||||
reports {
|
||||
xml.required = true
|
||||
html.required = false
|
||||
}
|
||||
afterEvaluate {
|
||||
classDirectories = files(classDirectories.files.collect {
|
||||
fileTree(dir: it, exclude: "org/drinkless/tdlib/**")
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
tasks.build {
|
||||
|
|
|
|||
Loading…
Reference in a new issue