Style: XSD file fixes and CI linter #2158
Workflow file for this run
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: Lint | |
| permissions: | |
| contents: read | |
| pull-requests: write | |
| on: | |
| pull_request: | |
| types: | |
| - "opened" | |
| - "reopened" | |
| - "synchronize" | |
| - "labeled" | |
| - "unlabeled" | |
| - "edited" | |
| jobs: | |
| commits_check_job: | |
| runs-on: ubuntu-slim | |
| name: DCO Check | |
| steps: | |
| - name: Get PR Commits | |
| id: "get-pr-commits" | |
| uses: tim-actions/get-pr-commits@198af03565609bb4ed924d1260247b4881f09e7d # 26 Feb 2024 | |
| with: | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| - name: DCO Check | |
| uses: tim-actions/dco@f2279e6e62d5a7d9115b0cb8e837b777b1b02e21 # 10 Jun 2021 | |
| with: | |
| commits: ${{ steps.get-pr-commits.outputs.commits }} | |
| license_check: | |
| runs-on: ubuntu-slim | |
| name: License Check | |
| steps: | |
| - uses: actions/checkout@v6 | |
| with: | |
| fetch-depth: 0 | |
| - name: license check | |
| run: | | |
| python3 ${{ github.workspace }}/.github/workflows/ext/check_license.py --path=${{ github.workspace }} | tee missing_licenses.txt | |
| if [ -s missing_licenses.txt ]; then exit 1; fi | |
| pr_title_check: | |
| runs-on: ubuntu-slim | |
| name: PR Title Check | |
| steps: | |
| - uses: actions/checkout@v6 | |
| with: | |
| fetch-depth: 0 | |
| - name: pr title check | |
| env: | |
| PR_TITLE: ${{ github.event.pull_request.title }} | |
| run: | | |
| python3 ${{ github.workspace }}/.github/workflows/ext/check_pr_title.py | |
| check_mem_sorting: | |
| runs-on: ubuntu-slim | |
| name: Check .mem files sorting | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v6 | |
| - name: Check alphabetical order in .mem files | |
| run: | | |
| #!/usr/bin/env bash | |
| set -euo pipefail | |
| echo "Checking all .mem files in src/ for sorted order..." | |
| # Find all .mem files recursively under src/ | |
| files=$(find src -type f -name "*.mem") | |
| # Track whether we find any unsorted files | |
| unsorted=0 | |
| for f in $files; do | |
| # Compare file with its sorted version | |
| if ! diff -q <(sort "$f") "$f" > /dev/null; then | |
| echo "❌ File not sorted alphabetically: $f" | |
| echo " To fix, run: sort -o $f $f" | |
| unsorted=1 | |
| fi | |
| done | |
| if [ "$unsorted" -eq 1 ]; then | |
| echo | |
| echo "Some .mem files are not sorted alphabetically." | |
| exit 1 | |
| fi | |
| echo "✅ All .mem files are sorted." | |
| xsd_schema_check: | |
| runs-on: ubuntu-slim | |
| name: XSD Schema Check | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v6 | |
| - name: Install xmllint | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y --no-install-recommends libxml2-utils | |
| - name: Validate XSD schemas with xmllint | |
| run: | | |
| #!/usr/bin/env bash | |
| set -euo pipefail | |
| echo "Validating all .xsd files under src/ with xmllint..." | |
| # Find all XSD schemas tracked in the source tree. | |
| files=$(find src -type f -name "*.xsd" | sort) | |
| if [ -z "$files" ]; then | |
| echo "No .xsd files found under src/." | |
| exit 0 | |
| fi | |
| failed=0 | |
| for f in $files; do | |
| echo "→ $f" | |
| # 1. Well-formedness: the file must be valid XML. | |
| if ! xmllint --noout "$f"; then | |
| echo "❌ Not well-formed XML: $f" | |
| failed=1 | |
| continue | |
| fi | |
| # 2. Schema validity: compile the file as an XML Schema. Loading it | |
| # via --schema forces libxml2 to compile the schema, surfacing | |
| # structural XSD errors (unknown types, dangling refs, etc.). The | |
| # file is passed as its own instance document only because | |
| # xmllint requires one; the instance result is irrelevant, so we | |
| # key on schema *compilation* failures alone. | |
| out=$(xmllint --noout --schema "$f" "$f" 2>&1 || true) | |
| if echo "$out" | grep -Eq "parser error|failed to compile"; then | |
| echo "❌ Invalid XML Schema: $f" | |
| echo "$out" | grep -E "parser error|failed to compile" || true | |
| failed=1 | |
| fi | |
| done | |
| if [ "$failed" -ne 0 ]; then | |
| echo | |
| echo "Some XSD schemas failed validation." | |
| exit 1 | |
| fi | |
| echo "✅ All XSD schemas are well-formed and valid." | |
| cpp_formatting_check: | |
| name: C++ Formatting Check | |
| runs-on: ubuntu-26.04 | |
| steps: | |
| - uses: actions/checkout@v6 | |
| with: | |
| fetch-depth: 0 | |
| - name: clang-format style check | |
| id: format-check | |
| run: | | |
| git clang-format-21 --diff -q origin/main | tee clang_format.patch | |
| if [ -s clang_format.patch ]; then | |
| echo "" | |
| echo "clang-format check failed. A patch file with the required" | |
| echo "formatting fixes has been uploaded as a build artifact." | |
| echo "Download 'clang-format-patch' from this workflow run and apply it with:" | |
| echo "" | |
| echo " git apply clang_format.patch" | |
| echo "" | |
| exit 1 | |
| fi | |
| - name: Upload formatting patch | |
| if: failure() && steps.format-check.outcome == 'failure' | |
| uses: actions/upload-artifact@v5 | |
| with: | |
| name: clang-format-patch | |
| path: clang_format.patch | |
| python_formatting_check: | |
| # There might be differences how the formatter refactors the code locally | |
| # and in the CI. If there is a problem with CI formatter mismatch, consider | |
| # wrapping a troublesome python code with comments: | |
| # "# fmt: off" | |
| # "<Python code we don't want to format>" | |
| # "# fmt: on" | |
| name: Python Formatting Check | |
| runs-on: ubuntu-slim | |
| steps: | |
| - uses: actions/checkout@v6 | |
| with: | |
| fetch-depth: 0 | |
| - uses: actions/setup-python@v6 | |
| - name: ruff style check | |
| id: format-check | |
| run: | | |
| pip3 install ruff | |
| ruff format . | |
| git diff | tee ruff_format.patch | |
| if [ -s ruff_format.patch ]; then | |
| echo "" | |
| echo "ruff format check failed. A patch file with the required" | |
| echo "formatting fixes has been uploaded as a build artifact." | |
| echo "Download 'ruff-format-patch' from this workflow run and apply it with:" | |
| echo "" | |
| echo " git apply ruff_format.patch" | |
| echo "" | |
| exit 1 | |
| fi | |
| - name: Upload formatting patch | |
| if: failure() && steps.format-check.outcome == 'failure' | |
| uses: actions/upload-artifact@v5 | |
| with: | |
| name: ruff-format-patch | |
| path: ruff_format.patch | |
| python_linter_check: | |
| name: Python Linter Check | |
| runs-on: ubuntu-slim | |
| steps: | |
| - uses: actions/checkout@v6 | |
| with: | |
| fetch-depth: 0 | |
| - uses: actions/setup-python@v6 | |
| with: | |
| python-version: '3.12.4' | |
| - name: Install dependencies | |
| run: | | |
| pip3 install -r ${{ github.workspace }}/src/python/requirements-test.txt | |
| pip3 install pylint lint-diffs | |
| ln -s ${{ github.workspace }}/src/python/pylintrc ${{ github.workspace }}/.pylintrc | |
| echo [pylint] > ${{ github.workspace }}/.lint-diffs | |
| echo extensions=.py >> ${{ github.workspace }}/.lint-diffs | |
| echo [clang-tidy] >> ${{ github.workspace }}/.lint-diffs | |
| echo extensions= >> ${{ github.workspace }}/.lint-diffs | |
| echo [rubocop] >> ${{ github.workspace }}/.lint-diffs | |
| echo extensions= >> ${{ github.workspace }}/.lint-diffs | |
| - name: Check the whole repo with pylint | |
| run: | | |
| export PYTHONPATH=${{ github.workspace }}/src/python:$PYTHONPATH | |
| pylint -j 8 src || true | |
| - name: Check the PR with pylint | |
| run: | | |
| export PYTHONPATH=${{ github.workspace }}/src/python:$PYTHONPATH | |
| git diff -U0 origin/main | lint-diffs | |
| configure_ubuntu: | |
| name: "Configure [ubuntu]" | |
| uses: ./.github/workflows/build-ubuntu.yaml | |
| with: | |
| ref: ${{ github.sha }} | |
| name: "configure-ubuntu" | |
| target: "" | |
| save_build_as_artifacts: true | |
| run_unit_tests: false | |
| cxx_standard: cpp23 | |
| cpp_linter_check: | |
| name: C++ Linter Check | |
| needs: configure_ubuntu | |
| runs-on: ubuntu-slim | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - uses: actions/download-artifact@v5 | |
| with: | |
| name: ${{ needs.configure_ubuntu.outputs.artifact_key }} | |
| - uses: cpp-linter/cpp-linter-action@77c390c5ba9c947ebc185a3e49cc754f1558abb5 | |
| id: linter | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| with: | |
| style: '' # Disable clang-format checks | |
| tidy-checks: '' # Use .clang-tidy config file | |
| thread-comments: update | |
| lines-changed-only: diff | |
| version: '21' | |
| database: build/blazingmq | |
| ignore: '.github|src/standalones/s_bmqfuzz' | |
| continue-on-error: true |