Skip to content

Commit f673c7b

Browse files
committed
Пример проекта для курса Java Junior Developer
0 parents  commit f673c7b

9 files changed

Lines changed: 177 additions & 0 deletions

File tree

‎.github/workflows/ci.yml‎

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [ master, main ]
6+
pull_request:
7+
branches: [ master, main ]
8+
workflow_dispatch:
9+
10+
concurrency:
11+
group: ${{ github.workflow }}-${{ github.ref }}
12+
cancel-in-progress: true
13+
14+
jobs:
15+
build:
16+
runs-on: ubuntu-latest
17+
timeout-minutes: 15
18+
19+
steps:
20+
- uses: actions/checkout@v4
21+
22+
- name: Set up JDK 17
23+
uses: actions/setup-java@v4
24+
with:
25+
java-version: '17'
26+
distribution: 'temurin'
27+
cache: 'maven'
28+
29+
- name: Build with Maven
30+
run: mvn -B clean compile -Dmaven.test.skip=true -Djava.awt.headless=true
31+
32+
- name: Run tests with coverage
33+
run: mvn -B test jacoco:report -Djava.awt.headless=true || true
34+
35+
- name: Show coverage summary
36+
run: |
37+
if [ -f target/site/jacoco/jacoco.csv ]; then
38+
echo "## Test Coverage Report" >> $GITHUB_STEP_SUMMARY
39+
echo '```' >> $GITHUB_STEP_SUMMARY
40+
awk -F',' 'NR>1 {missed+=$4; covered+=$5} END {total=missed+covered; if(total>0) printf "Line Coverage: %d/%d (%.1f%%)\nMissed: %d lines\n", covered, total, covered*100/total, missed; else print "No coverage data"}' target/site/jacoco/jacoco.csv >> $GITHUB_STEP_SUMMARY
41+
echo '```' >> $GITHUB_STEP_SUMMARY
42+
else
43+
echo "No JaCoCo coverage report found" >> $GITHUB_STEP_SUMMARY
44+
fi
45+
46+
- name: Upload coverage to Codecov
47+
uses: codecov/codecov-action@v4
48+
with:
49+
file: target/site/jacoco/jacoco.xml
50+
fail_ci_if_error: false
51+
env:
52+
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}

‎.gitignore‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
target/
2+
pom.xml.tag
3+
pom.xml.releaseBackup
4+
pom.xml.versionsBackup
5+
pom.xml.next
6+
release.properties
7+
dependency-reduced-pom.xml
8+
buildNumber.properties
9+
.mvn/timing.properties
10+
.idea
11+
*.iml

‎.travis.yml‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
language: java
2+
jdk:
3+
- oraclejdk8

‎CLAUDE.md‎

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# ProjectExample — Пример проекта для курса Java Junior Developer
2+
3+
## Learning Objectives
4+
5+
This is educational material. Key goals:
6+
- Study the source code and understand the patterns used
7+
- Complete exercises and homework assignments
8+
- Experiment with modifications to deepen understanding
9+
10+
## Prerequisites
11+
12+
- JDK 8+
13+
- Maven 3.x
14+
15+
## Build & Run
16+
17+
```bash
18+
mvn clean install
19+
mvn test
20+
```
21+
22+
## Development Guidelines
23+
24+
### Code Style
25+
- Follow standard Java conventions
26+
- Keep code clean and well-organized
27+
- Use meaningful variable and method names
28+
29+
### Git Workflow
30+
- Write clear, descriptive commit messages
31+
- One logical change per commit
32+
- Test before committing
33+
34+
### Testing
35+
- Write tests for new functionality
36+
- Run the full test suite before pushing
37+
- Keep tests focused and independent

‎README.md‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# ProjectExample
2+
Пример проекта для курса Java Junior Developer

‎pom.xml‎

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xmlns="http://maven.apache.org/POM/4.0.0"
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+
<!-- POM = Project Object Model -->
8+
<groupId>ru.levelp</groupId>
9+
<artifactId>ProjectExample</artifactId>
10+
<version>1.0-SNAPSHOT</version>
11+
12+
<properties>
13+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
14+
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
15+
<!-- Версия Java которой мы будем компилировать -->
16+
<java.version>1.8</java.version>
17+
</properties>
18+
19+
<dependencies>
20+
<dependency>
21+
<groupId>junit</groupId>
22+
<artifactId>junit</artifactId>
23+
<version>4.11</version>
24+
<scope>test</scope>
25+
</dependency>
26+
</dependencies>
27+
28+
<build>
29+
<pluginManagement>
30+
<plugins>
31+
<plugin>
32+
<groupId>org.apache.maven.plugins</groupId>
33+
<artifactId>maven-compiler-plugin</artifactId>
34+
<version>3.1</version>
35+
<configuration>
36+
<!-- Версия Java для исходников -->
37+
<source>${java.version}</source>
38+
<!-- Версия Java для байт-кода -->
39+
<target>${java.version}</target>
40+
</configuration>
41+
</plugin>
42+
</plugins>
43+
</pluginManagement>
44+
</build>
45+
</project>

‎src/main/java/Sum.java‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
public class Sum {
2+
public static int sum(int a, int b) {
3+
return a + b;
4+
}
5+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
name=value

‎src/test/java/ExampleTest.java‎

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import org.junit.Assert;
2+
import org.junit.Before;
3+
import org.junit.Test;
4+
5+
public class ExampleTest extends Assert {
6+
7+
@Before
8+
public void setUp() {
9+
System.out.println("Перед каждым тестом");
10+
}
11+
12+
@Test
13+
public void testSum() {
14+
assertEquals(5, Sum.sum(2, 3));
15+
}
16+
17+
@Test
18+
public void testSum2() {
19+
assertEquals(2000, Sum.sum(1000, 1000));
20+
}
21+
}

0 commit comments

Comments
 (0)