Skip to content

Commit 7c1e933

Browse files
committed
Separate Github Actions into jobs
Created separate jobs for the different parts of the CI pipeline to make it easier to view in Github
1 parent e0c6477 commit 7c1e933

File tree

1 file changed

+39
-12
lines changed

1 file changed

+39
-12
lines changed

.github/workflows/build.yml

Lines changed: 39 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,53 +6,76 @@ on:
66
pull_request:
77
branches: [ master ]
88

9-
jobs:
10-
build-and-test:
11-
runs-on: ubuntu-22.04
9+
defaults:
10+
run:
11+
shell: bash
12+
13+
env:
14+
JAVA_VERSION: '17'
15+
UBUNTU_VERSION: 'ubuntu-22.04'
1216

17+
jobs:
18+
build:
19+
runs-on: ${{ env.UBUNTU_VERSION }}
1320
steps:
1421
- uses: actions/checkout@v3
15-
with:
16-
fetch-depth: 0 # Required for Code Climate
1722

1823
- name: Set up JDK
1924
uses: actions/setup-java@v3
2025
with:
21-
java-version: '17'
26+
java-version: ${{ env.JAVA_VERSION }}
2227
distribution: 'adopt'
2328
cache: maven
2429

2530
- name: Build with Maven
2631
run: mvn clean install
2732

28-
# Upload build artifacts
2933
- name: Upload build artifacts
3034
if: always()
3135
uses: actions/upload-artifact@v4
3236
with:
3337
name: build-artifacts
3438
path: target/*.jar
3539

40+
test:
41+
needs: build
42+
runs-on: ${{ env.UBUNTU_VERSION }}
43+
steps:
44+
- uses: actions/checkout@v3
45+
46+
- name: Set up JDK
47+
uses: actions/setup-java@v3
48+
with:
49+
java-version: ${{ env.JAVA_VERSION }}
50+
distribution: 'adopt'
51+
cache: maven
52+
3653
- name: Run Tests
3754
run: mvn test
3855

39-
# Upload Surefire test results
4056
- name: Upload Surefire test results
4157
if: always()
4258
uses: actions/upload-artifact@v4
4359
with:
4460
name: surefire-reports
4561
path: target/surefire-reports/
4662

47-
# Upload JaCoCo reports
4863
- name: Upload JaCoCo reports
4964
if: always()
5065
uses: actions/upload-artifact@v4
5166
with:
5267
name: jacoco-reports
5368
path: target/site/jacoco/
5469

55-
# Code Climate Setup and Analysis
70+
71+
code-scan:
72+
needs: build
73+
runs-on: u${{ env.UBUNTU_VERSION }}
74+
steps:
75+
- uses: actions/checkout@v3
76+
with:
77+
fetch-depth: 0
78+
5679
- name: Setup Code Climate
5780
run: |
5881
curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
@@ -66,11 +89,15 @@ jobs:
6689
JACOCO_SOURCE_PATH=src/main/java ./cc-test-reporter format-coverage target/site/jacoco/jacoco.xml --input-type jacoco
6790
./cc-test-reporter upload-coverage
6891
69-
# Install Snyk CLI
92+
security-scan:
93+
needs: build
94+
runs-on: ${{ env.UBUNTU_VERSION }}
95+
steps:
96+
- uses: actions/checkout@v3
97+
7098
- name: Install Snyk CLI
7199
run: npm install -g snyk
72100

73-
# Run Snyk to check for vulnerabilities
74101
- name: Run Snyk to check for vulnerabilities
75102
continue-on-error: true
76103
env:

0 commit comments

Comments
 (0)