Skip to content

Commit af9fc4d

Browse files
fix: add CodeQL workflow with disk space cleanup (#8817)
* fix: add CodeQL workflow with disk space cleanup * chore: update CodeQL workflow to match GitHub advanced setup
1 parent 0f00d18 commit af9fc4d

File tree

2 files changed

+138
-0
lines changed

2 files changed

+138
-0
lines changed

.github/codeql/codeql-config.yml

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
name: "CodeQL Config"
2+
3+
# Exclude paths to reduce disk space usage during CodeQL analysis
4+
# This prevents analyzing unnecessary files that consume disk space
5+
paths-ignore:
6+
# Dependencies - don't analyze third-party code
7+
- "**/node_modules"
8+
- "**/yarn.lock"
9+
- "**/package-lock.json"
10+
11+
# Build artifacts - generated code doesn't need analysis
12+
- "**/dist"
13+
- "**/lib"
14+
- "**/compiled"
15+
- "**/build"
16+
- "**/www"
17+
- "**/release"
18+
19+
# Test fixtures and snapshots
20+
- "**/__mocks__"
21+
- "**/__image_snapshots__"
22+
- "**/_fixtures"
23+
- "**/fixture"
24+
- "**/test/**/*.png"
25+
- "**/test/**/*.jpg"
26+
- "**/test/**/*.svg"
27+
- "**/integration-tests/**/*.png"
28+
29+
# Example and playground files - not production code
30+
- "**/example"
31+
- "**/examples"
32+
- "**/playground"
33+
- "**/website"
34+
- "**/docs"
35+
36+
# Generated files
37+
- "**/*.map"
38+
- "**/*.min.js"
39+
- "**/*.min.css"
40+
41+
# Large standalone packages - exclude website and release directories
42+
- "standalone-packages/monaco-editor/website"
43+
- "standalone-packages/monaco-editor/release"
44+
- "standalone-packages/vscode-editor/release"
45+
- "standalone-packages/vscode-textmate/**/*.result"
46+
- "standalone-packages/vscode-textmate/**/*.patch"
47+
48+
# Static assets
49+
- "**/static/fonts"
50+
- "**/static/img"
51+
- "**/public"
52+
53+
# CI/CD files
54+
- "**/Dockerfile*"
55+
- "**/.circleci"

.github/workflows/codeql.yml

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
name: "CodeQL"
2+
3+
on:
4+
push:
5+
branches: [ "main" ]
6+
pull_request:
7+
branches: [ "main" ]
8+
schedule:
9+
- cron: '0 0 * * 0'
10+
11+
jobs:
12+
analyze:
13+
name: Analyze (${{ matrix.language }})
14+
runs-on: ubuntu-latest
15+
permissions:
16+
# required for all workflows
17+
security-events: write
18+
# required to fetch internal or private CodeQL packs
19+
packages: read
20+
# only required for workflows in private repositories
21+
actions: read
22+
contents: read
23+
24+
strategy:
25+
fail-fast: false
26+
matrix:
27+
include:
28+
- language: javascript-typescript
29+
build-mode: none
30+
31+
steps:
32+
- name: Clean up disk space
33+
run: |
34+
echo "Disk space before cleanup:"
35+
df -h
36+
echo ""
37+
echo "Cleaning up unnecessary files to free disk space..."
38+
39+
# Remove large tool directories that aren't needed for JavaScript/TypeScript CodeQL analysis
40+
# These tools will be re-downloaded by GitHub Actions if needed for other jobs
41+
sudo rm -rf /usr/share/dotnet
42+
sudo rm -rf /opt/ghc
43+
sudo rm -rf /usr/local/share/boost
44+
sudo rm -rf /usr/local/lib/android
45+
sudo rm -rf /opt/az
46+
47+
# Remove large tool caches (CodeQL will re-download only what it needs)
48+
sudo rm -rf "$AGENT_TOOLSDIRECTORY"
49+
50+
# Clean up system caches
51+
sudo apt-get clean
52+
sudo rm -rf /var/lib/apt/lists/*
53+
54+
# Remove Docker images if Docker is installed (not needed for CodeQL)
55+
docker system prune -af || true
56+
57+
# Remove pip cache
58+
rm -rf ~/.cache/pip || true
59+
60+
# Remove npm cache (will be recreated during checkout if needed)
61+
npm cache clean --force || true
62+
63+
echo ""
64+
echo "Disk space after cleanup:"
65+
df -h
66+
67+
- name: Checkout repository
68+
uses: actions/checkout@v4
69+
70+
# Initializes the CodeQL tools for scanning.
71+
- name: Initialize CodeQL
72+
uses: github/codeql-action/init@v4
73+
with:
74+
languages: ${{ matrix.language }}
75+
build-mode: ${{ matrix.build-mode }}
76+
# Use our custom config file to exclude unnecessary files
77+
config-file: ./.github/codeql/codeql-config.yml
78+
79+
- name: Perform CodeQL Analysis
80+
uses: github/codeql-action/analyze@v4
81+
with:
82+
category: "/language:${{matrix.language}}"
83+

0 commit comments

Comments
 (0)