Skip to content

Commit 6a820f2

Browse files
committed
ci: add GitHub Actions workflow and JUnit 5 config
1 parent 5843c14 commit 6a820f2

4 files changed

Lines changed: 52 additions & 1 deletion

File tree

.github/workflows/maven.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: Java CI with Maven
2+
3+
on:
4+
push:
5+
branches: [ master ]
6+
pull_request:
7+
branches: [ master ]
8+
9+
jobs:
10+
build:
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- name: Checkout repo
15+
uses: actions/checkout@v4
16+
17+
- name: Set up JDK 17
18+
uses: actions/setup-java@v4
19+
with:
20+
java-version: '17'
21+
distribution: 'temurin'
22+
cache: maven
23+
24+
- name: Build with Maven
25+
run: mvn -B -V -DskipTests=false verify
26+
27+
- name: Upload test results
28+
if: always()
29+
uses: actions/upload-artifact@v4
30+
with:
31+
name: test-results
32+
path: target/surefire-reports || target/failsafe-reports || target

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,11 @@ The repository contains a simple Java application which outputs the string
99
main application works as expected. The results of these tests are saved to a
1010
JUnit XML report.
1111

12+
## Continuous Integration
13+
14+
This repository includes a GitHub Actions workflow at `.github/workflows/maven.yml` that runs on push and pull requests to `master`.
15+
It uses JDK 17 and runs `mvn -B verify`, publishing test artifacts.
16+
1217
The `jenkins` directory contains an example of the `Jenkinsfile` (i.e. Pipeline)
1318
you'll be creating yourself during the tutorial and the `jenkins/scripts` subdirectory
1419
contains a shell script with commands that are executed when Jenkins processes

pom.xml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,12 @@
1414
<version>5.11.0</version>
1515
<scope>test</scope>
1616
</dependency>
17+
<dependency>
18+
<groupId>org.junit.jupiter</groupId>
19+
<artifactId>junit-jupiter-engine</artifactId>
20+
<version>5.11.0</version>
21+
<scope>test</scope>
22+
</dependency>
1723
</dependencies>
1824
<properties>
1925
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
@@ -32,6 +38,14 @@
3238
</plugins>
3339
</pluginManagement>
3440
<plugins>
41+
<plugin>
42+
<groupId>org.apache.maven.plugins</groupId>
43+
<artifactId>maven-surefire-plugin</artifactId>
44+
<version>3.0.0-M9</version>
45+
<configuration>
46+
<useModulePath>false</useModulePath>
47+
</configuration>
48+
</plugin>
3549
<plugin>
3650
<!-- Build an executable JAR -->
3751
<groupId>org.apache.maven.plugins</groupId>

src/main/java/com/mycompany/app/App.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
*/
66
public class App {
77

8-
private static final String MESSAGE = "Hello World!";
8+
private static final String MESSAGE = "Hello World from Github Actions!";
99

1010
public App() {}
1111

0 commit comments

Comments
 (0)