simulate clang-format error with auto-correct #18
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: scan-provider-agents | |
| on: | |
| pull_request: | |
| paths: | |
| - 'cvmassistants/secretprovider/secret-provider-agent/src/secret_provider_agent.c' | |
| - 'cvmassistants/keyprovider/key-provider-agent/src/key_provider_agent.c' | |
| push: | |
| branches: | |
| - test-scan-provider-agents-ci | |
| paths: | |
| - 'cvmassistants/secretprovider/secret-provider-agent/src/secret_provider_agent.c' | |
| - 'cvmassistants/keyprovider/key-provider-agent/src/key_provider_agent.c' | |
| workflow_dispatch: {} | |
| jobs: | |
| scan-provider-agents: | |
| name: Scan ${{ matrix.provider-agent.file }} | |
| runs-on: ubuntu-latest | |
| strategy: | |
| matrix: | |
| provider-agent: | |
| - dir: cvmassistants/secretprovider/secret-provider-agent/src | |
| file: secret_provider_agent.c | |
| - dir: cvmassistants/keyprovider/key-provider-agent/src | |
| file: key_provider_agent.c | |
| permissions: | |
| security-events: write | |
| contents: read | |
| actions: read | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Install cppcheck | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y cppcheck | |
| - name: Check if file changed | |
| id: changed | |
| uses: tj-actions/changed-files@v47 | |
| with: | |
| files: ${{ matrix.provider-agent.dir }}/${{ matrix.provider-agent.file }} | |
| - name: clang-format scan ${{ matrix.provider-agent.file }} | |
| if: steps.changed.outputs.any_changed == 'true' || github.event_name == 'workflow_dispatch' | |
| uses: DoozyX/[email protected] | |
| with: | |
| source: ${{ matrix.provider-agent.dir }}/${{ matrix.provider-agent.file }} | |
| style: llvm | |
| inplace: True | |
| - uses: EndBug/add-and-commit@v9 | |
| with: | |
| author_name: Clang Robot | |
| author_email: [email protected] | |
| message: 'Committing clang-format changes' | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - name: cppcheck scan ${{ matrix.provider-agent.file }} (SARIF) | |
| if: steps.changed.outputs.any_changed == 'true' || github.event_name == 'workflow_dispatch' | |
| working-directory: ${{ matrix.provider-agent.dir }} | |
| run: | | |
| cppcheck --enable=all --suppress=missingIncludeSystem --xml --output-file=report.xml ${{ matrix.provider-agent.file }} | |
| - name: Convert cppcheck XML → SARIF | |
| if: steps.changed.outputs.any_changed == 'true' || github.event_name == 'workflow_dispatch' | |
| uses: Flast/cppcheck-sarif@v2 | |
| with: | |
| input: ${{ matrix.provider-agent.dir }}/report.xml | |
| output: ${{ matrix.provider-agent.dir }}/report.sarif | |
| - name: Upload SARIF to GitHub Code Scanning | |
| if: steps.changed.outputs.any_changed == 'true' || github.event_name == 'workflow_dispatch' | |
| uses: github/codeql-action/upload-sarif@v4 | |
| with: | |
| sarif_file: ${{ matrix.provider-agent.dir }}/report.sarif | |
| category: cppcheck |