|
| 1 | +# CodeQL static analysis |
| 2 | +name: CodeQL |
| 3 | + |
| 4 | +on: workflow_call |
| 5 | + |
| 6 | +permissions: |
| 7 | + contents: read |
| 8 | + |
| 9 | +env: |
| 10 | + BUILD_DIR : "${{github.workspace}}/build" |
| 11 | + INSTL_DIR : "${{github.workspace}}/../install-dir" |
| 12 | + |
| 13 | +jobs: |
| 14 | + analyze: |
| 15 | + name: Analyze |
| 16 | + permissions: |
| 17 | + security-events: write |
| 18 | + env: |
| 19 | + VCPKG_PATH: "${{github.workspace}}/build/vcpkg/packages/hwloc_x64-windows;${{github.workspace}}/build/vcpkg/packages/tbb_x64-windows;${{github.workspace}}/build/vcpkg/packages/jemalloc_x64-windows" |
| 20 | + strategy: |
| 21 | + fail-fast: false |
| 22 | + matrix: |
| 23 | + os: [windows-latest] |
| 24 | + |
| 25 | + # TODO revert |
| 26 | + runs-on: ["codeql-test", "Windows"] |
| 27 | + |
| 28 | + steps: |
| 29 | + - name: Checkout repository |
| 30 | + uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 |
| 31 | + with: |
| 32 | + fetch-depth: 0 |
| 33 | + |
| 34 | + - name: aaa |
| 35 | + if: matrix.os == 'windows-latest' |
| 36 | + run: echo $env:path |
| 37 | + shell: pwsh |
| 38 | + |
| 39 | + - name: Check for Python >= 3.10 |
| 40 | + id: check_python |
| 41 | + run: | |
| 42 | + $pythonCommand = Get-Command python -ErrorAction SilentlyContinue |
| 43 | + if ($pythonCommand) { |
| 44 | + $pythonVersion = python --version 2>&1 |
| 45 | + $versionPattern = 'Python (\d+)\.(\d+)\.(\d+)' |
| 46 | + echo $pythonVersion |
| 47 | + if ($pythonVersion -match $versionPattern) { |
| 48 | + $major = [int]$matches[1] |
| 49 | + $minor = [int]$matches[2] |
| 50 | + if ($major -gt 3 -or ($major -eq 3 -and $minor -ge 10)) { |
| 51 | + echo "##[set-output name=python_exists;]true" |
| 52 | + } |
| 53 | + } |
| 54 | + } |
| 55 | + shell: pwsh |
| 56 | + |
| 57 | + - name: Setup Python 3.10 |
| 58 | + if: steps.check_python.outputs.python_exists != 'true' |
| 59 | + uses: actions/setup-python@0a5c61591373683505ea898e09a3ea4f39ef2b9c # v5.0.0 |
| 60 | + with: |
| 61 | + python-version: "3.10" |
| 62 | + |
| 63 | + - name: Initialize CodeQL |
| 64 | + uses: github/codeql-action/init@b7bf0a3ed3ecfa44160715d7c442788f65f0f923 # v3.23.2 |
| 65 | + with: |
| 66 | + languages: cpp |
| 67 | + |
| 68 | + - name: "[Win] Initialize vcpkg" |
| 69 | + if: matrix.os == 'windows-latest' |
| 70 | + uses: lukka/run-vcpkg@5e0cab206a5ea620130caf672fce3e4a6b5666a1 # v11.5 |
| 71 | + with: |
| 72 | + vcpkgGitCommitId: 3dd44b931481d7a8e9ba412621fa810232b66289 |
| 73 | + vcpkgDirectory: ${{env.BUILD_DIR}}/vcpkg |
| 74 | + vcpkgJsonGlob: '**/vcpkg.json' |
| 75 | + |
| 76 | + - name: "[Win] Install dependencies" |
| 77 | + if: matrix.os == 'windows-latest' |
| 78 | + run: | |
| 79 | + vcpkg install |
| 80 | + echo $env:path |
| 81 | + python3 -m pip install -r third_party/requirements.txt |
| 82 | + shell: pwsh |
| 83 | + |
| 84 | + - name: "[Lin] Install apt packages" |
| 85 | + if: matrix.os == 'ubuntu-latest' |
| 86 | + run: | |
| 87 | + sudo apt-get update |
| 88 | + sudo apt-get install -y cmake clang libhwloc-dev libnuma-dev libjemalloc-dev libtbb-dev |
| 89 | +
|
| 90 | + # Latest distros do not allow global pip installation |
| 91 | + - name: "[Lin] Install Python requirements in venv" |
| 92 | + if: matrix.os == 'ubuntu-latest' |
| 93 | + run: | |
| 94 | + python3 -m venv .venv |
| 95 | + . .venv/bin/activate |
| 96 | + echo "$PATH" >> $GITHUB_PATH |
| 97 | + python3 -m pip install -r third_party/requirements.txt |
| 98 | +
|
| 99 | + - name: Configure CMake |
| 100 | + run: > |
| 101 | + cmake |
| 102 | + -B ${{env.BUILD_DIR}} |
| 103 | + ${{matrix.extra_build_option}} |
| 104 | + -DCMAKE_INSTALL_PREFIX="${{env.INSTL_DIR}}" |
| 105 | + -DCMAKE_PREFIX_PATH="${{env.VCPKG_PATH}}" |
| 106 | + -DUMF_FORMAT_CODE_STYLE=OFF |
| 107 | + -DUMF_DEVELOPER_MODE=ON |
| 108 | + -DUMF_BUILD_LIBUMF_POOL_JEMALLOC=ON |
| 109 | + -DUMF_BUILD_LEVEL_ZERO_PROVIDER=ON |
| 110 | + -DUMF_BUILD_CUDA_PROVIDER=ON |
| 111 | + -DUMF_TESTS_FAIL_ON_SKIP=ON |
| 112 | +
|
| 113 | + - name: Build |
| 114 | + run: cmake --build ${{env.BUILD_DIR}} --config Release -j |
| 115 | + |
| 116 | + - name: Perform CodeQL Analysis |
| 117 | + uses: github/codeql-action/analyze@b7bf0a3ed3ecfa44160715d7c442788f65f0f923 # v3.23.2 |
0 commit comments