38
38
strategy :
39
39
fail-fast : false
40
40
matrix :
41
- language : [ 'go', 'javascript', 'python', 'java' ]
41
+ # Targets of the codeql analysis
42
+ # Each entry is composed by two elements: the language and the directory
43
+ # containing source code for that language.
44
+ target :
45
+ - language : ' go'
46
+ directory : ' go'
47
+ - language : ' javascript'
48
+ directory : ' nodejs'
49
+ - language : ' python'
50
+ directory : ' python'
51
+ - language : ' java'
52
+ directory : ' java'
53
+ - language : ' csharp'
54
+ directory : ' dotnet'
42
55
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby', 'swift' ]
43
56
# Use only 'java' to analyze code written in Java, Kotlin or both
44
57
# Use only 'javascript' to analyze code written in JavaScript, TypeScript or both
52
65
- name : Initialize CodeQL
53
66
uses : github/codeql-action/init@v2
54
67
with :
55
- languages : ${{ matrix.language }}
68
+ languages : ${{ matrix.target. language }}
56
69
# If you wish to specify custom queries, you can do so here or in a config file.
57
70
# By default, queries listed here will override any specified in a config file.
58
71
# Prefix the list here with "+" to use these queries and those in the config file.
65
78
# If this step fails, then you should remove it and run the build manually (see below)
66
79
- name : Autobuild
67
80
uses : github/codeql-action/autobuild@v2
68
- if : ${{ matrix.language != 'java' }}
81
+ with :
82
+ working-directory : ${{ matrix.target.directory }}
83
+ # There are no array literals in GHA that is why we need to use fromJson.
84
+ if : ${{ !contains(fromJson('["java", "csharp"]'), matrix.target.language) }}
69
85
70
86
# ℹ️ Command-line programs to run using the OS shell.
71
87
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun
@@ -82,16 +98,28 @@ jobs:
82
98
with :
83
99
distribution : corretto
84
100
java-version : ' 11'
85
- if : ${{ matrix.language == 'java' }}
101
+ if : ${{ matrix.target. language == 'java' }}
86
102
87
103
- name : build Java
88
104
uses : gradle/gradle-build-action@v2
89
105
with :
90
106
arguments : build --no-build-cache
91
- build-root-directory : java
92
- if : ${{ matrix.language == 'java' }}
107
+ build-root-directory : ${{ matrix.target.directory }}
108
+ if : ${{ matrix.target.language == 'java' }}
109
+
110
+ - name : setup dotnet
111
+ uses : actions/setup-dotnet@v3
112
+ with :
113
+ dotnet-version : 6.x
114
+ if : ${{ matrix.target.language == 'csharp' }}
115
+
116
+ - name : build dotnet
117
+ # Build all dotnet applications from this directory
118
+ run : find . -name '*.sln' -exec dotnet build '{}' \;
119
+ working-directory : ${{ matrix.target.directory }}
120
+ if : ${{ matrix.target.language == 'csharp' }}
93
121
94
122
- name : Perform CodeQL Analysis
95
123
uses : github/codeql-action/analyze@v2
96
124
with :
97
- category : " /language:${{matrix.language}}"
125
+ category : " /language:${{matrix.target. language}}"
0 commit comments