Skip to content

Commit 61b45e5

Browse files
authored
Initial commit
0 parents  commit 61b45e5

File tree

19 files changed

+1380
-0
lines changed

19 files changed

+1380
-0
lines changed

.github/workflows/jacoco.yml

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
---
2+
name: Measure coverage
3+
4+
on:
5+
workflow_dispatch:
6+
pull_request:
7+
branches: [main]
8+
9+
env:
10+
COVERAGE_THRESHOLD: 0.8
11+
12+
permissions:
13+
contents: read
14+
pull-requests: write
15+
16+
jobs:
17+
test:
18+
name: Coverage with JaCoCo
19+
runs-on: ubuntu-latest
20+
steps:
21+
- name: Check out code
22+
uses: actions/checkout@v4
23+
24+
- name: Set up JDK 17
25+
uses: actions/setup-java@v4
26+
with:
27+
java-version: '17'
28+
distribution: temurin
29+
cache: maven
30+
31+
- name: Evaluate coverage
32+
run: mvn -B verify
33+
34+
- name: Create filtered JaCoCo CSV that contains only GT4500 results
35+
run: >
36+
> jacoco-gt4500.csv awk
37+
'NR==1{print;next}/GT4500/{print}'
38+
target/site/jacoco/jacoco.csv
39+
40+
- name: Generate JaCoCo badges
41+
id: jacoco
42+
uses: cicirello/jacoco-badge-generator@v2
43+
with:
44+
jacoco-csv-file: jacoco-gt4500.csv
45+
generate-coverage-badge: false
46+
generate-branches-badge: false
47+
workflow-summary-heading: JaCoCo Test Coverage Summary (GT4500)
48+
49+
- name: Log coverage metrics
50+
run: |
51+
echo "GT4500 instruction coverage = ${{ steps.jacoco.outputs.coverage }}"
52+
echo "GT4500 branch coverage = ${{ steps.jacoco.outputs.branches }}"
53+
54+
- name: Add PR comment with coverage metrics
55+
uses: mshick/add-pr-comment@v2
56+
with:
57+
message: |
58+
### JaCoCo Coverage Report (GT4500)
59+
60+
| Coverage Metric | Value | Threshold (Minimum) | |
61+
| --- | --- | --- | --- |
62+
| 👉 Instruction Coverage | ${{ steps.jacoco.outputs.coverage }} | ${{ env.COVERAGE_THRESHOLD }} | ${{ steps.jacoco.outputs.coverage < env.COVERAGE_THRESHOLD && '❌' || '✅' }} |
63+
| 🌳 Decision/Branch Coverage | ${{ steps.jacoco.outputs.branches }} | ${{ env.COVERAGE_THRESHOLD }} | ${{ steps.jacoco.outputs.branches < env.COVERAGE_THRESHOLD && '❌' || '✅' }} |
64+
allow-repeats: true
65+
66+
- name: Upload coverage report
67+
uses: actions/upload-artifact@v4
68+
with:
69+
name: jacoco-report
70+
path: target/site/jacoco/
71+
72+
- name: Fail job unless requirements are met
73+
if: ${{ steps.jacoco.outputs.coverage < env.COVERAGE_THRESHOLD || steps.jacoco.outputs.branches < env.COVERAGE_THRESHOLD }}
74+
uses: actions/github-script@v7
75+
with:
76+
script: core.setFailed('Coverage metrics do not meet requirements')
77+

.github/workflows/maven.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
---
2+
name: Java CI with Maven
3+
4+
on:
5+
push:
6+
branches: [main]
7+
pull_request:
8+
branches: [main]
9+
10+
jobs:
11+
build:
12+
name: Build with Maven
13+
runs-on: ubuntu-latest
14+
steps:
15+
- uses: actions/checkout@v4
16+
- name: Set up JDK 17
17+
uses: actions/setup-java@v4
18+
with:
19+
java-version: '17'
20+
distribution: temurin
21+
cache: maven
22+
- name: Build with Maven
23+
run: mvn -B package --file pom.xml

.gitignore

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
*.class
2+
3+
# Mobile Tools for Java (J2ME)
4+
.mtj.tmp/
5+
6+
# Package Files #
7+
*.jar
8+
*.war
9+
*.ear
10+
11+
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
12+
hs_err_pid*
13+
14+
# ignore target from Maven
15+
target/
16+
17+
# IntelliJ folder
18+
.idea/
19+
20+
# Visual Studio Code files
21+
*.classpath
22+
*.project
23+
.settings/
24+
.vscode/
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Licensed to the Apache Software Foundation (ASF) under one
2+
# or more contributor license agreements. See the NOTICE file
3+
# distributed with this work for additional information
4+
# regarding copyright ownership. The ASF licenses this file
5+
# to you under the Apache License, Version 2.0 (the
6+
# "License"); you may not use this file except in compliance
7+
# with the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing,
12+
# software distributed under the License is distributed on an
13+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
# KIND, either express or implied. See the License for the
15+
# specific language governing permissions and limitations
16+
# under the License.
17+
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.3/apache-maven-3.9.3-bin.zip
18+
wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.2.0/maven-wrapper-3.2.0.jar

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2017 Budapest University of Technology and Economics
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# SE Spaceship
2+
3+
This is a sample application for the [Software Engineering](http://www.mit.bme.hu/oktatas/targyak/vimiab04) course at BME MIT.
4+
5+
The application is simplified and deliberately contains bugs.
6+
7+
## Getting started
8+
9+
- The project is implemented in Java 11.
10+
- The project can be built using [Maven](https://maven.apache.org/).
11+
- [JUnit](https://junit.org/junit5/) is used for tests, and [Mockito](https://site.mockito.org/) for isolating dependencies.
12+
13+
Clone the repository and execute Maven to build the application:
14+
15+
```
16+
mvn compile
17+
```
18+
19+
To compile and run tests also execute:
20+
21+
```
22+
mvn test
23+
```
24+
25+
(That will be enough to know for the current exercises. If you are more interested, see [this](https://github.com/ftsrg-edu/swsv-labs/wiki/0b-Build-tools) short guide about Maven.)
26+
27+
As this is a really simple project, you can use the command-line build tools or a light-weight IDE like [Visual Studio Code](https://code.visualstudio.com/).
28+
29+
## Overview
30+
31+
The project represents an alpha version of a spaceship.
32+
33+
- The ship (`SpaceShip` interface) can fire one or more lasers or torpedos.
34+
- We have only one spaceship as of now (`GT4500`).
35+
- Currently two firing modes (`FiringMode`) are supported: firing only one or all instances of a given weapon type.
36+
- Lasers are not yet implemented, but the code for torpedo stores are ready (`TorpedoStore`).
37+
- For the GT4500 ship the rules for firing torpedoes can be found in the Javadoc comment of method `fireTorpedos`. They are already partially implemented.
38+
- There are currently two tests (`GT4500Test`), but be aware that they are not proper unit tests, as they do not isolate the dependencies of the tested class.
39+
40+
The code can be built, but due to missing features one of the tests fails. The first exercise will be to fix this.

0 commit comments

Comments
 (0)