Skip to content

Commit e783cea

Browse files
authored
Merge pull request #1126 from Adyen/improve-github-workflow
Improve GitHub CI workflow
2 parents f406b92 + 5dc248a commit e783cea

File tree

2 files changed

+96
-15
lines changed

2 files changed

+96
-15
lines changed

Diff for: .github/workflows/dotnetcore.yml

+46-15
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,63 @@
11
name: .NET Core
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: {}
415

516
jobs:
6-
build:
7-
name: Build and test
8-
17+
build-test:
18+
name: Build and Test
919
runs-on: ${{ matrix.os }}
20+
1021
strategy:
1122
matrix:
1223
os: [ ubuntu-latest, windows-latest ]
24+
dotnet-version: [ '6.0.x' ]
25+
1326
steps:
1427
- uses: actions/checkout@v4
28+
1529
- name: Setup .NET
1630
uses: actions/setup-dotnet@v4
1731
with:
18-
dotnet-version: |
19-
6.0.x
20-
- name: Install tools
21-
run: |
22-
dotnet restore
23-
32+
dotnet-version: ${{ matrix.dotnet-version }}
33+
2434
- name: Build Debug
2535
run: dotnet build -c Debug
26-
27-
- name: Run test suite net6.0
36+
37+
- name: Run unit tests
2838
run: dotnet test --no-build -c Debug -f net6.0 Adyen.Test/Adyen.Test.csproj
2939

30-
- name: Run integration test suite net6.0
31-
run: dotnet test --no-build -c Debug -f net6.0 Adyen.IntegrationTest/Adyen.IntegrationTest.csproj
32-
if: ${{ contains(github.event.pull_request.labels.*.name, 'release') }}
40+
integration-tests:
41+
name: Integration Tests
42+
runs-on: ubuntu-latest
43+
needs: build-test
44+
45+
#Check if event is a pull request and has a release tag and is not from a forked repo
46+
if: |
47+
github.event_name == 'pull_request' &&
48+
contains(github.event.pull_request.labels.*.name, 'release') &&
49+
github.event.pull_request.head.repo.full_name == github.repository
50+
51+
steps:
52+
- uses: actions/checkout@v4
53+
54+
- name: Setup .NET
55+
uses: actions/setup-dotnet@v4
56+
with:
57+
dotnet-version: '6.0.x'
58+
59+
- name: Build Debug
60+
run: dotnet build -c Debug
61+
62+
- name: Run integration tests
63+
run: dotnet test --no-build -c Debug -f net6.0 Adyen.IntegrationTest/Adyen.IntegrationTest.csproj

Diff for: .github/workflows/sonarcloud.yml

+50
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
name: SonarQube Analysis
2+
on:
3+
schedule:
4+
- cron: '0 1 * * 0'
5+
workflow_dispatch: {}
6+
7+
permissions:
8+
contents: read
9+
pull-requests: read
10+
11+
jobs:
12+
build:
13+
name: Build and analyze
14+
runs-on: windows-latest
15+
steps:
16+
- name: Set up JDK 17
17+
uses: actions/setup-java@v4
18+
with:
19+
java-version: 17
20+
distribution: 'zulu'
21+
- uses: actions/checkout@v4
22+
with:
23+
fetch-depth: 0
24+
- name: Cache SonarQube Cloud packages
25+
uses: actions/cache@v4
26+
with:
27+
path: ~\sonar\cache
28+
key: ${{ runner.os }}-sonar
29+
restore-keys: ${{ runner.os }}-sonar
30+
- name: Cache SonarQube Cloud scanner
31+
id: cache-sonar-scanner
32+
uses: actions/cache@v4
33+
with:
34+
path: .\.sonar\scanner
35+
key: ${{ runner.os }}-sonar-scanner
36+
restore-keys: ${{ runner.os }}-sonar-scanner
37+
- name: Install SonarQube Cloud scanner
38+
if: steps.cache-sonar-scanner.outputs.cache-hit != 'true'
39+
shell: powershell
40+
run: |
41+
New-Item -Path .\.sonar\scanner -ItemType Directory
42+
dotnet tool update dotnet-sonarscanner --tool-path .\.sonar\scanner
43+
- name: Build and analyze
44+
env:
45+
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
46+
shell: powershell
47+
run: |
48+
.\.sonar\scanner\dotnet-sonarscanner begin /k:"Adyen_adyen-dotnet-api-library" /o:"adyen" /d:sonar.token="${{ secrets.SONAR_TOKEN }}" /d:sonar.host.url="https://sonarcloud.io"
49+
dotnet build
50+
.\.sonar\scanner\dotnet-sonarscanner end /d:sonar.token="${{ secrets.SONAR_TOKEN }}"

0 commit comments

Comments
 (0)