ci: combine lint-clang and lint-error into lint-check
This commit is contained in:
parent
d9727e60bc
commit
8b25e11f81
3 changed files with 20 additions and 41 deletions
|
|
@ -1,26 +1,21 @@
|
||||||
name: "Lint error"
|
name: "Lint Check"
|
||||||
description: "Checks for lint errors and posts a helpful comment"
|
description: "Checks for lint errors and posts a helpful comment"
|
||||||
|
|
||||||
inputs:
|
|
||||||
format-command:
|
|
||||||
description: "The command to run to fix lint errors"
|
|
||||||
required: true
|
|
||||||
|
|
||||||
format-tool:
|
|
||||||
description: "The name of the linting tool"
|
|
||||||
required: true
|
|
||||||
|
|
||||||
runs:
|
runs:
|
||||||
using: "composite"
|
using: "composite"
|
||||||
steps:
|
steps:
|
||||||
|
- name: Install Dependencies
|
||||||
|
run: pipx install --global clang_format
|
||||||
|
shell: bash
|
||||||
|
|
||||||
- name: Run format command
|
- name: Run format command
|
||||||
run: ${{ inputs.format-command }}
|
run: find src/ -regex '.*\.\(cpp\|hpp\|cc\|cxx\|h\|c\|m\|mm\)' -exec clang-format -style=file --assume-filename=$(pwd)/.clang-format -i {} \;
|
||||||
shell: bash
|
shell: bash
|
||||||
|
|
||||||
- name: Find changes
|
- name: Find changes
|
||||||
id: changes
|
id: changes
|
||||||
run: |
|
run: |
|
||||||
file=${{ inputs.format-tool }}.diff
|
file=clang-format.diff
|
||||||
diff=$(git diff | tee $file)
|
diff=$(git diff | tee $file)
|
||||||
|
|
||||||
if [ -z "$diff" ]; then
|
if [ -z "$diff" ]; then
|
||||||
|
|
@ -43,7 +38,7 @@ runs:
|
||||||
if: steps.changes.outputs.diff
|
if: steps.changes.outputs.diff
|
||||||
uses: actions/upload-artifact@v4
|
uses: actions/upload-artifact@v4
|
||||||
with:
|
with:
|
||||||
name: ${{ inputs.format-tool }}-diff
|
name: clang-format-diff
|
||||||
path: ${{ steps.changes.outputs.file }}
|
path: ${{ steps.changes.outputs.file }}
|
||||||
if-no-files-found: error
|
if-no-files-found: error
|
||||||
|
|
||||||
|
|
@ -54,9 +49,9 @@ runs:
|
||||||
code_block="\`\`\`"
|
code_block="\`\`\`"
|
||||||
|
|
||||||
summary=$(cat<<EOF
|
summary=$(cat<<EOF
|
||||||
❌ \`${{ inputs.format-tool }}\`: It looks like your changes don't match our code style.
|
❌ \`clang-format\`: It looks like your changes don't match our code style.
|
||||||
|
|
||||||
🛠️ Please either run \`${{ inputs.format-command }}\` or apply this patch with \`git apply\`:
|
🛠️ Please either run \`clang-format -i\` on the file or apply this patch with \`git apply\`:
|
||||||
|
|
||||||
[\`${{ steps.changes.outputs.file }}\`](${{ steps.upload.outputs.artifact-url }})
|
[\`${{ steps.changes.outputs.file }}\`](${{ steps.upload.outputs.artifact-url }})
|
||||||
$code_block diff
|
$code_block diff
|
||||||
|
|
@ -67,7 +62,7 @@ runs:
|
||||||
echo "$summary" >> $GITHUB_STEP_SUMMARY
|
echo "$summary" >> $GITHUB_STEP_SUMMARY
|
||||||
|
|
||||||
file="ci_summary.md"
|
file="ci_summary.md"
|
||||||
echo "❌🛠️ \`${{ inputs.format-tool }}\`: Lint errors, fix available." >> $file
|
echo "❌🛠️ \`clang-format\`: Lint errors, fix available." >> $file
|
||||||
echo "file=$file" >> $GITHUB_OUTPUT
|
echo "file=$file" >> $GITHUB_OUTPUT
|
||||||
shell: bash
|
shell: bash
|
||||||
|
|
||||||
|
|
@ -75,7 +70,7 @@ runs:
|
||||||
if: steps.summary.outputs.file
|
if: steps.summary.outputs.file
|
||||||
uses: actions/upload-artifact@v4
|
uses: actions/upload-artifact@v4
|
||||||
with:
|
with:
|
||||||
name: summary-${{ inputs.format-tool }}
|
name: summary-clang-format
|
||||||
path: ${{ steps.summary.outputs.file }}
|
path: ${{ steps.summary.outputs.file }}
|
||||||
if-no-files-found: error
|
if-no-files-found: error
|
||||||
|
|
||||||
16
.github/actions/lint-clang/action.yml
vendored
16
.github/actions/lint-clang/action.yml
vendored
|
|
@ -1,16 +0,0 @@
|
||||||
name: "Lint clang"
|
|
||||||
description: "Lint with Clang formatter"
|
|
||||||
|
|
||||||
runs:
|
|
||||||
using: "composite"
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- name: Install dependencies
|
|
||||||
shell: bash
|
|
||||||
run: pipx install --global clang_format
|
|
||||||
|
|
||||||
- name: Linting with Clang formatter
|
|
||||||
uses: ./.github/actions/lint-error
|
|
||||||
with:
|
|
||||||
format-command: find src/ -regex '.*\.\(cpp\|hpp\|cc\|cxx\|h\|c\|m\|mm\)' -exec clang-format -style=file --assume-filename=$(pwd)/.clang-format -i {} \;
|
|
||||||
format-tool: "clang-format"
|
|
||||||
16
.github/workflows/continuous-integration.yml
vendored
16
.github/workflows/continuous-integration.yml
vendored
|
|
@ -34,7 +34,7 @@ jobs:
|
||||||
# Always run this job, even if not on PR, since other jobs need it.
|
# Always run this job, even if not on PR, since other jobs need it.
|
||||||
pr-comment-flags:
|
pr-comment-flags:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
needs: lint-clang
|
needs: lint-check
|
||||||
|
|
||||||
outputs:
|
outputs:
|
||||||
no-sonar: ${{ steps.check.outputs.no-sonar }}
|
no-sonar: ${{ steps.check.outputs.no-sonar }}
|
||||||
|
|
@ -82,7 +82,7 @@ jobs:
|
||||||
- name: Test summary
|
- name: Test summary
|
||||||
uses: ./.github/actions/test-summary
|
uses: ./.github/actions/test-summary
|
||||||
|
|
||||||
lint-clang:
|
lint-check:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
timeout-minutes: 5
|
timeout-minutes: 5
|
||||||
|
|
||||||
|
|
@ -90,11 +90,11 @@ jobs:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: Linting Clang
|
- name: Lint Checker
|
||||||
uses: ./.github/actions/lint-clang
|
uses: ./.github/actions/lint-check
|
||||||
|
|
||||||
analyse-valgrind:
|
analyse-valgrind:
|
||||||
needs: lint-clang
|
needs: lint-check
|
||||||
if: ${{ github.event_name == 'pull_request' }}
|
if: ${{ github.event_name == 'pull_request' }}
|
||||||
uses: ./.github/workflows/valgrind-analysis.yml
|
uses: ./.github/workflows/valgrind-analysis.yml
|
||||||
|
|
||||||
|
|
@ -106,7 +106,7 @@ jobs:
|
||||||
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
|
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
|
||||||
|
|
||||||
main-build:
|
main-build:
|
||||||
needs: lint-clang
|
needs: lint-check
|
||||||
name: ${{ matrix.target.name }}
|
name: ${{ matrix.target.name }}
|
||||||
runs-on: ${{ matrix.target.runs-on }}
|
runs-on: ${{ matrix.target.runs-on }}
|
||||||
container: ${{ matrix.target.container }}
|
container: ${{ matrix.target.container }}
|
||||||
|
|
@ -242,7 +242,7 @@ jobs:
|
||||||
|
|
||||||
# Technically, "unix" is a misnomer, but we use it here to mean "Unix-like BSD-derived".
|
# Technically, "unix" is a misnomer, but we use it here to mean "Unix-like BSD-derived".
|
||||||
unix:
|
unix:
|
||||||
needs: lint-clang
|
needs: lint-check
|
||||||
name: unix-${{ matrix.distro.name }}
|
name: unix-${{ matrix.distro.name }}
|
||||||
runs-on: ${{ vars.CI_UNIX_RUNNER || 'ubuntu-24.04' }}
|
runs-on: ${{ vars.CI_UNIX_RUNNER || 'ubuntu-24.04' }}
|
||||||
timeout-minutes: 20
|
timeout-minutes: 20
|
||||||
|
|
@ -275,7 +275,7 @@ jobs:
|
||||||
./build/bin/unittests
|
./build/bin/unittests
|
||||||
./build/bin/integtests || true
|
./build/bin/integtests || true
|
||||||
flatpak:
|
flatpak:
|
||||||
needs: lint-clang
|
needs: lint-check
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
container:
|
container:
|
||||||
image: bilelmoussaoui/flatpak-github-actions:kde-6.7
|
image: bilelmoussaoui/flatpak-github-actions:kde-6.7
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue