Skip to content

Commit accfea6

Browse files
[Infra] Improve CodeQL analysis (#6415)
Co-authored-by: Rajkumar Rangaraj <[email protected]>
1 parent 570a6fa commit accfea6

File tree

1 file changed

+34
-16
lines changed

1 file changed

+34
-16
lines changed
Lines changed: 34 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,32 @@
1-
# For most projects, this workflow file will not need changing; you simply need
2-
# to commit it to your repository.
3-
#
4-
# You may wish to alter this file to override the set of languages analyzed,
5-
# or to provide custom queries or build logic.
61
name: "CodeQL"
72

83
on:
4+
push:
5+
branches: [ 'main' ]
6+
pull_request:
7+
branches: [ 'main' ]
98
schedule:
109
- cron: '0 0 * * *' # once in a day at 00:00
1110
workflow_dispatch:
1211

13-
permissions:
14-
contents: read
12+
permissions: {}
1513

1614
jobs:
1715
analyze:
1816
permissions:
1917
actions: read # for github/codeql-action/init to get workflow details
2018
contents: read # for actions/checkout to fetch code
2119
security-events: write # for github/codeql-action/analyze to upload SARIF results
22-
name: Analyze
2320
runs-on: windows-latest
2421

2522
strategy:
2623
fail-fast: false
2724
matrix:
28-
language: ['csharp']
25+
language: ['actions', 'csharp']
2926

3027
steps:
31-
- name: configure Pagefile
28+
- name: Configure Pagefile
29+
if: matrix.language == 'csharp'
3230
uses: al-cheb/configure-pagefile-action@a3b6ebd6b634da88790d9c58d4b37a7f4a7b8708 # v1.4
3331
with:
3432
minimum-size: 8GB
@@ -37,17 +35,37 @@ jobs:
3735

3836
- name: Checkout repository
3937
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
38+
with:
39+
filter: 'tree:0'
40+
persist-credentials: false
41+
show-progress: false
4042

4143
- name: Initialize CodeQL
4244
uses: github/codeql-action/init@4e828ff8d448a8a6e532957b1811f387a63867e8 # v3.29.4
4345
with:
46+
build-mode: none
4447
languages: ${{ matrix.language }}
4548

46-
- name: Setup dotnet
47-
uses: actions/setup-dotnet@67a3573c9a986a3f9c594539f4ab511d57bb3ce9 # v4.3.1
48-
49-
- name: dotnet pack
50-
run: dotnet pack ./build/OpenTelemetry.proj --configuration Release
51-
5249
- name: Perform CodeQL Analysis
5350
uses: github/codeql-action/analyze@4e828ff8d448a8a6e532957b1811f387a63867e8 # v3.29.4
51+
with:
52+
category: '/language:${{ matrix.language }}'
53+
54+
codeql:
55+
if: ${{ !cancelled() }}
56+
needs: [ analyze ]
57+
runs-on: ubuntu-latest
58+
59+
steps:
60+
- name: Report status
61+
shell: bash
62+
env:
63+
SCAN_SUCCESS: ${{ !contains(needs.*.result, 'failure') && !contains(needs.*.result, 'cancelled') }}
64+
run: |
65+
if [ "${SCAN_SUCCESS}" == "true" ]
66+
then
67+
echo 'CodeQL analysis successful'
68+
else
69+
echo 'CodeQL analysis failed'
70+
exit 1
71+
fi

0 commit comments

Comments
 (0)