ci: split codeql (#13812)

* perf: codeql core

* perf: standardize caching for codeqlcore

* fix: correct cache keys

* perf: add codeql-js for website and workflows

* fix: typo

* fix: use bash instead of pwsh in ubuntu
This commit is contained in:
Constrat
2025-08-20 23:14:16 +02:00
committed by GitHub
parent b79b3d2a7d
commit 4489797eed
2 changed files with 102 additions and 26 deletions

View File

@@ -1,4 +1,4 @@
name: "CodeQL Advanced"
name: "CodeQL MaaCore and MaaWpfGui Analysis"
on:
pull_request:
@@ -10,10 +10,11 @@ on:
- "cmake/**"
- "CMakeLists.txt"
- "MAA.sln"
- ".github/workflows/ci.yml"
- ".github/workflows/codeql-core.yml"
- "!**/*.md"
- "!**/*.xaml"
schedule:
- cron: "45 11 * * *"
- cron: "45 11 * * *" # Runs daily at 11:45 UTC
workflow_dispatch:
permissions:
@@ -23,26 +24,6 @@ permissions:
security-events: write
jobs:
analyze-none:
name: Analyze CI and MaaWebsite
runs-on: windows-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
show-progress: false
- name: Setup CodeQL
uses: github/codeql-action/init@v3
with:
languages: javascript-typescript,actions
build-mode: none
- name: Run CodeQL
uses: github/codeql-action/analyze@v3
with:
category: "/language:multi-none"
analyze-manual:
name: Analyze MaaCore and MaaWpfGui
runs-on: windows-latest
@@ -52,12 +33,35 @@ jobs:
with:
show-progress: false
- name: Setup build environments
- name: Update submodules
run: git submodule update --init --depth 1 3rdparty/EmulatorExtras
- name: Cache .nuke/temp, ~/.nuget/packages
id: cache-nuget
uses: actions/cache@v4
with:
path: |
.nuke/temp
~/.nuget/packages
key: ${{ runner.os }}-x64-${{ hashFiles('**/global.json', '**/*.csproj') }}
- name: Restore dependencies
if: steps.cache-nuget.outputs.cache-hit != 'true'
run: dotnet restore
- name: Cache MaaDeps
id: cache-maadeps
uses: actions/cache@v4
with:
path: |
./MaaDeps
key: ${{ runner.os }}-x64-maadeps-${{ hashFiles('./maadeps-download.py') }}
- name: Bootstrap MaaDeps
if: steps.cache-maadeps.outputs.cache-hit != 'true'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
git submodule update --init --depth 1 3rdparty/EmulatorExtras
dotnet restore
python3 maadeps-download.py x64-windows
- name: Create fake event file

72
.github/workflows/codeql-js.yml vendored Normal file
View File

@@ -0,0 +1,72 @@
name: "CodeQL Website and Workflows Analysis"
on:
pull_request:
branches: ["dev"]
paths:
- "website/**"
- ".github/workflows/*.yml"
- ".github/*.yml"
- "!**/*.md"
schedule:
- cron: "00 12 * * *" # Runs daily at 12:00 UTC
workflow_dispatch:
permissions:
actions: write
contents: read
security-events: write
jobs:
analyze-website:
name: Analyze Website (JavaScript/TypeScript)
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
show-progress: false
- name: Setup CodeQL for JavaScript/TypeScript
uses: github/codeql-action/init@v3
with:
languages: javascript-typescript
build-mode: none
- name: Run CodeQL Analysis
uses: github/codeql-action/analyze@v3
with:
category: "/language:multi-none"
- name: Delete old caches
shell: bash
run: |
oldCaches=$(gh cache list --key codeql --order asc --json key | jq -r '.[] | .key' | head -n -1)
for cache in $oldCaches; do
if [ -n "$cache" ]; then
echo "Deleting cache: $cache"
gh cache delete "$cache" --confirm
fi
done
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
analyze-workflows:
name: Analyze GitHub Workflows
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
show-progress: false
- name: Setup CodeQL for GitHub Actions
uses: github/codeql-action/init@v3
with:
languages: actions
build-mode: none
- name: Run CodeQL Analysis
uses: github/codeql-action/analyze@v3
with:
category: "/language:multi-none"