Skip to content

Commit

Permalink
Add github codeql
Browse files Browse the repository at this point in the history
  • Loading branch information
h0lyalg0rithm committed Sep 3, 2023
1 parent d0c9002 commit fa1ed8a
Show file tree
Hide file tree
Showing 2 changed files with 125 additions and 0 deletions.
42 changes: 42 additions & 0 deletions .github/actions/build/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#!/usr/bin/env bash

set -x

source "/usr/share/miniconda/etc/profile.d/conda.sh"
conda activate riscv_perf_model

echo "Starting Build Entry"
echo "HOME:" $HOME
echo "GITHUB_WORKSPACE:" $GITHUB_WORKSPACE
echo "GITHUB_EVENT_PATH:" $GITHUB_EVENT_PATH
echo "CONDA_PREFIX:" $CONDA_PREFIX
echo "PWD:" `pwd`

#
# Compile Sparta Infra (always build with release)
# Have other build types point to release
#
echo "Building Sparta Infra"
cd ${GITHUB_WORKSPACE}/map/sparta
mkdir -p release
cd release
cmake .. -DCMAKE_BUILD_TYPE=$OLYMPIA_BUILD_TYPE -DGEN_DEBUG_INFO=OFF -DCMAKE_INSTALL_PREFIX=${CONDA_PREFIX}
if [ $? -ne 0 ]; then
echo "ERROR: Cmake for Sparta framework failed"
exit 1
fi
make -j$(nproc --all) install
BUILD_SPARTA=$?
if [ ${BUILD_SPARTA} -ne 0 ]; then
echo "ERROR: build sparta FAILED!!!"
exit 1
fi

cd ${GITHUB_WORKSPACE}
mkdir $OLYMPIA_BUILD_TYPE
cd $OLYMPIA_BUILD_TYPE
cmake .. -DCMAKE_BUILD_TYPE=$OLYMPIA_BUILD_TYPE -DGEN_DEBUG_INFO=OFF
if [ $? -ne 0 ]; then
echo "ERROR: Cmake for olympia failed"
exit 1
fi
83 changes: 83 additions & 0 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
name: "Github CodeQL"

on:
push:
branches:
- '*'

jobs:
analyze:
name: Analyze
runs-on: ubuntu-latest
permissions:
actions: read
contents: read
security-events: write

strategy:
fail-fast: false
matrix:
language: [ cpp ]
os: [ubuntu-latest]
BUILD_TYPE: [Debug,Release]

env:
OLYMPIA_BUILD_TYPE: ${{ matrix.BUILD_TYPE }}

steps:
- name: Checkout
uses: actions/checkout@v3
with:
submodules: recursive
#
# Get Sparta
- name: Checkout Sparta
uses: actions/checkout@v3
with:
repository: sparcians/map
path: map
ref: map_v2

# Setup Conda and build environment
- name: Grab Python v3.8
uses: actions/setup-python@v3
with:
python-version: 3.8

# Cache the conda dependencies to
- name: Cache conda deps
uses: actions/cache@v3
with:
key: ${{ matrix.os }}-${{ matrix.BUILD_TYPE }}-conda-${{ hashFiles('conda/environment.yml') }}
path: /usr/share/miniconda/envs/riscv_perf_model # Default path for conda

# Setup CCache to cache builds
- name: ccache
uses: hendrikmuhs/[email protected]
with:
key: ${{ matrix.os }}-${{ matrix.BUILD_TYPE }}-ccache-${{ github.ref_name }}
restore-keys: |
${{ matrix.os }}-${{ matrix.BUILD_TYPE }}-ccache-master
${{ matrix.os }}-${{ matrix.BUILD_TYPE }}-ccache
- name: Setup Conda Environment
run: |
# $CONDA is an environment variable pointing to the root of the miniconda directory
$CONDA/bin/conda config --set channel_priority strict
$CONDA/bin/conda env update --file ${{ github.workspace }}/conda/environment.yml
$CONDA/bin/conda init bash
# Build
- name: Initialize CodeQL
uses: github/codeql-action/init@v2
with:
languages: ${{ matrix.language }}
queries: +security-and-quality

- name: Build
run: ./.github/actions/build/build.sh

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
with:
category: "/language:${{ matrix.language }}"

0 comments on commit fa1ed8a

Please sign in to comment.