From 5ef011a13c5fe596e2feca77f3889dd685f806d9 Mon Sep 17 00:00:00 2001 From: qualv13 <71326761+qualv13@users.noreply.github.com> Date: Sun, 23 Aug 2026 12:11:45 +0200 Subject: [PATCH 1/2] Run the tests in CI and tag the one that calls the live API 17 tests have been passing on my machine and nowhere else. They now run on every push against Temurin 17. EnergyServiceIntegrationTest is excluded. It builds a real RestTemplate and calls the NESO Carbon Intensity API, so a bad afternoon upstream would fail a build with nothing wrong in it. Tagged `integration` rather than deleted, because it is the only thing that catches a change in the response shape. `mvn test` still runs it locally. The Testing section said the repository structure "indicates" service-level tests. It now says what each class covers and how many assertions are behind that claim. Adds MIT: without a licence the default is all rights reserved. --- .github/workflows/ci.yml | 23 ++++++++++++++++++ LICENSE | 21 ++++++++++++++++ README.md | 24 +++++++++++++------ .../service/EnergyServiceIntegrationTest.java | 5 ++++ 4 files changed, 66 insertions(+), 7 deletions(-) create mode 100644 .github/workflows/ci.yml create mode 100644 LICENSE diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..d56a28c --- /dev/null +++ b/.github/workflows/ci.yml @@ -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 diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..a66add1 --- /dev/null +++ b/LICENSE @@ -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. diff --git a/README.md b/README.md index 087b534..3a80fa0 100644 --- a/README.md +++ b/README.md @@ -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.
+ +
@@ -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.
---
diff --git a/src/test/java/org/qualv13/carcharging/service/EnergyServiceIntegrationTest.java b/src/test/java/org/qualv13/carcharging/service/EnergyServiceIntegrationTest.java
index ccb523e..1e47d4f 100644
--- a/src/test/java/org/qualv13/carcharging/service/EnergyServiceIntegrationTest.java
+++ b/src/test/java/org/qualv13/carcharging/service/EnergyServiceIntegrationTest.java
@@ -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;
@@ -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
From 6bd0c5d8468fab22512b88811b9ad1ad19259768 Mon Sep 17 00:00:00 2001
From: qualv13 <71326761+qualv13@users.noreply.github.com>
Date: Sun, 23 Aug 2026 12:28:03 +0200
Subject: [PATCH 2/2] Mark mvnw executable
Committed from Windows without the executable bit, so ./mvnw is a permission
error on any Linux or macOS clone, CI included.
---
mvnw | 0
1 file changed, 0 insertions(+), 0 deletions(-)
mode change 100644 => 100755 mvnw
diff --git a/mvnw b/mvnw
old mode 100644
new mode 100755