From 363f970da809f4b140c6859f6dc98bc8653ec1b5 Mon Sep 17 00:00:00 2001 From: feihongxu0824 Date: Wed, 18 Mar 2026 16:16:49 +0800 Subject: [PATCH] chore: android ci needs lint first (#240) --- .github/workflows/01-ci-pipeline.yml | 55 +++++++++++ .github/workflows/02-lint-check.yml | 52 +++++++++++ .../{main.yml => 03-macos-linux-build.yml} | 91 ++++--------------- ...android_build.yml => 04-android-build.yml} | 17 +--- 4 files changed, 125 insertions(+), 90 deletions(-) create mode 100644 .github/workflows/01-ci-pipeline.yml create mode 100644 .github/workflows/02-lint-check.yml rename .github/workflows/{main.yml => 03-macos-linux-build.yml} (51%) rename .github/workflows/{android_build.yml => 04-android-build.yml} (94%) diff --git a/.github/workflows/01-ci-pipeline.yml b/.github/workflows/01-ci-pipeline.yml new file mode 100644 index 0000000..290b9c8 --- /dev/null +++ b/.github/workflows/01-ci-pipeline.yml @@ -0,0 +1,55 @@ +name: Main + +on: + push: + branches: [ "main" ] + paths-ignore: + - '**.md' + merge_group: + pull_request: + branches: [ "main" ] + paths-ignore: + - '**.md' + workflow_dispatch: + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }}-${{ github.head_ref || '' }}-${{ github.base_ref || '' }}-${{ github.ref != 'refs/heads/main' || github.sha }} + cancel-in-progress: true + +permissions: + contents: read + +jobs: + # Code quality checks (fast, run first) + lint: + uses: ./.github/workflows/02-lint-check.yml + + # Main build and test matrix + build-and-test-macos-arm64: + name: Build & Test (macos-arm64) + needs: lint + uses: ./.github/workflows/03-macos-linux-build.yml + with: + platform: macos-arm64 + os: macos-15 + + build-and-test-linux-arm64: + name: Build & Test (linux-arm64) + needs: lint + uses: ./.github/workflows/03-macos-linux-build.yml + with: + platform: linux-arm64 + os: ubuntu-24.04-arm + + build-and-test-linux-x64: + name: Build & Test (linux-x64) + needs: lint + uses: ./.github/workflows/03-macos-linux-build.yml + with: + platform: linux-x64 + os: ubuntu-24.04 + + build-android: + name: Build & Test (android) + needs: lint + uses: ./.github/workflows/04-android-build.yml diff --git a/.github/workflows/02-lint-check.yml b/.github/workflows/02-lint-check.yml new file mode 100644 index 0000000..4f9076c --- /dev/null +++ b/.github/workflows/02-lint-check.yml @@ -0,0 +1,52 @@ +name: Lint + +on: + workflow_call: + +jobs: + lint: + name: Code Quality Checks + runs-on: ubuntu-24.04 + steps: + - name: Checkout code + uses: actions/checkout@v6 + + - name: Set up Python + uses: actions/setup-python@v6 + with: + python-version: '3.10' + cache: 'pip' + cache-dependency-path: 'pyproject.toml' + + - name: Install linting tools + run: | + python -m pip install --upgrade pip \ + ruff==v0.14.4 \ + clang-format==18.1.8 + shell: bash + + - name: Run Ruff Linter + run: python -m ruff check . + shell: bash + + - name: Run Ruff Formatter Check + run: python -m ruff format --check . + shell: bash + + - name: Run clang-format Check + run: | + CPP_FILES=$(find . -type f \( -name "*.cpp" -o -name "*.h" -o -name "*.hpp" -o -name "*.cc" -o -name "*.cxx" \) \ + ! -path "./build/*" \ + ! -path "./tests/*" \ + ! -path "./scripts/*" \ + ! -path "./python/*" \ + ! -path "./thirdparty/*" \ + ! -path "./.git/*") + + if [ -z "$CPP_FILES" ]; then + echo "No C++ files found to check." + exit 0 + fi + + clang-format --dry-run --Werror $CPP_FILES + shell: bash diff --git a/.github/workflows/main.yml b/.github/workflows/03-macos-linux-build.yml similarity index 51% rename from .github/workflows/main.yml rename to .github/workflows/03-macos-linux-build.yml index abfd4d7..9ec52cc 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/03-macos-linux-build.yml @@ -1,92 +1,33 @@ -name: Main +name: MacOS & Linux Build on: - push: - branches: [ "main" ] - paths-ignore: - - '**.md' - merge_group: - pull_request: - branches: [ "main" ] - paths-ignore: - - '**.md' - workflow_dispatch: - -concurrency: - group: ${{ github.workflow }}-${{ github.ref }}-${{ github.head_ref || '' }}-${{ github.base_ref || '' }}-${{ github.ref != 'refs/heads/main' || github.sha }} - cancel-in-progress: true + workflow_call: + inputs: + platform: + description: 'Platform identifier' + required: true + type: string + os: + description: 'GitHub Actions runner OS' + required: true + type: string permissions: contents: read jobs: - # Code quality checks (fast, run first) - lint: - name: Code Quality Checks - runs-on: ubuntu-24.04 - steps: - - name: Checkout code - uses: actions/checkout@v6 - - - name: Set up Python - uses: actions/setup-python@v6 - with: - python-version: '3.10' - cache: 'pip' - cache-dependency-path: 'pyproject.toml' - - - name: Install linting tools - run: | - python -m pip install --upgrade pip \ - ruff==v0.14.4 \ - clang-format==18.1.8 - shell: bash - - - name: Run Ruff Linter - run: python -m ruff check . - shell: bash - - - name: Run Ruff Formatter Check - run: python -m ruff format --check . - shell: bash - - - name: Run clang-format Check - run: | - CPP_FILES=$(find . -type f \( -name "*.cpp" -o -name "*.h" -o -name "*.hpp" -o -name "*.cc" -o -name "*.cxx" \) \ - ! -path "./build/*" \ - ! -path "./tests/*" \ - ! -path "./scripts/*" \ - ! -path "./python/*" \ - ! -path "./thirdparty/*" \ - ! -path "./.git/*") - - if [ -z "$CPP_FILES" ]; then - echo "No C++ files found to check." - exit 0 - fi - - clang-format --dry-run --Werror $CPP_FILES - shell: bash - # Build and test matrix (parallel execution) build-and-test: - name: Build & Test (${{ matrix.platform }}) - needs: lint - runs-on: ${{ matrix.os }} + name: Build & Test (${{ inputs.platform }}) + runs-on: ${{ inputs.os }} strategy: fail-fast: false matrix: include: - - os: macos-15 - platform: macos-arm64 - arch_flag: "" # ARM64 uses auto-detection - - os: ubuntu-24.04-arm - platform: linux-arm64 - arch_flag: "" # ARM64 uses auto-detection - - os: ubuntu-24.04 - platform: linux-x64 - arch_flag: "" # Use native CPU microarchitecture + - os: ${{ inputs.os }} + platform: ${{ inputs.platform }} + arch_flag: "" # Use appropriate architecture steps: - name: Checkout code diff --git a/.github/workflows/android_build.yml b/.github/workflows/04-android-build.yml similarity index 94% rename from .github/workflows/android_build.yml rename to .github/workflows/04-android-build.yml index 099d486..5ee6fe3 100644 --- a/.github/workflows/android_build.yml +++ b/.github/workflows/04-android-build.yml @@ -1,20 +1,7 @@ -name: android-cross-build +name: Android Cross Build on: - push: - branches: [ "main" ] - paths-ignore: - - '**.md' - merge_group: - pull_request: - branches: [ "main" ] - paths-ignore: - - '**.md' - workflow_dispatch: - -concurrency: - group: ${{ github.workflow }}-${{ github.ref }}-${{ github.head_ref || '' }}-${{ github.base_ref || '' }}-${{ github.ref != 'refs/heads/main' || github.sha }} - cancel-in-progress: true + workflow_call: permissions: contents: read