2020-10-01 19:27:15 +07:00
# 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'
2020-10-01 20:21:47 +07:00
env :
2023-07-01 15:37:24 +07:00
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 }}
2020-10-01 20:21:47 +07:00
2020-10-01 19:27:15 +07:00
jobs :
2020-12-06 22:50:14 +07:00
analyze_java_sonar :
if : github.event_name != 'pull_request'
name : Analyze java by sonar
2020-10-01 19:27:15 +07:00
runs-on : ubuntu-latest
strategy :
fail-fast : false
steps :
2020-10-01 20:21:47 +07:00
2023-07-01 15:37:24 +07:00
# Install Java
2020-10-01 20:21:47 +07:00
- name : Setup Java
2023-07-01 15:37:24 +07:00
uses : actions/setup-java@v3
2020-10-01 20:21:47 +07:00
with :
java-version : '${{ env.java }}'
2023-07-01 15:37:24 +07:00
distribution : ${{ env.java_distribution }}
2020-10-01 20:21:47 +07:00
2020-12-05 22:33:26 +07:00
# on case PR it check out to commit is merger of PR to base (master)
2020-10-01 19:27:15 +07:00
- name : Checkout repository
2023-07-01 15:37:24 +07:00
uses : actions/checkout@v3
2020-10-01 19:27:15 +07:00
with :
2020-11-30 09:37:49 +07:00
# 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
2023-07-01 15:37:24 +07:00
- name : Cache sonar material restore
id : cache-sonar-material-restore
uses : actions/cache/restore@v3
2020-11-30 09:37:49 +07:00
with :
path : |
~/.sonar/cache
2023-07-01 15:37:24 +07:00
key : ${{ runner.os }}-sonar-${{ env.branch_name }}
- name : Cache maven material restore
id : cache-maven-material-restore
uses : actions/cache/restore@v3
with :
path : |
~/.m2
key : ${{ runner.os }}-maven-${{ env.branch_name }}
2020-10-01 19:27:15 +07:00
2020-12-05 22:33:26 +07:00
# 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/
2020-12-01 16:38:48 +07:00
- name : Build and sonar analyze
2020-11-30 09:37:49 +07:00
env :
GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
SONAR_TOKEN : ${{ secrets.SONAR_TOKEN }}
run : |
2020-12-05 22:33:26 +07:00
export MAVEN_OPTS="-Xmx7G -Dorg.slf4j.simpleLogger.defaultLogLevel=warn"
2020-12-06 22:50:14 +07:00
sonarProject="-Dsonar.projectKey=${{ github.repository_owner }}_idempiere -Dsonar.organization=${{ github.repository_owner }}"
2020-12-01 16:38:48 +07:00
sonar="-Dsonar.java.source=$java -Dsonar.java.target=$java -Dsonar.host.url=https://sonarcloud.io -Dsonar.log.level=WARN"
2020-12-06 22:50:14 +07:00
sonarExclusions="-Dsonar.exclusions=**/I_*.java,**/X_*.java"
2020-12-01 16:38:48 +07:00
codeql="-Dfindbugs.skip -Dcheckstyle.skip -Dpmd.skip=true -Denforcer.skip -Dmaven.javadoc.skip -DskipTests -Dmaven.test.skip.exec -Dlicense.skip=true -Drat.skip=true"
2020-12-06 22:50:14 +07:00
mvn -B -V -e $codeql $sonar $sonarProject $sonarExclusions package org.sonarsource.scanner.maven:sonar-maven-plugin:sonar
2023-07-01 15:37:24 +07:00
- name : Cache sonar material save
uses : actions/cache/save@v3
with :
path : |
~/.sonar/cache
key : ${{ steps.cache-sonar-material-restore.outputs.cache-primary-key }}
- name : Cache maven material save
uses : actions/cache/save@v3
with :
path : |
~/.m2
key : ${{ steps.cache-maven-material-restore.outputs.cache-primary-key }}
2020-12-06 22:50:14 +07:00
analyze_java_codeQL :
name : Analyze java by code QL
runs-on : ubuntu-latest
strategy :
fail-fast : false
steps :
2023-07-01 15:37:24 +07:00
# Install Java
2020-12-06 22:50:14 +07:00
- name : Setup Java
2023-07-01 15:37:24 +07:00
uses : actions/setup-java@v3
2020-12-06 22:50:14 +07:00
with :
java-version : '${{ env.java }}'
2023-07-01 15:37:24 +07:00
distribution : ${{ env.java_distribution }}
2020-12-06 22:50:14 +07:00
# on case PR it check out to commit is merger of PR to base (master)
- name : Checkout repository
2023-07-01 15:37:24 +07:00
uses : actions/checkout@v3
- name : Cache maven material restore
id : cache-maven-material-restore
uses : actions/cache/restore@v3
2020-12-06 22:50:14 +07:00
with :
path : |
~/.m2
2023-07-01 15:37:24 +07:00
key : ${{ runner.os }}-maven-${{ env.branch_name }}
2020-12-06 22:50:14 +07:00
# Initializes the CodeQL tools for scanning.
- name : Initialize CodeQL
2023-07-01 15:37:24 +07:00
uses : github/codeql-action/init@v2
2020-12-06 22:50:14 +07:00
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
2020-12-05 22:33:26 +07:00
- name : Autobuild
2023-07-01 15:37:24 +07:00
uses : github/codeql-action/autobuild@v2
2020-12-06 22:50:14 +07:00
2020-12-01 16:38:48 +07:00
- name : Perform CodeQL Analysis
2023-07-01 15:37:24 +07:00
uses : github/codeql-action/analyze@v2
- name : Cache maven material save
uses : actions/cache/save@v3
with :
path : |
~/.m2
key : ${{ steps.cache-maven-material-restore.outputs.cache-primary-key }}
2020-12-01 16:38:48 +07:00
2020-12-06 22:50:14 +07:00
analyze_javascript_codeQL :
name : Analyze javascript by code QL
2020-12-01 16:38:48 +07:00
runs-on : ubuntu-latest
strategy :
fail-fast : false
steps :
2020-12-05 22:33:26 +07:00
# on case PR it check out to commit is merger of PR to base (master)
2020-12-01 16:38:48 +07:00
- name : Checkout repository
2023-07-01 15:37:24 +07:00
uses : actions/checkout@v3
2020-12-01 16:38:48 +07:00
- name : Initialize CodeQL
2023-07-01 15:37:24 +07:00
uses : github/codeql-action/init@v2
2020-12-01 16:38:48 +07:00
with :
languages : javascript
2020-11-30 09:37:49 +07:00
2020-10-01 19:27:15 +07:00
- name : Perform CodeQL Analysis
2023-07-01 15:37:24 +07:00
uses : github/codeql-action/analyze@v2