Skip to content

Commit 7cbe000

Browse files
author
coursar
committed
feat(ci)
1 parent 0b9e1da commit 7cbe000

File tree

6 files changed

+163
-1
lines changed

6 files changed

+163
-1
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
2.4. [x] [Циклы, параметризованные тесты и аннотации](params)
1818

19-
2.5. [ ] [Выстраивание процесса непрерывной интеграции (CI): Github Actions. Покрытие кода с JaCoCo, статический анализ кода: CheckStyle, SpotBugs](continuous)
19+
2.5. [x] [Выстраивание процесса непрерывной интеграции (CI): Github Actions. Покрытие кода с JaCoCo, статический анализ кода: CheckStyle, SpotBugs](ci)
2020

2121
## Блок 3. ООП
2222

ci/.github/workflows/maven.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
name: Java CI # как называется Workflow
2+
3+
on: [push] # когда срабатывает (на push)
4+
5+
jobs: # какие задачи делаем
6+
build: # сборка
7+
runs-on: ubuntu-latest # на какой ОС запускаем
8+
9+
steps: # какие шаги выполняем
10+
- uses: actions/checkout@v2 # выкачиваем репо
11+
- name: Set up JDK 11
12+
uses: actions/setup-java@v1 # устанавливаем JDK
13+
with:
14+
java-version: 11 # версия для установки
15+
- name: Build with Maven
16+
run: mvn -B -e verify # запускаем Maven

ci/.gitignore

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
Thumbs.db*
2+
.DS_Store*
3+
HELP.md
4+
.gradle
5+
build/
6+
target/
7+
8+
### STS ###
9+
.apt_generated
10+
.classpath
11+
.factorypath
12+
.project
13+
.settings
14+
.springBeans
15+
.sts4-cache
16+
17+
### IntelliJ IDEA ###
18+
.idea
19+
*.iws
20+
*.iml
21+
*.ipr
22+
out/
23+
24+
### NetBeans ###
25+
/nbproject/private/
26+
/nbbuild/
27+
/dist/
28+
/nbdist/
29+
/.nb-gradle/
30+
31+
### VS Code ###
32+
.vscode/
33+
34+
### Package Files ###
35+
*.jar
36+
*.war
37+
*.nar
38+
*.ear
39+
*.zip
40+
*.tar.gz
41+
*.rar
42+
43+
### Exclusions ###
44+
!gradle/wrapper/gradle-wrapper.jar
45+
!.mvn/wrapper/maven-wrapper.jar
46+
!**/src/main/**
47+
!**/src/test/**

ci/pom.xml

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
5+
<modelVersion>4.0.0</modelVersion>
6+
7+
<groupId>ru.netology</groupId>
8+
<artifactId>statistics</artifactId>
9+
<version>1.0-SNAPSHOT</version>
10+
11+
<properties>
12+
<maven.compiler.source>11</maven.compiler.source>
13+
<maven.compiler.target>11</maven.compiler.target>
14+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
15+
</properties>
16+
17+
<dependencies>
18+
<dependency>
19+
<groupId>org.junit.jupiter</groupId>
20+
<artifactId>junit-jupiter</artifactId>
21+
<version>5.4.2</version>
22+
<scope>test</scope>
23+
</dependency>
24+
</dependencies>
25+
26+
<build>
27+
<plugins>
28+
<plugin>
29+
<groupId>org.apache.maven.plugins</groupId>
30+
<artifactId>maven-surefire-plugin</artifactId>
31+
<version>2.22.2</version>
32+
<configuration>
33+
<failIfNoTests>true</failIfNoTests>
34+
</configuration>
35+
</plugin>
36+
<plugin>
37+
<groupId>org.jacoco</groupId>
38+
<artifactId>jacoco-maven-plugin</artifactId>
39+
<version>0.8.5</version>
40+
<executions>
41+
<execution>
42+
<id>prepare-agent</id>
43+
<phase>initialize</phase>
44+
<goals>
45+
<goal>prepare-agent</goal>
46+
</goals>
47+
</execution>
48+
<execution>
49+
<id>report</id>
50+
<phase>verify</phase>
51+
<goals>
52+
<goal>report</goal>
53+
</goals>
54+
</execution>
55+
</executions>
56+
</plugin>
57+
</plugins>
58+
</build>
59+
</project>
60+
61+
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
package ru.netology.statistic;
2+
3+
public class StatisticsService {
4+
/**
5+
* Calculate index of max income
6+
*
7+
* @param incomes - array of incomes
8+
* @return - index of first max value
9+
*/
10+
public long findMax(long[] incomes) {
11+
long current_max_index = 0;
12+
long current_max = incomes[0];
13+
for (long income : incomes)
14+
if (current_max < income)
15+
current_max = income;
16+
return current_max;
17+
}
18+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
package ru.netology.statistic;
2+
3+
import org.junit.jupiter.api.Test;
4+
5+
import static org.junit.jupiter.api.Assertions.*;
6+
7+
class StatisticsServiceTest {
8+
9+
@Test
10+
void findMax() {
11+
StatisticsService service = new StatisticsService();
12+
13+
long[] incomesInBillions = {12, 5, 8, 4, 5, 3, 8, 6, 11, 11, 12};
14+
long expected = 12;
15+
16+
long actual = service.findMax(incomesInBillions);
17+
18+
assertEquals(expected, actual);
19+
}
20+
}

0 commit comments

Comments
 (0)