-
-
Notifications
You must be signed in to change notification settings - Fork 298
186 lines (154 loc) · 5.91 KB
/
codeql-analysis.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
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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
# For most projects, this workflow file will not need changing; you simply need
# to commit it to your repository.
#
# You may wish to alter this file to override the set of languages analyzed,
# or to provide custom queries or build logic.
name: "CodeQL"
on:
push:
branches: [master, release-7.1]
pull_request:
# The branches below must be a subset of the branches above
branches: [master]
schedule:
- cron: '0 7 * * 4'
env:
java: 17
# use temurin because of this one https://github.com/actions/setup-java/blob/main/docs/advanced-usage.md#Hosted-Tool-Cache
java_distribution: 'temurin'
# to build cache key for maven per branch
branch_name: ${{ github.ref_name }}
jobs:
analyze_java_sonar:
if: github.event_name != 'pull_request'
name: Analyze java by sonar
runs-on: ubuntu-latest
strategy:
fail-fast: false
steps:
# Install Java
- name: Setup Java
uses: actions/setup-java@v4
with:
java-version: '${{ env.java }}'
distribution: ${{ env.java_distribution }}
check-latest: true
# setup maven to 3.9 for tycho
- name: Set up Maven
uses: stCarolas/setup-maven@v5
with:
maven-version: 3.9.6
# on case PR it check out to commit is merger of PR to base (master)
- name: Checkout repository
uses: actions/checkout@v4
with:
# fetch all commit so sornar can know who change a line, it's resolved Warning: Shallow clone detected, no blame information will be provided. You can convert to non-shallow with 'git fetch --unshallow'.
fetch-depth: 0
# restore sonar cache
- name: Cache sonar material restore
id: cache-sonar-material-restore
uses: actions/cache/restore@v4
with:
path: |
~/.sonar/cache
key: ${{ runner.os }}-sonar-${{ env.branch_name }}
# restore maven cache
- name: Cache maven material restore
id: cache-maven-material-restore
uses: actions/cache/restore@v4
with:
path: |
~/.m2/repository
key: ${{ runner.os }}-maven-${{ env.branch_name }}-repository
# run sonar on master only because sonar for PR come from other repository isn't support at moment (already on develop)
# https://stackoverflow.com/a/39720346
# https://docs.sonarqube.org/latest/analysis/pr-decoration/
- name: Build and sonar analyze
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
run: |
export MAVEN_OPTS="-Xmx7G -Dorg.slf4j.simpleLogger.defaultLogLevel=warn"
sonarProject="-Dsonar.projectKey=${{ github.repository_owner }}_idempiere -Dsonar.organization=${{ github.repository_owner }}"
sonar="-Dsonar.java.source=$java -Dsonar.java.target=$java -Dsonar.host.url=https://sonarcloud.io -Dsonar.log.level=WARN"
sonarExclusions="-Dsonar.exclusions=**/I_*.java,**/X_*.java"
codeql="-Dfindbugs.skip -Dcheckstyle.skip -Dpmd.skip=true -Denforcer.skip -Dmaven.javadoc.skip -DskipTests -Dmaven.test.skip.exec -Dlicense.skip=true -Drat.skip=true"
mvn -B -V -e $codeql $sonar $sonarProject $sonarExclusions package org.sonarsource.scanner.maven:sonar-maven-plugin:sonar
# save sonar cache
- name: Cache sonar material save
uses: actions/cache/save@v4
with:
path: |
~/.sonar/cache
key: ${{ steps.cache-sonar-material-restore.outputs.cache-primary-key }}
# save maven cache
- name: Cache maven material save
uses: actions/cache/save@v4
with:
path: |
~/.m2/repository
key: ${{ steps.cache-maven-material-restore.outputs.cache-primary-key }}-repository
analyze_java_codeQL:
name: Analyze java by code QL
runs-on: ubuntu-latest
strategy:
fail-fast: false
steps:
# Install Java
- name: Setup Java
uses: actions/setup-java@v4
with:
java-version: '${{ env.java }}'
distribution: ${{ env.java_distribution }}
check-latest: true
# setup maven to 3.9 for tycho
- name: Set up Maven
uses: stCarolas/setup-maven@v5
with:
maven-version: 3.9.6
# on case PR it check out to commit is merger of PR to base (master)
- name: Checkout repository
uses: actions/checkout@v4
# restore maven cache
- name: Cache maven material restore
id: cache-maven-material-restore
uses: actions/cache/restore@v4
with:
path: |
~/.m2/repository
key: ${{ runner.os }}-maven-${{ env.branch_name }}-repository
# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v3
with:
languages: java
# If you wish to specify custom queries, you can do so here or in a config file.
# By default, queries listed here will override any specified in a config file.
# Prefix the list here with "+" to use these queries and those in the config file.
# queries: ./path/to/local/query, your-org/your-repo/queries@main
- name: Autobuild
uses: github/codeql-action/autobuild@v3
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v3
# save maven cache
- name: Cache maven material save
uses: actions/cache/save@v4
with:
path: |
~/.m2/repository
key: ${{ steps.cache-maven-material-restore.outputs.cache-primary-key }}-repository
analyze_javascript_codeQL:
name: Analyze javascript by code QL
runs-on: ubuntu-latest
strategy:
fail-fast: false
steps:
# on case PR it check out to commit is merger of PR to base (master)
- name: Checkout repository
uses: actions/checkout@v4
- name: Initialize CodeQL
uses: github/codeql-action/init@v3
with:
languages: javascript
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v3