|
| 1 | +name: "CodeQL" |
| 2 | + |
| 3 | +on: |
| 4 | + # Run the analysis once every 24 hours. The actual time does not matter |
| 5 | + # that much, start with a time that allows for easier troubleshooting. |
| 6 | + schedule: |
| 7 | + - cron: '00 22 * * *' |
| 8 | + |
| 9 | +jobs: |
| 10 | + analyze: |
| 11 | + name: Analyze |
| 12 | + runs-on: ubuntu-latest |
| 13 | + permissions: |
| 14 | + actions: read |
| 15 | + contents: read |
| 16 | + security-events: write |
| 17 | + |
| 18 | + strategy: |
| 19 | + fail-fast: false |
| 20 | + matrix: |
| 21 | + language: [ 'cpp' ] |
| 22 | + |
| 23 | + steps: |
| 24 | + - name: Checkout repository |
| 25 | + uses: actions/checkout@v2 |
| 26 | + - name: Checkout vcpkg |
| 27 | + uses: actions/checkout@v2 |
| 28 | + with: |
| 29 | + path: "build/vcpkg" |
| 30 | + repository: "microsoft/vcpkg" |
| 31 | + fetch-depth: 0 |
| 32 | + - name: Checkout pinned vcpkg version |
| 33 | + run: > |
| 34 | + git -C build/vcpkg checkout -q $(<ci/etc/vcpkg-commit.txt) |
| 35 | + - name: cache-vcpkg |
| 36 | + id: cache-vcpkg |
| 37 | + uses: actions/cache@v2 |
| 38 | + with: |
| 39 | + path: | |
| 40 | + ~/.cache/vcpkg |
| 41 | + ~/.ccache |
| 42 | + key: | |
| 43 | + codeql-analysis-6-${{ hashFiles('vcpkg.json') }}-${{ hashFiles('build/vcpkg/versions/baseline.json') }} |
| 44 | + restore-keys: | |
| 45 | + codeql-analysis- |
| 46 | + - name: install tools |
| 47 | + run: sudo apt install ninja-build ccache |
| 48 | + - name: bootstrap vcpkg |
| 49 | + working-directory: "build/vcpkg" |
| 50 | + run: | |
| 51 | + CC="ccache gcc" CXX="ccache g++" ./bootstrap-vcpkg.sh -disableMetrics |
| 52 | +
|
| 53 | + # Compile the dependencies of `google-cloud-cpp` (if needed) before |
| 54 | + # enabling the CodeQL scan, otherwise all the code in the deps would be |
| 55 | + # scanned too. Note that most of the time this uses the vcpkg binary |
| 56 | + # cache. |
| 57 | + - name: bootstrap vcpkg packages |
| 58 | + run: > |
| 59 | + build/vcpkg/vcpkg install \ |
| 60 | + --x-manifest-root . \ |
| 61 | + --feature-flags=versions \ |
| 62 | + --clean-after-build |
| 63 | +
|
| 64 | + - name: Initialize CodeQL |
| 65 | + uses: github/codeql-action/init@v1 |
| 66 | + with: |
| 67 | + languages: ${{ matrix.language }} |
| 68 | + |
| 69 | + - name: Build |
| 70 | + # The build configuration is specifically tweaked for CodeQL analysis: |
| 71 | + # - We disable the tests because I (coryan) think that any security |
| 72 | + # vulnerabilities in the tests are irrelevant *and* compiling with |
| 73 | + # the tests takes over 3h. |
| 74 | + # - We disable ccache because the CodeQL scan only scans the code |
| 75 | + # that is actually compiled. Any cached compilation would be |
| 76 | + # excluded from the DB |
| 77 | + run: > |
| 78 | + cmake -GNinja -S . -B build/output \ |
| 79 | + -DCMAKE_TOOLCHAIN_FILE=build/vcpkg/scripts/buildsystems/vcpkg.cmake \ |
| 80 | + -DBUILD_TESTING=OFF \ |
| 81 | + -DGOOGLE_CLOUD_CPP_ENABLE_CCACHE=OFF && \ |
| 82 | + cmake --build build/output |
| 83 | +
|
| 84 | + - name: Perform CodeQL Analysis |
| 85 | + uses: github/codeql-action/analyze@v1 |
0 commit comments