@@ -38,21 +38,34 @@ jobs:
3838 strategy :
3939 fail-fast : false
4040 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'
4255 # CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby', 'swift' ]
4356 # Use only 'java' to analyze code written in Java, Kotlin or both
4457 # Use only 'javascript' to analyze code written in JavaScript, TypeScript or both
4558 # Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support
4659
4760 steps :
4861 - name : Checkout repository
49- uses : actions/checkout@v3
62+ uses : actions/checkout@v4
5063
5164 # Initializes the CodeQL tools for scanning.
5265 - name : Initialize CodeQL
5366 uses : github/codeql-action/init@v2
5467 with :
55- languages : ${{ matrix.language }}
68+ languages : ${{ matrix.target. language }}
5669 # If you wish to specify custom queries, you can do so here or in a config file.
5770 # By default, queries listed here will override any specified in a config file.
5871 # Prefix the list here with "+" to use these queries and those in the config file.
6578 # If this step fails, then you should remove it and run the build manually (see below)
6679 - name : Autobuild
6780 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) }}
6985
7086 # ℹ️ Command-line programs to run using the OS shell.
7187 # 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun
@@ -82,16 +98,28 @@ jobs:
8298 with :
8399 distribution : corretto
84100 java-version : ' 11'
85- if : ${{ matrix.language == 'java' }}
101+ if : ${{ matrix.target. language == 'java' }}
86102
87103 - name : build Java
88104 uses : gradle/gradle-build-action@v2
89105 with :
90106 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' }}
93121
94122 - name : Perform CodeQL Analysis
95123 uses : github/codeql-action/analyze@v2
96124 with :
97- category : " /language:${{matrix.language}}"
125+ category : " /language:${{matrix.target. language}}"
0 commit comments