-
Notifications
You must be signed in to change notification settings - Fork 0
102 lines (85 loc) · 3.04 KB
/
Copy pathcodeql.yml
File metadata and controls
102 lines (85 loc) · 3.04 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
name: "CodeQL"
on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
schedule:
- cron: '21 10 * * 5'
jobs:
check-changes:
runs-on: ubuntu-latest
permissions:
contents: read
outputs:
languages: ${{ steps.set-matrix.outputs.languages }}
steps:
- uses: actions/checkout@v6
- uses: dorny/paths-filter@de90cc6fb38fc0963ad72b210f1f284cd68cea36
id: filter
with:
filters: |
rust:
- 'crates/**'
- 'Cargo.toml'
- 'Cargo.lock'
python:
- 'tests/verify_validate/**'
javascript:
- 'scripts/**'
- 'package.json'
- id: set-matrix
run: |
# Build a JSON array of languages based on changes
LANGS="[]"
if [ "${{ steps.filter.outputs.rust }}" == "true" ]; then
LANGS=$(echo $LANGS | jq -c '. + ["rust"]')
fi
if [ "${{ steps.filter.outputs.python }}" == "true" ]; then
LANGS=$(echo $LANGS | jq -c '. + ["python"]')
fi
if [ "${{ steps.filter.outputs.javascript }}" == "true" ]; then
# CodeQL uses 'javascript-typescript' for JS
LANGS=$(echo $LANGS | jq -c '. + ["javascript-typescript"]')
fi
# If this is a scheduled run, analyze everything (fallback)
if [ "${{ github.event_name }}" == "schedule" ]; then
LANGS='["rust", "python", "javascript-typescript"]'
fi
# Handle empty case (if docs only) -> Pass empty JSON to avoid matrix error
# Actually, empty matrix usually skips job.
echo "languages=$LANGS" >> $GITHUB_OUTPUT
echo "Detected languages: $LANGS"
analyze:
needs: check-changes
if: ${{ needs.check-changes.outputs.languages != '[]' }}
name: Analyze
runs-on: ubuntu-latest
permissions:
actions: read
contents: read
security-events: write
strategy:
fail-fast: false
matrix:
language: ${{ fromJSON(needs.check-changes.outputs.languages) }}
steps:
- name: Checkout repository
uses: actions/checkout@v6
# Initialize CodeQL tools for the scanned language
- name: Initialize CodeQL
uses: github/codeql-action/init@v4
with:
languages: ${{ matrix.language }}
# If you have custom config, point to it, else default
# Autobuild attempts to build any compiled languages (C/C++, C#, Go, Java, Swift)
# For Rust, Autobuild often works, but manual build might be needed if complex.
# Python/JS are interpreted.
- name: Autobuild
uses: github/codeql-action/autobuild@v4
# ℹ️ Command-line programs to run using the OS shell.
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v4
with:
category: "/language:${{ matrix.language }}"