Skip to content

Commit

Permalink
ci: update codeql to handle multiple OSes
Browse files Browse the repository at this point in the history
  • Loading branch information
ReenigneArcher committed Apr 16, 2024
1 parent 76d08eb commit 9ac63f0
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 9 deletions.
File renamed without changes.
25 changes: 25 additions & 0 deletions .codeql-prebuild-cpp-Windows.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# install dependencies for C++ analysis

# update pacman
pacman --noconfirm -Suy

# install dependencies
pacman --noconfirm -S \
base-devel \
cmake \
diffutils \
gcc \
git \
make \
mingw-w64-x86_64-binutils \
mingw-w64-x86_64-boost \
mingw-w64-x86_64-cmake \
mingw-w64-x86_64-curl \
mingw-w64-x86_64-miniupnpc \
mingw-w64-x86_64-nlohmann-json \
mingw-w64-x86_64-nodejs \
mingw-w64-x86_64-onevpl \
mingw-w64-x86_64-openssl \
mingw-w64-x86_64-opus \
mingw-w64-x86_64-rust \
mingw-w64-x86_64-toolchain
36 changes: 27 additions & 9 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ on:
- cron: '00 12 * * 0' # every Sunday at 12:00 UTC

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
group: "${{ github.workflow }}-${{ github.ref }}"
cancel-in-progress: true

jobs:
Expand Down Expand Up @@ -57,10 +57,17 @@ jobs:
console.log(`Remapping language: ${key} to ${remap_languages[key.toLowerCase()]}`)
key = remap_languages[key.toLowerCase()]
}
if (supported_languages.includes(key.toLowerCase()) &&
!matrix['include'].includes({"language": key.toLowerCase()})) {
if (supported_languages.includes(key.toLowerCase())) {
console.log(`Found supported language: ${key}`)
matrix['include'].push({"language": key.toLowerCase()})
let osList = ['ubuntu-latest'];
if (key.toLowerCase() === 'swift') {
osList = ['macos-latest'];
} else if (key.toLowerCase() === 'cpp') {
osList = ['macos-latest', 'ubuntu-latest', 'windows-latest'];
}
for (let os of osList) {
matrix['include'].push({"language": key.toLowerCase(), "os": os})
}
}
}
Expand All @@ -86,8 +93,11 @@ jobs:
analyze:
name: Analyze
if: ${{ needs.languages.outputs.continue == 'true' }}
defaults:
run:
shell: ${{ matrix.os == 'windows-latest' && 'msys2 {0}' || 'bash' }}
needs: [languages]
runs-on: ${{ (matrix.language == 'swift' && 'macos-latest') || 'ubuntu-latest' }}
runs-on: ${{ matrix.os || 'ubuntu-latest' }}
timeout-minutes: ${{ (matrix.language == 'swift' && 120) || 360 }}
permissions:
actions: read
Expand All @@ -100,6 +110,7 @@ jobs:

steps:
- name: Maximize build space
if: runner.os == 'Linux'
uses: easimon/maximize-build-space@v8
with:
root-reserve-mb: 20480
Expand All @@ -114,6 +125,12 @@ jobs:
with:
submodules: recursive

- name: Setup msys2
if: runner.os == 'Windows'
uses: msys2/setup-msys2@v2
with:
update: true

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v3
Expand All @@ -131,10 +148,11 @@ jobs:
# create a file named .codeql-prebuild-${{ matrix.language }}.sh in the root of your repository
- name: Prebuild
run: |
# check if .qodeql-prebuild-${{ matrix.language }}.sh exists
if [ -f "./.codeql-prebuild-${{ matrix.language }}.sh" ]; then
echo "Running .codeql-prebuild-${{ matrix.language }}.sh"
./.codeql-prebuild-${{ matrix.language }}.sh
# check if prebuild script exists
filename=".codeql-prebuild-${{ matrix.language }}-${{ runner.os }}.sh"
if [ -f "./${filename}" ]; then
echo "Running prebuild script: ${filename}"
./${filename}
fi
# Autobuild attempts to build any compiled languages (C/C++, C#, Go, Java, or Swift).
Expand Down

0 comments on commit 9ac63f0

Please sign in to comment.