This repository has been archived by the owner on Jan 21, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
140 lines (135 loc) · 4.44 KB
/
test.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
name: Test
on:
push:
branches:
- main
- develop
- 'release/**'
- 'hotfix/**'
pull_request:
paths:
- 'go-sdk/**/*'
- 'py-sdk/**/*'
- '.github/workflows/test.yaml'
branches:
# Destination branches
- 'develop'
jobs:
check-folder-changes:
runs-on: ubuntu-latest
name: Check folder changes
outputs:
go-sdk: ${{ steps.filter.outputs.go-sdk }}
py-sdk: ${{ steps.filter.outputs.py-sdk }}
steps:
- name: Checkout
uses: actions/checkout@v4
- uses: dorny/paths-filter@v2
id: filter
with:
filters: |
go-sdk:
- 'go-sdk/**/*'
- '.github/workflows/test.yaml'
py-sdk:
- 'py-sdk/**/*'
- '.github/workflows/test.yaml'
unit-tests:
runs-on: ubuntu-latest
name: Linting and Unit tests
needs: check-folder-changes
strategy:
fail-fast: true
matrix:
include:
- component: go-sdk
changes: ${{ needs.check-folder-changes.outputs.go-sdk }}
- component: py-sdk
changes: ${{ needs.check-folder-changes.outputs.py-sdk }}
steps:
- name: Checkout code
if: matrix.changes == 'true'
uses: actions/checkout@v4
- name: Install Go
if: matrix.changes == 'true' && matrix.component == 'go-sdk'
uses: actions/setup-go@v4
with:
go-version: 1.20.x
- name: Run linters Go
if: matrix.changes == 'true' && matrix.component == 'go-sdk'
uses: golangci/golangci-lint-action@v3
with:
version: latest
working-directory: ./${{ matrix.component }}
args: --timeout=5m
- name: Install Python
if: matrix.changes == 'true' && matrix.component == 'py-sdk'
uses: actions/setup-python@v4
with:
python-version: 3.11.5
- name: Install poetry and dependencies
if: matrix.changes == 'true' && matrix.component == 'py-sdk'
run: |
python -m pip install poetry=="1.5.1"
python -m poetry install --with dev
working-directory: ./${{ matrix.component }}
# - name: Run mypy
# if: matrix.changes == 'true' && matrix.component == 'py-sdk'
# run: make mypy
# working-directory: ./
- name: Run unit tests Go
if: matrix.changes == 'true' && matrix.component == 'go-sdk'
run: make gotest
working-directory: .
- name: Run unit tests Python
if: matrix.changes == 'true' && matrix.component == 'py-sdk'
run: make pytest
working-directory: ./
- name: Run integration tests
if: matrix.changes == 'true' && matrix.component == 'go-sdk'
run: go test ./... -cover -v -coverpkg=./... -coverprofile=coverage-integration.out --tags=integration
working-directory: ./${{ matrix.component }}
- name: Archive code coverage results
if: matrix.changes == 'true'
uses: actions/upload-artifact@v3
with:
name: coverage-report-${{ matrix.component }}
path: |
${{ matrix.component }}/coverage-unit.out
${{ matrix.component }}/coverage-integration.out
sonarcloud:
name: SonarCloud
runs-on: ubuntu-latest
needs:
- check-folder-changes
- unit-tests
strategy:
fail-fast: false
matrix:
include:
- component: go-sdk
changes: ${{ needs.check-folder-changes.outputs.go-sdk }}
sonar_token_secret: SONAR_TOKEN_GO_SDK
- component: py-sdk
changes: ${{ needs.check-folder-changes.outputs.py-sdk }}
sonar_token_secret: SONAR_TOKEN_PYTHON_SDK
steps:
- uses: actions/checkout@v4
if: matrix.changes == 'true'
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
- name: Download code coverage results
if: matrix.changes == 'true'
uses: actions/download-artifact@v3
with:
name: coverage-report-${{ matrix.component }}
path: |
${{ matrix.component }}
- name: SonarCloud Scan
if: matrix.changes == 'true'
uses: SonarSource/sonarcloud-github-action@master
with:
projectBaseDir: ${{ matrix.component }}
env:
GITHUB_TOKEN: ${{ secrets.PAT }} # Needed to get PR information, if any
SONAR_TOKEN: ${{ secrets[matrix.sonar_token_secret] }}