| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
|
|
| |
|
|
| name: Lint |
|
|
| on: |
| workflow_call: |
| inputs: |
| artifactBasename: |
| type: string |
| required: true |
| changedFiles: |
| type: string |
| required: true |
| changedLines: |
| type: string |
| required: false |
| changedCppFiles: |
| type: string |
| required: true |
| changedCppLines: |
| type: string |
| required: false |
| changedPythonFiles: |
| type: string |
| required: true |
| changedPythonLines: |
| type: string |
| required: false |
| checkLineendings: |
| default: false |
| type: boolean |
| required: false |
| lineendingsFailSilent: |
| default: true |
| type: boolean |
| required: false |
| checkWhitespace: |
| default: true |
| type: boolean |
| required: false |
| whitespaceFailSilent: |
| default: true |
| type: boolean |
| required: false |
| checkTabs: |
| default: true |
| type: boolean |
| required: false |
| tabsFailSilent: |
| default: true |
| type: boolean |
| required: false |
| checkQtConnections: |
| default: true |
| type: boolean |
| required: false |
| qtConnectionsFailSilent: |
| default: true |
| type: boolean |
| required: false |
| checkCpplint: |
| default: true |
| type: boolean |
| required: false |
| cpplintFailSilent: |
| default: true |
| type: boolean |
| required: false |
| checkPylint: |
| default: true |
| type: boolean |
| required: false |
| pylintDisable: |
| default: C0302,C0303 |
| type: string |
| required: false |
| pylintFailSilent: |
| default: true |
| type: boolean |
| required: false |
| checkBlack: |
| default: true |
| type: boolean |
| required: false |
| blackFailSilent: |
| default: true |
| type: boolean |
| required: false |
| checkClangFormat: |
| default: false |
| type: boolean |
| required: false |
| clangStyle: |
| default: file |
| type: string |
| required: false |
| clangFormatFailSilent: |
| default: true |
| type: boolean |
| required: false |
| checkSpelling: |
| default: true |
| type: boolean |
| required: false |
| listIgnoredMisspelling: |
| default: .github/codespellignore |
| type: string |
| required: false |
| spellingIgnore: |
| default: ./.git*,*.po,*.ts,*.svg,./src/3rdParty,./src/Base/swig*,./src/Mod/Robot/App/kdl_cp,./src/Mod/Import/App/SCL*,./src/Doc/FreeCAD.uml,./build/ |
| type: string |
| required: false |
| codespellFailSilent: |
| default: true |
| type: boolean |
| required: false |
| checkClangTidy: |
| default: true |
| type: boolean |
| required: false |
| clangTidyFailSilent: |
| default: true |
| type: boolean |
| required: false |
| checkClazy: |
| default: false |
| type: boolean |
| required: false |
| clazyChecks: |
| default: level2,no-non-pod-global-static,no-copyable-polymorphic |
| type: string |
| required: false |
| clazyFailSilent: |
| default: true |
| type: boolean |
| required: false |
| checkClazyQT6: |
| default: false |
| type: boolean |
| required: false |
| clazyQT6Checks: |
| default: qt6-deprecated-api-fixes,qt6-header-fixes,qt6-qhash-signature,qt6-fwd-fixes,missing-qobject-macro |
| type: string |
| required: false |
| QT6Branch: |
| default: main |
| type: string |
| required: false |
| clazyQT6FailSilent: |
| default: true |
| type: boolean |
| required: false |
| outputs: |
| reportFile: |
| value: ${{ jobs.Lint.outputs.reportFile }} |
|
|
| permissions: |
| contents: read |
|
|
| jobs: |
|
|
| Lint: |
| if: inputs.changedFiles != '' |
| runs-on: ubuntu-latest |
| env: |
| logdir: /tmp/logs/ |
| fixesdir: /tmp/fixes/ |
| reportdir: /tmp/report/ |
| reportfilename: ${{ inputs.artifactBasename }}-report.md |
| defaults: |
| run: |
| shell: bash |
| outputs: |
| reportFile: ${{ steps.Init.outputs.reportFile }} |
|
|
| steps: |
| - name: Harden the runner (Audit all outbound calls) |
| uses: step-security/harden-runner@df199fb7be9f65074067a9eb93f12bb4c5547cf2 |
| with: |
| egress-policy: audit |
|
|
| - name: Check out code |
| uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 |
| with: |
| submodules: true |
|
|
| - name: Make needed directories, files and initializations |
| id: Init |
| run: | |
| mkdir -p ${{ env.logdir }} |
| mkdir -p ${{ env.fixesdir }} |
| mkdir -p ${{ env.reportdir }} |
| echo "reportFile=${{ env.reportfilename }}" >> $GITHUB_OUTPUT |
| |
| |
| - name: Check File Case Sensitivity |
| uses: credfeto/action-case-checker@cb652aeab29ed363bbdb7d9ee1bfcc010c46cac5 |
|
|
| - name: Check for non Unix line ending |
| if: inputs.checkLineendings && always() |
| continue-on-error: ${{ inputs.lineendingsFailSilent }} |
| run: | |
| python3 tools/lint/generic_checks.py \ |
| --lineendings-check \ |
| --files "${{ inputs.changedFiles }}" \ |
| --report-file "${{ env.reportdir }}${{ env.reportfilename }}" \ |
| --log-dir "${{ env.logdir }}" |
| |
| - name: Check for trailing whitespaces |
| if: inputs.checkWhitespace && always() |
| continue-on-error: ${{ inputs.whitespaceFailSilent }} |
| run: | |
| python3 tools/lint/generic_checks.py \ |
| --whitespace-check \ |
| --files "${{ inputs.changedFiles }}" \ |
| --report-file "${{ env.reportdir }}${{ env.reportfilename }}" \ |
| --log-dir "${{ env.logdir }}" |
| |
| - name: Check for Tab usage |
| if: inputs.checkTabs && always() |
| continue-on-error: ${{ inputs.tabsFailSilent }} |
| run: | |
| python3 tools/lint/generic_checks.py \ |
| --tabs-check \ |
| --files "${{ inputs.changedFiles }}" \ |
| --report-file "${{ env.reportdir }}${{ env.reportfilename }}" \ |
| --log-dir "${{ env.logdir }}" |
| |
| |
|
|
| - name: Pylint |
| if: inputs.checkPylint && inputs.changedPythonFiles != '' && always() |
| continue-on-error: ${{ inputs.pylintFailSilent }} |
| run: | |
| python3 tools/lint/pylint.py \ |
| --files "${{ inputs.changedPythonFiles }}" \ |
| --disable "${{ inputs.pylintDisable }}" \ |
| --log-dir "${{ env.logdir }}" \ |
| --report-file "${{ env.reportdir }}${{ env.reportfilename }}" |
| |
| - name: Black |
| if: inputs.checkBlack && inputs.changedPythonFiles != '' && always() |
| continue-on-error: ${{ inputs.blackFailSilent }} |
| run: | |
| python3 tools/lint/black.py \ |
| --files "${{ inputs.changedPythonFiles }}" \ |
| --log-dir "${{ env.logdir }}" \ |
| --report-file "${{ env.reportdir }}${{ env.reportfilename }}" |
| |
| |
|
|
| - name: Install FreeCAD dependencies |
| if: inputs.changedCppFiles != '' && always() |
| run: ./package/ubuntu/install-apt-packages.sh |
|
|
| - name: Run CMake |
| if: inputs.changedCppFiles != '' && always() |
| run: | |
| mkdir build && cmake -S ./ -B ./build/ -D CMAKE_EXPORT_COMPILE_COMMANDS:BOOL=TRUE |
| |
| - name: Check old Qt string-based connections (https://wiki.qt.io/New_Signal_Slot_Syntax) |
| if: inputs.checkQtConnections && inputs.changedCppFiles != '' && always() |
| continue-on-error: ${{ inputs.qtConnectionsFailSilent }} |
| run: | |
| python3 tools/lint/qt_connections.py \ |
| --files "${{ inputs.changedFiles }}" \ |
| --log-dir "${{ env.logdir }}" \ |
| --report-file "${{ env.reportdir }}${{ env.reportfilename }}" |
| |
| - name: Cpplint |
| if: inputs.checkCpplint && inputs.changedCppFiles != '' && always() |
| continue-on-error: ${{ inputs.cpplintFailSilent }} |
| run: | |
| python3 tools/lint/cpplint.py \ |
| --files "${{ inputs.changedCppFiles }}" \ |
| --log-dir "${{ env.logdir }}" \ |
| --report-file "${{ env.reportdir }}${{ env.reportfilename }}" |
| |
| - name: Clang-format |
| if: inputs.checkClangFormat && inputs.changedCppFiles != '' && always() |
| continue-on-error: ${{ inputs.clangFormatFailSilent }} |
| run: | |
| python3 tools/lint/clang_format.py \ |
| --files "${{ inputs.changedCppFiles }}" \ |
| --clang-style "${{ inputs.clangStyle }}" \ |
| --log-dir "${{ env.logdir }}" \ |
| --report-file "${{ env.reportdir }}${{ env.reportfilename }}" |
| |
| - name: Codespell |
| if: inputs.checkSpelling && always() |
| continue-on-error: ${{ inputs.codespellFailSilent }} |
| run: | |
| python3 tools/lint/codespell.py \ |
| --files ${{ inputs.changedFiles }} \ |
| --ignore-words "${{ inputs.listIgnoredMisspelling }}" \ |
| --skip "${{ inputs.spellingIgnore }}" \ |
| --log-dir "${{ env.logdir }}" \ |
| --report-file "${{ env.reportdir }}${{ env.reportfilename }}" |
| |
| - name: Clang-tidy |
| if: inputs.checkClangTidy && inputs.changedCppFiles != '' && always() |
| continue-on-error: ${{ inputs.clangTidyFailSilent }} |
| run: | |
| python3 tools/lint/clang_tidy.py \ |
| --files "${{ inputs.changedCppFiles }}" \ |
| --line-filter '${{ inputs.changedCppLines }}' \ |
| --clang-style "${{ inputs.clangStyle }}" \ |
| --log-dir "${{ env.logdir }}" \ |
| --report-file "${{ env.reportdir }}${{ env.reportfilename }}" |
| |
| - name: Clazy |
| if: inputs.checkClazy && inputs.changedCppFiles != '' && always() |
| continue-on-error: ${{ inputs.clazyFailSilent }} |
| run: | |
| python3 tools/lint/clazy.py \ |
| --files "${{ inputs.changedCppFiles }}" \ |
| --clazy-checks "${{ inputs.clazyChecks }}" \ |
| --log-dir "${{ env.logdir }}" \ |
| --report-file "${{ env.reportdir }}${{ env.reportfilename }}" |
| |
| - name: Clazy-QT6 |
| if: inputs.checkClazyQT6 && inputs.changedCppFiles != '' && github.ref == inputs.QT6Branch && always() |
| continue-on-error: ${{ inputs.clazyQT6FailSilent }} |
| run: | |
| python3 tools/lint/clazy_qt6.py \ |
| --files "${{ inputs.changedCppFiles }}" \ |
| --clazy-qt6-checks "${{ inputs.clazyQT6Checks }}" \ |
| --log-dir "${{ env.logdir }}" \ |
| --report-file "${{ env.reportdir }}${{ env.reportfilename }}" |
| |
| |
|
|
| - name: Upload logs and fixes |
| if: always() |
| uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 |
| with: |
| name: ${{ inputs.artifactBasename }}-Logs |
| path: | |
| ${{ env.logdir }} |
| ${{ env.fixesdir }} |
| |
| - name: Upload report |
| if: always() |
| uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 |
| with: |
| name: ${{ env.reportfilename }} |
| path: | |
| ${{env.reportdir}}${{ env.reportfilename }} |
| |