I am trying to setup a CodeQL analysis workflow for my project on Github. I would like to analyze the code for Windows, Ubuntu and MacOS all together and therefore I decided to split the compile-part into three parallel ways, since I have to run the analysis separately for each OS. So far, I set-up the workflow in this way:
name: "CodeQL"
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
schedule:
- cron: '45 22 * * 0'
jobs:
analyze:
name: Analyze
runs-on: ${{ matrix.os }}
permissions:
actions: read
contents: read
security-events: write
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
language: [ 'cpp' ]
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Initialize CodeQL
uses: github/codeql-action/init@v2
with:
languages: ${{ matrix.language }}
- name: Installing extra dependencies and compiling (Ubuntu)
if: matrix.os == 'ubuntu-latest'
run: |
sudo apt install build-essential g++ libboost-all-dev wget unzip doctest-dev
exprtk_sha1=ca5c577917646ddba3f71ce6d5dd7d01f351ee80
wget https://github.com/ArashPartow/exprtk/archive/$exprtk_sha1.zip
mv $exprtk_sha1.zip exprtk-$exprtk_sha1.zip
unzip exprtk-$exprtk_sha1.zip
sudo cp exprtk-$exprtk_sha1/exprtk.hpp /usr/include/
rm -rf exprtk-*
make
- name: Installing extra dependencies and compiling (MacOS)
if: matrix.os == 'macos-latest'
run: |
brew install boost doctest
exprtk_sha1=ca5c577917646ddba3f71ce6d5dd7d01f351ee80
wget https://github.com/ArashPartow/exprtk/archive/$exprtk_sha1.zip
mv $exprtk_sha1.zip exprtk-$exprtk_sha1.zip
unzip exprtk-$exprtk_sha1.zip
sudo cp exprtk-$exprtk_sha1/exprtk.hpp /usr/local/include
rm -rf exprtk-*
make
- name: Installing extra dependencies and compiling (Windows)
if: matrix.os == 'windows-latest'
run: |
choco install unzip wget
mkdir C:/install
cd C:/install
wget https://boostorg.jfrog.io/artifactory/main/release/1.79.0/source/boost_1_79_0.zip | Out-Null
unzip boost_1_79_0.zip | Out-Null
mkdir C:/boost-build
mkdir C:/install/boost_1_79_0/boost-build
mkdir C:/boost
cd -
cd C:/install/boost_1_79_0/tools/build
.\bootstrap.bat gcc
.\b2 --prefix="C:/boost-build" install
$Env:PATH+=";C:/boost-build/bin"
cd -
cd C:/install/boost_1_79_0
b2 --build-dir="C:/install/boost_1_79_0/build" --build-type=complete --prefix="C:/boost" toolset=gcc install
cd -
cp -r C:/boost/include/boost-1_79/boost C:/ProgramData/Chocolatey/lib/mingw/tools/install/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/include/c++
cp C:/boost/lib/* C:/mingw810/x86_64-810-posix-seh-rt_v6-rev0/mingw64/opt/lib
$Env:PATH+=";C:/ProgramData/Chocolatey/lib/mingw/tools/install/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/include/c++"
$Env:PATH+=";C:/mingw810/x86_64-810-posix-seh-rt_v6-rev0/mingw64/opt/lib"
$Env:PATH+=";C:/ProgramData/Chocolatey/lib/mingw/tools/install/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/include/c++"
$Env:PATH+=";C:/mingw810/x86_64-810-posix-seh-rt_v6-rev0/mingw64/opt/lib"
rd -r C:/install
rd -r C:/boost-build
wget https://github.com/doctest/doctest/archive/refs/heads/master.zip | Out-Null
unzip master.zip | Out-Null
mkdir C:/ProgramData/Chocolatey/lib/mingw/tools/install/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/include/c++/doctest
cp doctest-master/doctest/doctest.h C:/ProgramData/Chocolatey/lib/mingw/tools/install/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/include/c++/doctest
rd -r doctest-master
make
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
It works well, but the problem is that in the Windows part, it employs more than 4 hours to complete, since I have to download and build the boost library every time, in order to correctly compile the code.
Is there a way to speed-up the process?
I already tried with package managers (even if many libraries are not founded on Windows), but the situation doesn't change, or other complications occur: like the fact that I have to find every time the installation of the dependencies and add them to the system path, but since they are not easy to find, I have to re-launch the workflow many and many times to debug.