This repository has been archived by the owner on Jan 15, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
114 lines (106 loc) · 4.35 KB
/
central_code_quality_check.yml
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
# Please do not attempt to edit this flow without the direct consent from the DevOps team. This file is managed centrally.
# Contact @moabu
# Sonar cloud https://sonarcloud.io/organizations/janssenproject/projects
name: Code quality check
on:
push:
branches:
- master
- main
- "!update-pycloud-in-**"
paths-ignore:
- 'docker-jans-**/CHANGELOG.md'
- 'docker-jans-**/version.txt'
- 'jans-pycloudlib/CHANGELOG.md'
- 'jans-pycloudlib/jans/pycloudlib/version.py'
- '**.md'
pull_request:
branches:
- master
- main
- "!update-pycloud-in-**"
paths-ignore:
- 'docker-jans-**/CHANGELOG.md'
- 'docker-jans-**/version.txt'
- 'jans-pycloudlib/CHANGELOG.md'
- 'jans-pycloudlib/jans/pycloudlib/version.py'
- '**.md'
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
env:
JVM_PROJECTS: |
JanssenProject/jans-auth-server
JanssenProject/jans-orm
JanssenProject/jans-config-api
JanssenProject/jans-client-api
JanssenProject/jans-scim
JanssenProject/jans-core
JanssenProject/jans-notify
JanssenProject/jans-fido2
JanssenProject/jans-eleven
NON_JVM_PROJECTS: |
JanssenProject/jans-setup
JanssenProject/jans-cli
JanssenProject/jans-cloud-native
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of sonarqube analysis
- name: Set up JDK 11
# JanssenProject/jans-cli is too similar to JanssenProject/jans-client-api as the contains function is returning it belonging to the JVM_PROJECT
if: contains(env.JVM_PROJECTS, github.repository) && github.repository != 'JanssenProject/jans-cli'
uses: actions/[email protected]
with:
java-version: '11'
distribution: 'adopt'
- name: Cache SonarCloud packages for JVM based project
# JanssenProject/jans-cli is too similar to JanssenProject/jans-client-api as the contains function is returning it belonging to the JVM_PROJECT
if: contains(env.JVM_PROJECTS, github.repository) && github.repository != 'JanssenProject/jans-cli'
uses: actions/[email protected]
with:
path: ~/.sonar/cache
key: ${{ runner.os }}-sonar
restore-keys: ${{ runner.os }}-sonar
- name: Build and analyze JVM based project
# JanssenProject/jans-cli is too similar to JanssenProject/jans-client-api as the contains function is returning it belonging to the JVM_PROJECT
if: contains(env.JVM_PROJECTS, github.repository) && github.repository != 'JanssenProject/jans-cli'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
run: |
case "$GITHUB_REPOSITORY" in
"JanssenProject/jans-auth-server")
;&
"JanssenProject/jans-client-api")
;&
"JanssenProject/jans-scim")
;&
"JanssenProject/jans-eleven")
;&
"JanssenProject/jans-config-api")
echo "Run Sonar analysis without test execution"
mvn -B -DskipTests=true install org.sonarsource.scanner.maven:sonar-maven-plugin:sonar
;;
*)
echo "Run Sonar analysis with test execution"
mvn -B install org.sonarsource.scanner.maven:sonar-maven-plugin:sonar
;;
esac
- name: Convert repo org name to lowercase for non JVM projects
if: contains(env.NON_JVM_PROJECTS, github.repository)
env:
REPO_OWNER: ${{ github.repository_owner }}
run: |
echo "REPO_ORG=${REPO_OWNER,,}" >>${GITHUB_ENV}
- name: SonarCloud Scan for non-JVM project
if: contains(env.NON_JVM_PROJECTS, github.repository)
uses: SonarSource/sonarcloud-github-action@master
with:
args: >
-Dsonar.organization=${{ env.REPO_ORG }}
-Dsonar.projectKey=${{ github.repository_owner }}_${{ github.event.repository.name }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}