Skip to content

New SonarCloud action code. #56

New SonarCloud action code.

New SonarCloud action code. #56

Workflow file for this run

name: Codacy Clang-Tidy
on:
push:
branches:
- main
pull_request:
types: [opened, synchronize, reopened]
jobs:
build:
name: Build
runs-on: ubuntu-latest
env:
CCT_VERSION: 1.3.2
CCT: codacy-clang-tidy-linux-1.3.2
CODACY_URL: https://api.codacy.com
# The path for clang-tidy output.
CLANG_TIDY_OUT: /tmp/clang-tidy-out
# The path for codacy-clang-tidy output.
CCT_OUT: /tmp/cct-out
steps:
- uses: actions/checkout@v3
with:
submodules: 'True'
- name: Download the codacy-clang-tidy tool
env:
CCT_DOWNLOAD_URL: https://github.com/codacy/codacy-clang-tidy/releases/download/${{ env.CCT_VERSION }}/${{ env.CCT }}
run: |
mkdir -p "$HOME/cct"
curl -L "${{ env.CCT_DOWNLOAD_URL }}" -o "$HOME/cct/${{ env.CCT }}"
chmod +x "$HOME/cct/${{ env.CCT }}"
- name: Configure
run: |
cmake -S . \
-B build \
-D CMAKE_EXPORT_COMPILE_COMMANDS=Yes \
-D CMAKE_C_COMPILER=clang-12 \
-D CMAKE_CXX_COMPILER=clang++-12
- name: Run clang-tidy
run: |
clang-tidy-12 -extra-arg=-std=c++17 \
-extra-arg=-DNDEBUG \
-p=build/compile_commands.json \
./*.?pp \
> "${{ env.CLANG_TIDY_OUT }}"
# Convert the clang-tidy output to a format that the Codacy API accepts
- name: Run codacy-clang-tidy
run: |
"$HOME/cct/${{ env.CCT }}" < "${{ env.CLANG_TIDY_OUT }}" > "${{ env.CCT_OUT }}"
- name: Upload to the Codacy server
run: |
COMMIT=$(git rev-parse HEAD)
# Send the results to Codacy
curl -XPOST \
-L \
-H "project-token: ${{ secrets.CODACY_PROJECT_TOKEN }}" \
-H "Content-type: application/json" \
-d "@${{ env.CCT_OUT }}" \
"${{ env.CODACY_URL }}/2.0/commit/${COMMIT}/issuesRemoteResults"
# Signal that Codacy can use the sent results and start a new analysis
curl -XPOST \
-L \
-H "project-token: ${{ secrets.CODACY_PROJECT_TOKEN }}" \
-H "Content-type: application/json" \
"${{ env.CODACY_URL }}/2.0/commit/${COMMIT}/resultsFinal"