2022-08-23 11:29:26 +00: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 13:07:23 +00:00
|
|
|
FBT_TOOLCHAIN_PATH: /runner/_work
|
2022-08-23 11:29:26 +00:00
|
|
|
|
|
|
|
jobs:
|
|
|
|
analyse_c_cpp:
|
2022-08-27 12:38:13 +00:00
|
|
|
if: ${{ !github.event.pull_request.head.repo.fork }}
|
2022-08-23 11:29:26 +00:00
|
|
|
runs-on: [self-hosted, FlipperZeroShell]
|
|
|
|
steps:
|
|
|
|
- name: 'Decontaminate previous build leftovers'
|
|
|
|
run: |
|
2022-09-03 07:09:03 +00:00
|
|
|
if [ -d .git ]; then
|
|
|
|
git submodule status || git checkout "$(git rev-list --max-parents=0 HEAD | tail -n 1)"
|
2022-08-23 11:29:26 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
- name: 'Checkout code'
|
2022-12-10 13:10:51 +00:00
|
|
|
uses: actions/checkout@v3
|
2022-08-23 11:29:26 +00:00
|
|
|
with:
|
|
|
|
fetch-depth: 0
|
|
|
|
ref: ${{ github.event.pull_request.head.sha }}
|
|
|
|
|
2022-09-03 07:09:03 +00:00
|
|
|
- name: 'Get commit details'
|
2022-12-10 13:10:51 +00:00
|
|
|
id: names
|
2022-08-23 11:29:26 +00:00
|
|
|
run: |
|
|
|
|
if [[ ${{ github.event_name }} == 'pull_request' ]]; then
|
2022-09-05 13:40:54 +00:00
|
|
|
TYPE="pull"
|
|
|
|
elif [[ "${{ github.ref }}" == "refs/tags/"* ]]; then
|
|
|
|
TYPE="tag"
|
2022-08-23 11:29:26 +00:00
|
|
|
else
|
2022-09-05 13:40:54 +00:00
|
|
|
TYPE="other"
|
2022-08-23 11:29:26 +00:00
|
|
|
fi
|
2022-09-05 13:40:54 +00:00
|
|
|
python3 scripts/get_env.py "--event_file=${{ github.event_path }}" "--type=$TYPE"
|
2022-08-23 11:29:26 +00:00
|
|
|
|
2023-01-17 12:55:49 +00:00
|
|
|
- name: 'Supply PVS credentials'
|
2022-08-23 11:29:26 +00:00
|
|
|
run: |
|
|
|
|
pvs-studio-analyzer credentials ${{ secrets.PVS_STUDIO_CREDENTIALS }}
|
|
|
|
|
2022-12-26 19:33:44 +00:00
|
|
|
- name: 'Convert PVS-Studio output to html and detect warnings'
|
|
|
|
id: pvs-warn
|
|
|
|
run: |
|
|
|
|
WARNINGS=0
|
2023-01-17 12:55:49 +00:00
|
|
|
./fbt COMPACT=1 PVSNOBROWSER=1 firmware_pvs || WARNINGS=1
|
2022-12-26 19:33:44 +00:00
|
|
|
echo "warnings=${WARNINGS}" >> $GITHUB_OUTPUT
|
2022-08-23 11:29:26 +00:00
|
|
|
|
|
|
|
- name: 'Upload artifacts to update server'
|
2022-12-26 19:33:44 +00:00
|
|
|
if: ${{ !github.event.pull_request.head.repo.fork && (steps.pvs-warn.outputs.warnings != 0) }}
|
2022-08-23 11:29:26 +00:00
|
|
|
run: |
|
2022-10-12 15:31:25 +00:00
|
|
|
mkdir -p ~/.ssh
|
|
|
|
ssh-keyscan -p ${{ secrets.RSYNC_DEPLOY_PORT }} -H ${{ secrets.RSYNC_DEPLOY_HOST }} > ~/.ssh/known_hosts
|
2022-08-23 11:29:26 +00:00
|
|
|
echo "${{ secrets.RSYNC_DEPLOY_KEY }}" > deploy_key;
|
|
|
|
chmod 600 ./deploy_key;
|
|
|
|
rsync -avrzP --mkpath \
|
|
|
|
-e 'ssh -p ${{ secrets.RSYNC_DEPLOY_PORT }} -i ./deploy_key' \
|
2023-01-17 12:55:49 +00:00
|
|
|
build/f7-firmware-DC/pvsreport/ ${{ secrets.RSYNC_DEPLOY_USER }}@${{ secrets.RSYNC_DEPLOY_HOST }}:/home/data/firmware-pvs-studio-report/"${BRANCH_NAME}/${{steps.names.outputs.default_target}}-${{steps.names.outputs.suffix}}/";
|
2022-08-23 11:29:26 +00:00
|
|
|
rm ./deploy_key;
|
|
|
|
|
|
|
|
- name: 'Find Previous Comment'
|
2022-12-26 19:33:44 +00: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 11:29:26 +00: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 19:33:44 +00:00
|
|
|
if: ${{ !github.event.pull_request.head.repo.fork && github.event.pull_request && (steps.pvs-warn.outputs.warnings != 0) }}
|
2022-08-23 11:29:26 +00: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 07:09:03 +00:00
|
|
|
**PVS-Studio report for commit `${{steps.names.outputs.commit_sha}}`:**
|
|
|
|
- [Report](https://update.flipperzero.one/builds/firmware-pvs-studio-report/${{steps.names.outputs.branch_name}}/${{steps.names.outputs.default_target}}-${{steps.names.outputs.suffix}}/index.html)
|
2022-08-23 11:29:26 +00:00
|
|
|
edit-mode: replace
|
2022-12-26 19:33:44 +00:00
|
|
|
|
|
|
|
- name: 'Raise exception'
|
|
|
|
if: ${{ steps.pvs-warn.outputs.warnings != 0 }}
|
|
|
|
run: |
|
|
|
|
echo "Please fix all PVS varnings before merge"
|
|
|
|
exit 1
|
|
|
|
|