Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: CI

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

jobs:
build:
name: build and test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-java@v4
with:
distribution: temurin
java-version: "17"
cache: maven
# EnergyServiceIntegrationTest calls the live NESO Carbon Intensity API.
# It is a useful thing to run by hand and a bad thing to gate a merge on:
# an outage upstream would fail a build that has nothing wrong with it.
# `mvn test` locally still runs everything.
- run: ./mvnw -B --no-transfer-progress verify -DexcludedGroups=integration
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) 2026 Jakub Kierznowski

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.
24 changes: 17 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@
EV charging decision backend that analyzes UK grid carbon-intensity data and recommends the cleanest charging window in the next 48 hours.
</p>

<p align="center">
<a href="https://github.com/qualv13/CarCharging/actions/workflows/ci.yml"><img src="https://github.com/qualv13/CarCharging/actions/workflows/ci.yml/badge.svg" alt="CI"></a>
</p>

<p align="center">
<a href="https://github.com/qualv13/CarCharging"><img src="https://img.shields.io/badge/GitHub-CarCharging-181717?style=for-the-badge&logo=github" alt="GitHub"></a>
<img src="https://img.shields.io/badge/Java-17-ED8B00?style=for-the-badge&logo=openjdk&logoColor=white" alt="Java 17">
Expand Down Expand Up @@ -329,18 +333,24 @@ This simplicity is a strength for a focused API utility service.

## Testing

The Maven configuration includes Spring Boot test support.
18 tests, run on every push by [CI](.github/workflows/ci.yml).

Run tests with:
| Class | Covers | Tests |
| --- | --- | --- |
| `ChargingServiceTest` | the sliding window over half-hourly slots, including ties and short horizons | 10 |
| `EnergyServiceTest` | daily mix aggregation with a mocked client | 6 |
| `CarChargingApplicationTests` | the Spring context loads | 1 |
| `EnergyServiceIntegrationTest` | the real NESO API, end to end | 1 |

```bash
mvn test
mvn test # everything
mvn test -DexcludedGroups=integration # what CI runs
```

The repository structure also indicates service-level tests such as:
- `ChargingServiceTest`
- `EnergyServiceTest`
- `EnergyServiceIntegrationTest`
The last one is tagged `integration` and left out of CI on purpose. It calls
the live NESO Carbon Intensity API, so an outage upstream would fail a build
that has nothing wrong with it. Worth running by hand when the client or the
response shape changes.

---

Expand Down
Empty file modified mvnw
100644 → 100755
Empty file.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.qualv13.carcharging.service;

import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Tag;
import org.junit.jupiter.api.Test;
import org.qualv13.carcharging.client.CarbonIntensityClient;
import org.qualv13.carcharging.model.dto.ChargingWindowDto;
Expand All @@ -9,6 +10,10 @@

import java.util.List;

// Talks to the live NESO Carbon Intensity API, so it is excluded from CI:
// an outage upstream would fail a build that has nothing wrong with it.
// `mvn test` runs it; `mvn test -DexcludedGroups=integration` does not.
@Tag("integration")
class EnergyServiceIntegrationTest {

@Test
Expand Down
Loading