Skip to content
This repository was archived by the owner on Dec 27, 2024. It is now read-only.

Commit 509721a

Browse files
dev/git/ Добавление workflow (#4)
* dev/db/ Добавил workflow * dev/db/ Исправил код под checkstyle * dev/db/ Поменял версию ubuntu с latest на определенную версию * dev/db/ Добавил jacoco * dev/db/ Добавил миграции для тестов * dev/db/ Попытка добавить загрузку бд в контекст потока * dev/db/ Добавил библиотеки для тестов * dev/db/ Попытка добавить проход тестов в wf * dev/db/ Удалил ненужный тест * dev/db/ убрал wait-for-it.sh в dockerFile
1 parent 4d49095 commit 509721a

File tree

9 files changed

+615
-15
lines changed

9 files changed

+615
-15
lines changed

.github/workflows/ci.yml

Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
name: CI
2+
3+
on:
4+
pull_request:
5+
push:
6+
branches:
7+
- main
8+
9+
permissions:
10+
contents: read
11+
packages: write
12+
pull-requests: write
13+
14+
jobs:
15+
build:
16+
runs-on: ubuntu-24.04
17+
name: Build
18+
19+
steps:
20+
- uses: actions/checkout@v4
21+
22+
- name: Set up JDK 21
23+
uses: actions/setup-java@v4
24+
with:
25+
java-version: '21'
26+
distribution: 'temurin'
27+
cache: gradle
28+
29+
- name: Grant execute permission for gradlew
30+
run: chmod +x gradlew
31+
32+
- name: Build project
33+
run: ./gradlew bootJar
34+
35+
test:
36+
runs-on: ubuntu-24.04
37+
name: Test
38+
needs: build
39+
40+
steps:
41+
- uses: actions/checkout@v4
42+
43+
- name: Set up JDK 21
44+
uses: actions/setup-java@v4
45+
with:
46+
java-version: '21'
47+
distribution: 'temurin'
48+
cache: gradle
49+
50+
- name: Grant execute permission for gradlew
51+
run: chmod +x gradlew
52+
53+
- name: Run tests
54+
run: ./gradlew test
55+
56+
- name: Run tests with coverage
57+
run: ./gradlew jacocoTestReport
58+
59+
- name: Jacoco Report to PR
60+
id: jacoco
61+
uses: madrapps/jacoco-report@v1.7.1
62+
with:
63+
paths: ${{ github.workspace }}/build/reports/jacoco/test/jacocoTestReport.xml
64+
token: ${{ secrets.GITHUB_TOKEN }}
65+
66+
min-coverage-overall: 40
67+
min-coverage-changed-files: 60
68+
title: Code Coverage
69+
update-comment: true
70+
71+
lint:
72+
runs-on: ubuntu-24.04
73+
name: Style
74+
needs: build
75+
76+
steps:
77+
- name: Checkout code
78+
uses: actions/checkout@v4
79+
80+
- name: Set up JDK 21
81+
uses: actions/setup-java@v4
82+
with:
83+
java-version: '21'
84+
distribution: 'temurin'
85+
cache: gradle
86+
87+
- name: Grant execute permission for gradlew
88+
run: chmod +x gradlew
89+
90+
- name: Run static code analysis
91+
run: ./gradlew checkstyleMain
92+
93+
package:
94+
runs-on: ubuntu-24.04
95+
name: Package
96+
needs: [test, lint]
97+
98+
steps:
99+
- name: Checkout code
100+
uses: actions/checkout@v4
101+
102+
- name: Set up QEMU
103+
uses: docker/setup-qemu-action@v3
104+
105+
- name: Set up Docker Buildx
106+
uses: docker/setup-buildx-action@v3
107+
108+
- name: Log in to GitHub Container Registry
109+
uses: docker/login-action@v3
110+
with:
111+
registry: ghcr.io
112+
username: ${{ github.actor }}
113+
password: ${{ secrets.GTHB_TOKEN }}
114+
115+
- name: Build and push Docker image
116+
uses: docker/build-push-action@v6
117+
with:
118+
context: .
119+
file: ./docker/fintech.Dockerfile
120+
push: true
121+
tags: ghcr.io/alexandergarifullin/fintech:latest

build.gradle

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ plugins {
22
id 'java'
33
id 'org.springframework.boot' version '3.3.4'
44
id 'io.spring.dependency-management' version '1.1.6'
5+
id 'jacoco'
6+
id 'checkstyle'
57
}
68

79
group = 'com.cf'
@@ -17,6 +19,11 @@ repositories {
1719
mavenCentral()
1820
}
1921

22+
checkstyle {
23+
toolVersion = '10.3'
24+
configFile = file("${rootDir}/config/checkstyle/checkstyle.xml")
25+
}
26+
2027
dependencies {
2128
// spring
2229
implementation 'org.springframework.boot:spring-boot-starter-web'
@@ -32,9 +39,25 @@ dependencies {
3239

3340
// test
3441
testImplementation 'org.springframework.boot:spring-boot-starter-test'
35-
testRuntimeOnly 'org.junit.platform:junit-platform-launcher'
42+
testImplementation 'org.testcontainers:junit-jupiter:1.20.1'
43+
testImplementation 'org.wiremock:wiremock-standalone:3.9.1'
44+
testImplementation 'org.wiremock.integrations.testcontainers:wiremock-testcontainers-module:1.0-alpha-14'
45+
testImplementation 'org.testcontainers:postgresql:1.20.3'
46+
testImplementation 'org.liquibase:liquibase-core:4.29.2'
3647
}
3748

3849
tasks.named('test') {
3950
useJUnitPlatform()
4051
}
52+
53+
tasks.test {
54+
jvmArgs '-XX:+EnableDynamicAgentLoading'
55+
systemProperty "spring.profiles.active", "test"
56+
}
57+
58+
jacocoTestReport {
59+
reports {
60+
html.required = true
61+
xml.required = true
62+
}
63+
}

0 commit comments

Comments
 (0)