Skip to content

Commit f23ec89

Browse files
authored
Merge pull request #1440 from Adyen/improve-github-workflow
Improve Github workflows
2 parents f5603d1 + 68cf066 commit f23ec89

File tree

2 files changed

+57
-16
lines changed

2 files changed

+57
-16
lines changed

.github/workflows/javaci.yml

Lines changed: 49 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,63 @@
11
name: Java CI
22

3-
on: [push]
3+
on:
4+
push:
5+
branches:
6+
- main
7+
- sdk-automation/models
8+
- promote/main
9+
pull_request:
10+
branches:
11+
- main
12+
- sdk-automation/models
13+
- promote/main
14+
workflow_dispatch: {}
15+
16+
permissions:
17+
contents: read
418

519
jobs:
6-
build:
20+
java-check:
21+
runs-on: ubuntu-latest
22+
23+
steps:
24+
- uses: actions/checkout@v4
25+
- name: Set up JDK
26+
uses: actions/setup-java@v4
27+
with:
28+
java-version: '20'
29+
distribution: 'adopt'
30+
- name: Cache Maven packages
31+
uses: actions/cache@v3
32+
with:
33+
path: ~/.m2
34+
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
35+
restore-keys: |
36+
${{ runner.os }}-m2-
37+
- name: Check code style
38+
run: mvn -B checkstyle:check --no-transfer-progress
39+
40+
java-test:
741
runs-on: ubuntu-latest
42+
needs: java-check
43+
844
strategy:
945
matrix:
1046
java: [ '11', '17', '20' ]
47+
1148
steps:
1249
- uses: actions/checkout@v4
13-
- name: Set up JDK ${{ matrix.Java }}
50+
- name: Set up JDK ${{ matrix.java }}
1451
uses: actions/setup-java@v4
15-
1652
with:
1753
java-version: ${{ matrix.java }}
1854
distribution: 'adopt'
19-
20-
- name: Run the tests with Maven
21-
run: mvn -B clean test package --no-transfer-progress
55+
- name: Cache Maven packages
56+
uses: actions/cache@v3
57+
with:
58+
path: ~/.m2
59+
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
60+
restore-keys: |
61+
${{ runner.os }}-m2-
62+
- name: Run tests with coverage
63+
run: mvn -B clean test package --no-transfer-progress

.github/workflows/sonarcloud.yml

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
11
name: Sonarcloud CI
22

33
on:
4-
push:
5-
branches:
6-
- main
7-
pull_request:
8-
types: [ opened, synchronize, reopened ]
4+
schedule:
5+
- cron: '0 0 * * 4'
6+
workflow_dispatch: {}
7+
8+
permissions:
9+
contents: read
10+
pull-requests: read
911

1012
jobs:
11-
SonarCloud-Build:
12-
name: SonarCloud Build
13+
java-sonarqube:
1314
runs-on: ubuntu-latest
1415
steps:
1516
- uses: actions/checkout@v4
@@ -40,8 +41,6 @@ jobs:
4041
run: mvn test jacoco:report
4142

4243
- name: Run SonarCloud Analysis
43-
if: ${{ github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository }}
4444
env:
45-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
4645
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
4746
run: mvn sonar:sonar -Dsonar.projectKey=Adyen_adyen-java-api-library

0 commit comments

Comments
 (0)