Add filter step for code-scanning.yml

This commit is contained in:
Alexis Ehret 2021-02-12 18:34:59 +01:00
parent 535a677f3f
commit a250dd0b74

View file

@ -3,52 +3,103 @@ name: "Code scanning"
on:
push:
pull_request:
schedule:
- cron: '0 0 * * 1'
jobs:
changes:
runs-on: ubuntu-latest
outputs:
tools: ${{ steps.filter.outputs.changes }}
steps:
- uses: dorny/paths-filter@v2
id: filter
with:
filters: |
Clang:
- '**.c'
- '**.h'
- '**.in'
- '**.inc'
- '**/meson.build'
- 'shlr/rizin-shell-parser/**'
- 'subprojects/**'
- '.github/workflows/code-analysis.yml'
CodeQL-cpp:
- '**.c'
- '**.h'
- '**.in'
- '**.inc'
- '**/meson.build'
- 'shlr/rizin-shell-parser/**'
- 'subprojects/**'
- '.github/workflows/code-analysis.yml'
CodeQL-javascript:
- '**.py'
- '.github/workflows/code-analysis.yml'
CodeQL-python:
- '**.js'
- '.github/workflows/code-analysis.yml'
build:
needs: changes
name: ${{ matrix.name }}
runs-on: ubuntu-20.04
strategy:
fail-fast: false
matrix:
name: [CodeQL, Clang]
name: ${{ fromJson(needs.changes.outputs.tools) }}
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Install meson and ninja
if: matrix.name == 'CodeQL-cpp' || matrix.name == 'Clang'
run: |
sudo apt --assume-yes install python3-wheel python3-setuptools
sudo pip3 install meson ninja PyYAML
- name: Install microsoft/sarif-multitool
if: matrix.name == 'Clang'
run: |
sudo apt --assume-yes install npm
npm install @microsoft/sarif-multitool
- name: Initialize CodeQL
if: matrix.name == 'CodeQL'
- name: Initialize CodeQL - cpp
if: matrix.name == 'CodeQL-cpp'
uses: github/codeql-action/init@v1
with:
languages: cpp
setup-python-dependencies: false
- name: Initialize CodeQL - javascript
if: matrix.name == 'CodeQL-javascript'
uses: github/codeql-action/init@v1
with:
languages: javascript
setup-python-dependencies: false
- name: Initialize CodeQL - python
if: matrix.name == 'CodeQL-python'
uses: github/codeql-action/init@v1
with:
languages: python
setup-python-dependencies: false
- name: Autobuild CodeQL
if: matrix.name == 'CodeQL'
if: matrix.name == 'CodeQL-cpp'
uses: github/codeql-action/autobuild@v1
- name: Perform CodeQL Analysis
if: matrix.name == 'CodeQL'
if: startsWith( matrix.name, 'CodeQL' )
uses: github/codeql-action/analyze@v1
with:
output: "reports"
upload: false
- name: Merge all files (CodeQL)
if: matrix.name == 'CodeQL'
run: npx @microsoft/sarif-multitool merge reports/*.sarif
- name: Move file to merged.sarif (CodeQL)
if: startsWith( matrix.name, 'CodeQL' )
run: mv reports/*.sarif merged.sarif
- name: Install clang-tools-11 (Clang)
if: matrix.name == 'Clang'
@ -70,8 +121,7 @@ jobs:
- name: Exclude external lib
run: |
jq 'del(.runs[].results[].locations[] | select(.physicalLocation.artifactLocation.uri | contains("subprojects/")))' merged.sarif > tmp0.sarif
jq 'del(.runs[].results[] | select(.locations | length == 0))' tmp0.sarif > tmp1.sarif
jq 'del(.runs[] | select(.results | length == 0))' tmp1.sarif > filtered.sarif
jq 'del(.runs[].results[] | select(.locations | length == 0))' tmp0.sarif > filtered.sarif
- name: Treat warnings as errors
run: |