Skip to content

Commit afd8771

Browse files
feat(ci): add java 17/21/25 matrix and microservice smoke tests
1 parent 4a2b890 commit afd8771

7 files changed

Lines changed: 124 additions & 0 deletions

File tree

.github/workflows/ci.yml

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
9+
jobs:
10+
test:
11+
name: Test (Java ${{ matrix.java }} / ${{ matrix.os }})
12+
runs-on: ${{ matrix.os }}
13+
strategy:
14+
fail-fast: false
15+
matrix:
16+
os: [ubuntu-latest, windows-latest]
17+
java: [17, 21, 25]
18+
steps:
19+
- name: Checkout
20+
uses: actions/checkout@v4
21+
22+
- name: Setup Java
23+
uses: actions/setup-java@v4
24+
with:
25+
distribution: temurin
26+
java-version: ${{ matrix.java }}
27+
cache: maven
28+
29+
- name: Run tests
30+
run: mvn -B -ntp clean test
31+
32+
release-readiness:
33+
name: Release Readiness
34+
runs-on: ubuntu-latest
35+
needs: test
36+
steps:
37+
- name: Checkout
38+
uses: actions/checkout@v4
39+
40+
- name: Setup Java
41+
uses: actions/setup-java@v4
42+
with:
43+
distribution: temurin
44+
java-version: 21
45+
cache: maven
46+
47+
- name: Verify central release profile
48+
run: mvn -B -ntp -Pcentral-release -Dgpg.skip=true -DskipTests=true verify
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
package io.github.bpj.smoke;
2+
3+
import io.github.bpj.BPJ;
4+
5+
public final class CheckoutService {
6+
7+
public String buildOrderSummary(Customer customer, Product product, int quantity) {
8+
int subtotal = product.unitPrice() * quantity;
9+
int total = subtotal;
10+
return BPJ.format("Pedido de {customer.name}: {quantity} x {product.name} = {subtotal}. Total {total}");
11+
}
12+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
package io.github.bpj.smoke;
2+
3+
public record Customer(String name) {
4+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
package io.github.bpj.smoke;
2+
3+
public record Product(String name, int unitPrice) {
4+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
package io.github.bpj.smoke;
2+
3+
import io.github.bpj.BPJ;
4+
5+
public final class WelcomeNotifier {
6+
7+
public void printWelcome(Customer customer) {
8+
BPJ.println("Bienvenido {customer.name}");
9+
}
10+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
package io.github.bpj.smoke;
2+
3+
import static org.junit.jupiter.api.Assertions.assertEquals;
4+
5+
import org.junit.jupiter.api.Test;
6+
7+
class CheckoutServiceTest {
8+
9+
@Test
10+
void shouldInterpolateMicroserviceStyleSummaryWithoutManualContext() {
11+
CheckoutService service = new CheckoutService();
12+
Customer customer = new Customer("Orion");
13+
Product product = new Product("Keyboard", 15);
14+
15+
String output = service.buildOrderSummary(customer, product, 3);
16+
17+
assertEquals("Pedido de Orion: 3 x Keyboard = 45. Total 45", output);
18+
}
19+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
package io.github.bpj.smoke;
2+
3+
import static org.junit.jupiter.api.Assertions.assertEquals;
4+
5+
import java.io.ByteArrayOutputStream;
6+
import java.io.PrintStream;
7+
import java.nio.charset.StandardCharsets;
8+
import org.junit.jupiter.api.Test;
9+
10+
class WelcomeNotifierTest {
11+
12+
@Test
13+
void shouldPrintResolvedPlaceholderWithoutManualContext() throws Exception {
14+
WelcomeNotifier notifier = new WelcomeNotifier();
15+
PrintStream originalOut = System.out;
16+
ByteArrayOutputStream out = new ByteArrayOutputStream();
17+
18+
try (PrintStream capture = new PrintStream(out, true, StandardCharsets.UTF_8)) {
19+
System.setOut(capture);
20+
notifier.printWelcome(new Customer("Pablo"));
21+
} finally {
22+
System.setOut(originalOut);
23+
}
24+
25+
assertEquals("Bienvenido Pablo" + System.lineSeparator(), out.toString(StandardCharsets.UTF_8));
26+
}
27+
}

0 commit comments

Comments
 (0)