2022-08-23 14:29:26 +03:00
|
|
|
name: 'Static C/C++ analysis with PVS-Studio'
|
|
|
|
|
|
|
|
on:
|
|
|
|
push:
|
|
|
|
branches:
|
|
|
|
- dev
|
|
|
|
- "release*"
|
|
|
|
tags:
|
|
|
|
- '*'
|
|
|
|
pull_request:
|
|
|
|
|
|
|
|
env:
|
|
|
|
TARGETS: f7
|
|
|
|
DEFAULT_TARGET: f7
|
2022-12-19 16:07:23 +03:00
|
|
|
FBT_TOOLCHAIN_PATH: /runner/_work
|
2022-08-23 14:29:26 +03:00
|
|
|
|
|
|
|
jobs:
|
|
|
|
analyse_c_cpp:
|
2022-08-27 15:38:13 +03:00
|
|
|
if: ${{ !github.event.pull_request.head.repo.fork }}
|
2022-08-23 14:29:26 +03:00
|
|
|
runs-on: [self-hosted, FlipperZeroShell]
|
|
|
|
steps:
|
2023-03-22 14:26:40 +03:00
|
|
|
- name: 'Wipe workspace'
|
|
|
|
run: find ./ -mount -maxdepth 1 -exec rm -rf {} \;
|
2022-08-23 14:29:26 +03:00
|
|
|
|
|
|
|
- name: 'Checkout code'
|
2022-12-10 16:10:51 +03:00
|
|
|
uses: actions/checkout@v3
|
2022-08-23 14:29:26 +03:00
|
|
|
with:
|
2023-03-15 18:24:56 +03:00
|
|
|
fetch-depth: 1
|
2022-08-23 14:29:26 +03:00
|
|
|
ref: ${{ github.event.pull_request.head.sha }}
|
|
|
|
|
2022-09-03 10:09:03 +03:00
|
|
|
- name: 'Get commit details'
|
2022-12-10 16:10:51 +03:00
|
|
|
id: names
|
2022-08-23 14:29:26 +03:00
|
|
|
run: |
|
|
|
|
if [[ ${{ github.event_name }} == 'pull_request' ]]; then
|
2022-09-05 16:40:54 +03:00
|
|
|
TYPE="pull"
|
|
|
|
elif [[ "${{ github.ref }}" == "refs/tags/"* ]]; then
|
|
|
|
TYPE="tag"
|
2022-08-23 14:29:26 +03:00
|
|
|
else
|
2022-09-05 16:40:54 +03:00
|
|
|
TYPE="other"
|
2022-08-23 14:29:26 +03:00
|
|
|
fi
|
2022-09-05 16:40:54 +03:00
|
|
|
python3 scripts/get_env.py "--event_file=${{ github.event_path }}" "--type=$TYPE"
|
2022-08-23 14:29:26 +03:00
|
|
|
|
2023-01-17 15:55:49 +03:00
|
|
|
- name: 'Supply PVS credentials'
|
2022-08-23 14:29:26 +03:00
|
|
|
run: |
|
|
|
|
pvs-studio-analyzer credentials ${{ secrets.PVS_STUDIO_CREDENTIALS }}
|
|
|
|
|
2022-12-26 22:33:44 +03:00
|
|
|
- name: 'Convert PVS-Studio output to html and detect warnings'
|
|
|
|
id: pvs-warn
|
|
|
|
run: |
|
|
|
|
WARNINGS=0
|
2023-01-17 15:55:49 +03:00
|
|
|
./fbt COMPACT=1 PVSNOBROWSER=1 firmware_pvs || WARNINGS=1
|
2022-12-26 22:33:44 +03:00
|
|
|
echo "warnings=${WARNINGS}" >> $GITHUB_OUTPUT
|
2022-08-23 14:29:26 +03:00
|
|
|
|
2023-02-09 13:42:41 +03:00
|
|
|
- name: 'Upload report'
|
2022-12-26 22:33:44 +03:00
|
|
|
if: ${{ !github.event.pull_request.head.repo.fork && (steps.pvs-warn.outputs.warnings != 0) }}
|
2023-02-09 13:42:41 +03:00
|
|
|
uses: prewk/s3-cp-action@v2
|
|
|
|
with:
|
|
|
|
aws_s3_endpoint: "${{ secrets.PVS_AWS_ENDPOINT }}"
|
|
|
|
aws_access_key_id: "${{ secrets.PVS_AWS_ACCESS_KEY }}"
|
|
|
|
aws_secret_access_key: "${{ secrets.PVS_AWS_SECRET_KEY }}"
|
|
|
|
source: "./build/f7-firmware-DC/pvsreport"
|
|
|
|
dest: "s3://${{ secrets.PVS_AWS_BUCKET }}/${{steps.names.outputs.branch_name}}/${{steps.names.outputs.default_target}}-${{steps.names.outputs.suffix}}/"
|
|
|
|
flags: "--recursive --acl public-read"
|
2022-08-23 14:29:26 +03:00
|
|
|
|
|
|
|
- name: 'Find Previous Comment'
|
2022-12-26 22:33:44 +03:00
|
|
|
if: ${{ !github.event.pull_request.head.repo.fork && github.event.pull_request && (steps.pvs-warn.outputs.warnings != 0) }}
|
|
|
|
uses: peter-evans/find-comment@v2
|
2022-08-23 14:29:26 +03:00
|
|
|
id: fc
|
|
|
|
with:
|
|
|
|
issue-number: ${{ github.event.pull_request.number }}
|
|
|
|
comment-author: 'github-actions[bot]'
|
|
|
|
body-includes: 'PVS-Studio report for commit'
|
|
|
|
|
|
|
|
- name: 'Create or update comment'
|
2022-12-26 22:33:44 +03:00
|
|
|
if: ${{ !github.event.pull_request.head.repo.fork && github.event.pull_request && (steps.pvs-warn.outputs.warnings != 0) }}
|
2022-08-23 14:29:26 +03:00
|
|
|
uses: peter-evans/create-or-update-comment@v1
|
|
|
|
with:
|
|
|
|
comment-id: ${{ steps.fc.outputs.comment-id }}
|
|
|
|
issue-number: ${{ github.event.pull_request.number }}
|
|
|
|
body: |
|
2022-09-03 10:09:03 +03:00
|
|
|
**PVS-Studio report for commit `${{steps.names.outputs.commit_sha}}`:**
|
2023-02-09 13:42:41 +03:00
|
|
|
- [Report](https://pvs.flipp.dev/${{steps.names.outputs.branch_name}}/${{steps.names.outputs.default_target}}-${{steps.names.outputs.suffix}}/index.html)
|
2022-08-23 14:29:26 +03:00
|
|
|
edit-mode: replace
|
2022-12-26 22:33:44 +03:00
|
|
|
|
|
|
|
- name: 'Raise exception'
|
|
|
|
if: ${{ steps.pvs-warn.outputs.warnings != 0 }}
|
|
|
|
run: |
|
2023-02-07 19:33:05 +03:00
|
|
|
echo "Please fix all PVS warnings before merge"
|
2022-12-26 22:33:44 +03:00
|
|
|
exit 1
|
|
|
|
|