Skip to content

Commit 8ce788e

Browse files
Refactor Java CI workflow for Maven
Updated Java CI workflow to use matrix for JDK versions and added steps for creating a dummy .env file and running tests.
1 parent ce25058 commit 8ce788e

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

.github/workflows/main.yml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
name: Java CI with Maven
2+
3+
on:
4+
push:
5+
branches: [ "main" ]
6+
pull_request:
7+
branches: [ "main" ]
8+
9+
jobs:
10+
build_and_test:
11+
name: Build & Test (Java ${{ matrix.version }})
12+
runs-on: ubuntu-latest
13+
strategy:
14+
matrix:
15+
version: ["23", "24"]
16+
17+
steps:
18+
- uses: actions/checkout@v4
19+
20+
- name: Set up JDK ${{ matrix.version }}
21+
uses: actions/setup-java@v4
22+
with:
23+
java-version: ${{ matrix.version }} # Här använder vi matrisen korrekt!
24+
distribution: 'temurin'
25+
cache: maven
26+
27+
# VIKTIGT: Eftersom din LogConfig läser .env, måste vi skapa en tillfällig sådan för testerna
28+
- name: Create dummy .env for CI
29+
run: echo "DATABASE_URL=jdbc:sqlite:test.db" > .env
30+
31+
- name: Build and Run Tests
32+
run: mvn -B clean verify # verify kör även coverage-plugins om de finns i din pom.xml
33+
34+
formatting:
35+
runs-on: ubuntu-latest
36+
steps:
37+
- uses: actions/checkout@v4
38+
- uses: axel-op/googlejavaformat-action@v4
39+
with:
40+
args: "--set-exit-if-changed"

0 commit comments

Comments
 (0)