llvm-project/.github/workflows/ci-post-commit-analyzer-run.py
Tom Stellard 81671fe0e2
[workflows] Add post-commit job that periodically runs the clang static analyzer (#94106)
This job will run once per day on the main branch, and for every commit
on a release branch. It currently only builds llvm, but could add more
sub-projects in the future.

OpenSSF Best Practices recommends running a static analyzer on software
before it is released:
https://www.bestpractices.dev/en/criteria/0#0.static_analysis
2024-06-07 19:02:55 -07:00

35 lines
724 B
Python

import json
import multiprocessing
import os
import re
import subprocess
import sys
def run_analyzer(data):
os.chdir(data["directory"])
command = (
data["command"]
+ f" --analyze --analyzer-output html -o analyzer-results -Xclang -analyzer-config -Xclang max-nodes=75000"
)
print(command)
subprocess.run(command, shell=True, check=True)
def pool_error(e):
print("Error analyzing file:", e)
def main():
db_path = sys.argv[1]
database = json.load(open(db_path))
with multiprocessing.Pool() as pool:
pool.map_async(run_analyzer, [k for k in database], error_callback=pool_error)
pool.close()
pool.join()
if __name__ == "__main__":
main()