Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
BBence19 authored Oct 30, 2024
0 parents commit f6c305c
Show file tree
Hide file tree
Showing 19 changed files with 1,380 additions and 0 deletions.
77 changes: 77 additions & 0 deletions .github/workflows/jacoco.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
---
name: Measure coverage

on:
workflow_dispatch:
pull_request:
branches: [main]

env:
COVERAGE_THRESHOLD: 0.8

permissions:
contents: read
pull-requests: write

jobs:
test:
name: Coverage with JaCoCo
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v4

- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: temurin
cache: maven

- name: Evaluate coverage
run: mvn -B verify

- name: Create filtered JaCoCo CSV that contains only GT4500 results
run: >
> jacoco-gt4500.csv awk
'NR==1{print;next}/GT4500/{print}'
target/site/jacoco/jacoco.csv
- name: Generate JaCoCo badges
id: jacoco
uses: cicirello/jacoco-badge-generator@v2
with:
jacoco-csv-file: jacoco-gt4500.csv
generate-coverage-badge: false
generate-branches-badge: false
workflow-summary-heading: JaCoCo Test Coverage Summary (GT4500)

- name: Log coverage metrics
run: |
echo "GT4500 instruction coverage = ${{ steps.jacoco.outputs.coverage }}"
echo "GT4500 branch coverage = ${{ steps.jacoco.outputs.branches }}"
- name: Add PR comment with coverage metrics
uses: mshick/add-pr-comment@v2
with:
message: |
### JaCoCo Coverage Report (GT4500)
| Coverage Metric | Value | Threshold (Minimum) | |
| --- | --- | --- | --- |
| 👉 Instruction Coverage | ${{ steps.jacoco.outputs.coverage }} | ${{ env.COVERAGE_THRESHOLD }} | ${{ steps.jacoco.outputs.coverage < env.COVERAGE_THRESHOLD && '❌' || '✅' }} |
| 🌳 Decision/Branch Coverage | ${{ steps.jacoco.outputs.branches }} | ${{ env.COVERAGE_THRESHOLD }} | ${{ steps.jacoco.outputs.branches < env.COVERAGE_THRESHOLD && '❌' || '✅' }} |
allow-repeats: true

- name: Upload coverage report
uses: actions/upload-artifact@v4
with:
name: jacoco-report
path: target/site/jacoco/

- name: Fail job unless requirements are met
if: ${{ steps.jacoco.outputs.coverage < env.COVERAGE_THRESHOLD || steps.jacoco.outputs.branches < env.COVERAGE_THRESHOLD }}
uses: actions/github-script@v7
with:
script: core.setFailed('Coverage metrics do not meet requirements')

23 changes: 23 additions & 0 deletions .github/workflows/maven.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
---
name: Java CI with Maven

on:
push:
branches: [main]
pull_request:
branches: [main]

jobs:
build:
name: Build with Maven
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: temurin
cache: maven
- name: Build with Maven
run: mvn -B package --file pom.xml
24 changes: 24 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
*.class

# Mobile Tools for Java (J2ME)
.mtj.tmp/

# Package Files #
*.jar
*.war
*.ear

# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*

# ignore target from Maven
target/

# IntelliJ folder
.idea/

# Visual Studio Code files
*.classpath
*.project
.settings/
.vscode/
18 changes: 18 additions & 0 deletions .mvn/wrapper/maven-wrapper.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.3/apache-maven-3.9.3-bin.zip
wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.2.0/maven-wrapper-3.2.0.jar
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2017 Budapest University of Technology and Economics

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
40 changes: 40 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# SE Spaceship

This is a sample application for the [Software Engineering](http://www.mit.bme.hu/oktatas/targyak/vimiab04) course at BME MIT.

The application is simplified and deliberately contains bugs.

## Getting started

- The project is implemented in Java 11.
- The project can be built using [Maven](https://maven.apache.org/).
- [JUnit](https://junit.org/junit5/) is used for tests, and [Mockito](https://site.mockito.org/) for isolating dependencies.

Clone the repository and execute Maven to build the application:

```
mvn compile
```

To compile and run tests also execute:

```
mvn test
```

(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.)

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/).

## Overview

The project represents an alpha version of a spaceship.

- The ship (`SpaceShip` interface) can fire one or more lasers or torpedos.
- We have only one spaceship as of now (`GT4500`).
- Currently two firing modes (`FiringMode`) are supported: firing only one or all instances of a given weapon type.
- Lasers are not yet implemented, but the code for torpedo stores are ready (`TorpedoStore`).
- For the GT4500 ship the rules for firing torpedoes can be found in the Javadoc comment of method `fireTorpedos`. They are already partially implemented.
- 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.

The code can be built, but due to missing features one of the tests fails. The first exercise will be to fix this.
Loading

0 comments on commit f6c305c

Please sign in to comment.