Skip to content

Commit ea40811

Browse files
authored
Update codeql-analysis.yml for Gradle
1 parent 90c4a86 commit ea40811

File tree

1 file changed

+94
-24
lines changed

1 file changed

+94
-24
lines changed

.github/workflows/codeql-analysis.yml

Lines changed: 94 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -8,30 +8,100 @@ on:
88
schedule:
99
- cron: '34 10 * * 4'
1010

11+
permissions: {}
12+
1113
jobs:
12-
analyse:
13-
name: Analyse
14+
CodeQL-Build:
15+
permissions:
16+
actions: read # for github/codeql-action/init to get workflow details
17+
contents: read # for actions/checkout to fetch code
18+
security-events: write # for github/codeql-action/analyze to upload SARIF results
1419
runs-on: ubuntu-latest
15-
if: "!contains(github.event.head_commit.message, '[ci skip]') && !contains(github.event.head_commit.message, '[skip ci]')"
20+
21+
strategy:
22+
fail-fast: false
23+
matrix:
24+
# Override automatic language detection by changing the below list
25+
# Supported options are ['csharp', 'cpp', 'go', 'java', 'javascript', 'python']
26+
language: ['java', 'javascript']
27+
# Learn more...
28+
# https://docs.github.com/en/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#overriding-automatic-language-detection
29+
1630
steps:
17-
- uses: actions/checkout@v4
18-
with:
19-
fetch-depth: 2
20-
- uses: actions/setup-java@v4
21-
with:
22-
distribution: 'temurin'
23-
java-version: '17'
24-
- uses: actions/cache@v4
25-
with:
26-
path: ~/.m2/repository
27-
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
28-
restore-keys: |
29-
${{ runner.os }}-maven-
30-
- name: Initialize CodeQL
31-
uses: github/codeql-action/init@v3
32-
with:
33-
languages: java
34-
- name: Build
35-
run: mvn -B compile
36-
- name: Perform CodeQL Analysis
37-
uses: github/codeql-action/analyze@v3
31+
- name: Checkout repository
32+
uses: actions/checkout@v4
33+
# Checkout must run before the caching key is computed using the `hashFiles` method
34+
35+
- name: Cache Gradle Modules
36+
uses: actions/cache@v4
37+
with:
38+
path: |
39+
~/.gradle/caches/modules-2/
40+
~/.gradle/caches/build-cache-1/
41+
~/.gradle/caches/signatures/
42+
~/.gradle/caches/keyrings/
43+
key: ${{ runner.os }}-gradle-cache-${{ hashFiles('gradle/wrapper/gradle-wrapper.properties') }}
44+
if: ${{ matrix.language == 'java' }}
45+
46+
- name: Disable checksum offloading
47+
# See: https://github.com/actions/virtual-environments/issues/1187#issuecomment-686735760
48+
run: sudo ethtool -K eth0 tx off rx off
49+
50+
# Install and setup JDK 17
51+
- name: Setup JDK 17
52+
uses: actions/setup-java@v4
53+
with:
54+
distribution: temurin
55+
java-version: 17
56+
57+
# Initializes the CodeQL tools for scanning.
58+
- name: Initialize CodeQL
59+
uses: github/codeql-action/init@v3
60+
with:
61+
languages: ${{ matrix.language }}
62+
tools: latest
63+
# If you wish to specify custom queries, you can do so here or in a config file.
64+
# By default, queries listed here will override any specified in a config file.
65+
# Prefix the list here with "+" to use these queries and those in the config file.
66+
# queries: ./path/to/local/query, your-org/your-repo/queries@main
67+
68+
- name: Compile with Gradle with Build Scan
69+
if: ${{ matrix.language == 'java' && github.repository_owner == 'gradle' }}
70+
run: ./gradlew --init-script .github/workflows/codeql-analysis.init.gradle -DcacheNode=us -S testClasses -Dhttp.keepAlive=false
71+
env:
72+
# Set the DEVELOCITY_ACCESS_KEY so that Gradle Build Scans are generated
73+
DEVELOCITY_ACCESS_KEY: ${{ secrets.DEVELOCITY_ACCESS_KEY }}
74+
# Potential stop-gap solution for ReadTimeout issues with the Gradle Build Cache
75+
# https://gradle.slack.com/archives/CHDLT99C6/p1636477584059200
76+
GRADLE_OPTS: -Dhttp.keepAlive=false
77+
78+
- name: Compile with Gradle without Build Scan
79+
if: ${{ matrix.language == 'java' && github.repository_owner != 'gradle' }}
80+
run: ./gradlew --init-script .github/workflows/codeql-analysis.init.gradle -S testClasses
81+
82+
- name: Cleanup Gradle Daemons
83+
run: ./gradlew --stop
84+
if: ${{ matrix.language == 'java' }}
85+
86+
# ℹ️ Command-line programs to run using the OS shell.
87+
# 📚 https://git.io/JvXDl
88+
89+
# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
90+
# and modify them (or add more) to build your code if your project
91+
# uses a compiled language
92+
93+
#- run: |
94+
# make bootstrap
95+
# make release
96+
97+
- name: Perform CodeQL Analysis
98+
uses: github/codeql-action/analyze@v3
99+
with:
100+
config-file: ./.github/codeql/codeql-config.yml
101+
102+
- name: Cleanup Gradle Cache
103+
# Cleans up the Gradle caches before being cached
104+
run: |
105+
rm -f ~/.gradle/caches/modules-2/modules-2.lock
106+
rm -f ~/.gradle/caches/modules-2/gc.properties
107+
if: ${{ matrix.language == 'java' }}

0 commit comments

Comments
 (0)