Skip to content

Copy compile_commands.json to the correct place #33

Copy compile_commands.json to the correct place

Copy compile_commands.json to the correct place #33

# yaml-language-server: $schema=https://json.schemastore.org/github-workflow.json
name: "CodeQL - Analyze (C++, Python, Actions)"
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
schedule:
- cron: '0 3 * * 0' # weekly (UTC) — adjust as needed
workflow_dispatch:
permissions:
actions: read
contents: read
security-events: write
env:
BUILD_TYPE: RelWithDebInfo
jobs:
codeql:
name: Analyze with CodeQL
runs-on: ubuntu-24.04
container:
image: ghcr.io/framework-r-d/phlex-ci:latest
strategy:
fail-fast: false
matrix: # Necessry to disable yaml-language-server warning
single-run: [ true ]
timeout-minutes: 120
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
path: phlex-src
fetch-depth: 0
- name: Setup build environment
uses: ./phlex-src/.github/actions/setup-build-env
- name: Initialize CodeQL
uses: github/codeql-action/init@v4
with:
languages: cpp, python, actions
config-file: phlex-src/.github/codeql/codeql-config.yml
source-root: phlex-src
build-mode: none
- name: Configure CMake
uses: ./phlex-src/.github/actions/configure-cmake
with:
build-type: ${{ env.BUILD_TYPE }}
- name: Generate compilation database
run: |
. /entrypoint.sh
cd $GITHUB_WORKSPACE/phlex-build
ninja -t compdb
- name: Verify compile_commands.json and publish for diagnostics
run: |
set -euo pipefail
echo "Looking for compile_commands.json in common build locations..."
# Prefer phlex-src/build/compile_commands.json
if [ -f "$GITHUB_WORKSPACE/phlex-src/build/compile_commands.json" ]; then
echo "Found phlex-src/build/compile_commands.json"
cp "$GITHUB_WORKSPACE/phlex-src/build/compile_commands.json" "$GITHUB_WORKSPACE/phlex-src/"
elif [ -f "$GITHUB_WORKSPACE/phlex-build/compile_commands.json" ]; then
echo "Found phlex-build/compile_commands.json"
cp "$GITHUB_WORKSPACE/phlex-build/compile_commands.json" "$GITHUB_WORKSPACE/phlex-src/"
else
echo "No compile_commands.json found in phlex-src/build or phlex-build; continuing."
fi
echo "Workspace listing (for debugging):"
ls -la "$GITHUB_WORKSPACE" || true
find "$GITHUB_WORKSPACE" -type f -name compile_commands.json
# Run CodeQL analysis (uploads results to code scanning)
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v4
with:
category: "CodeQL"
output: codeql-results.sarif