-
Notifications
You must be signed in to change notification settings - Fork 24
178 lines (157 loc) · 6.19 KB
/
codeql-analysis.yml
File metadata and controls
178 lines (157 loc) · 6.19 KB
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
# 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.
#
# ******** NOTE ********
# We have attempted to detect the languages in your repository. Please check
# the `language` matrix defined below to confirm you have the correct set of
# supported CodeQL languages.
#
name: "CodeQL"
on:
push:
branches: [ master ]
pull_request:
# The branches below must be a subset of the branches above
branches: [ master ]
schedule:
- cron: '37 1 * * 3'
jobs:
analyze:
name: Analyze
runs-on: ubuntu-latest
env:
POSTGRES_URL: jdbc:postgresql://localhost:5432/movies
services:
postgres:
image: postgres:latest
env:
POSTGRES_USER: sven1
POSTGRES_PASSWORD: sven1
POSTGRES_DB: movies
ports:
- 5432:5432
options: >-
--health-cmd="pg_isready -U sven1 -d movies"
--health-interval=10s
--health-timeout=5s
--health-retries=5
strategy:
fail-fast: false
matrix:
language: [ 'java', 'javascript' ]
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python' ]
# Learn more:
# https://docs.github.com/en/free-pro-team@latest/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#changing-the-languages-that-are-analyzed
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Setup Java JDK
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: 25
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
# - name: Autobuild
# uses: github/codeql-action/autobuild@v3
- name: Build with Maven
if: matrix.language == 'java'
run: |
./mvnw clean install -Ddocker=true
- name: Find fat jar
if: matrix.language == 'java'
id: jar
run: |
JAR_PATH=$(find ./backend/target -type f -name "*SNAPSHOT.jar" | head -n 1)
echo "Found JAR: $JAR_PATH"
echo "jar=$JAR_PATH" >> $GITHUB_OUTPUT
# java -XX:+UseG1GC -XX:MaxGCPauseMillis=50 -XX:+UseStringDeduplication -XX:AOTCacheOutput=app.aot -Dspring.context.exit=onRefresh -Djava.security.egd=file:/dev/./urandom -jar extracted/moviemanager-backend-0.0.1-SNAPSHOT.jar --spring.profiles.active=prod
- name: Unpack fat jar
if: matrix.language == 'java'
id: UNPACK
run: |
java -Djarmode=tools -jar ${{ steps.jar.outputs.jar }} extract --destination extracted
EXTRACTED_PATH=$(find . -type d -name "extracted" | head -n 1)
echo "Found directory: $EXTRACTED_PATH"
echo "extracted=$EXTRACTED_PATH" >> $GITHUB_OUTPUT
- name: find extracted jar
if: matrix.language == 'java'
id: EXTRACT
run: |
EXTRACTED_JAR=$(find "${{ steps.UNPACK.outputs.extracted }}" -type f -name "*.jar" | head -n 1)
EXTRACTED_JAR=${EXTRACTED_JAR#./}
echo "Found extracted JAR: $EXTRACTED_JAR"
echo "extracted=$EXTRACTED_JAR" >> $GITHUB_OUTPUT
- name: Create AOT cache
if: matrix.language == 'java'
id: AOT
env:
JAVA_TOOL_OPTIONS: ""
_JAVA_OPTIONS: ""
JDK_JAVA_OPTIONS: ""
run: |
EXTRACTED_JAR="${{ steps.EXTRACT.outputs.extracted }}"
echo "jar=$EXTRACTED_JAR"
echo "JAVA_TOOL_OPTIONS=$JAVA_TOOL_OPTIONS"
echo "_JAVA_OPTIONS=$_JAVA_OPTIONS"
echo "JDK_JAVA_OPTIONS=$JDK_JAVA_OPTIONS"
JAVA_OPTS="-XX:+UseG1GC -XX:MaxGCPauseMillis=50 -XX:+UseCompressedOops -XX:+UseCompactObjectHeaders -XX:MaxDirectMemorySize=64m -XX:+UseStringDeduplication"
java $JAVA_OPTS \
-XX:+AOTClassLinking \
-XX:AOTCacheOutput=app.aot \
-Xlog:aot \
-Dspring.context.exit=onRefresh \
-Dspring.datasource.url="${{ env.POSTGRES_URL }}" \
-Dspring.profiles.active=prod \
-jar "$EXTRACTED_JAR" || echo "AOT Training finished with exit code $?"
# - name: Login to Docker Hub
# uses: docker/login-action@v3
# with:
# username: ${{ vars.DOCKERHUB_USERNAME }}
# password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Show Jdk version
if: matrix.language == 'java'
id: JDK
run: |
JDK_VERSION=$(java -version 2>&1)
VERSION=$(echo "$JDK_VERSION" | sed -n 's/.*build \([^[:space:]]*\)-LTS.*/\1/p')
echo "JDK_VERSION=$JDK_VERSION"
echo "VERSION=$VERSION"
MY_VERSION="jdk=$VERSION"
- name: Build and push
uses: docker/build-push-action@v6
if: matrix.language == 'java'
with:
context: .
file: ./Dockerfile
build-args: |
JAR_PATH=${{ steps.EXTRACT.outputs.extracted }}
LIB_PATH=${{ steps.aot.outputs.extracted }}
push: false
tags: angular2guy/moviemanager:latest
# ℹ️ Command-line programs to run using the OS shell.
# 📚 https://git.io/JvXDl
# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
# and modify them (or add more) to build your code if your project
# uses a compiled language
#- run: |
# make bootstrap
# make release
# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v3
with:
languages: ${{ matrix.language }}
# 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: Build with Maven for CodeQL
if: matrix.language == 'java'
run: |
./mvnw clean install -Ddocker=true
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v3