Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions .github/file-filters.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,25 @@ run_api_stability_for_prs: &run_api_stability_for_prs # API-related code
- "sdk_api.json"
- "sdk_api_v9.json"

run_lint_clang_formatting_for_prs: &run_lint_clang_formatting_for_prs
- "**/*.h"
- "**/*.hpp"
- "**/*.c"
- "**/*.cpp"
- "**/*.m"
- "**/*.mm"

# GH Actions
- ".github/workflows/lint-clang-formatting.yml"
- ".github/file-filters.yml"

# Formatting
- ".clang-format"
# Other
- "Makefile" # Make commands used for formatting setup
- "Brewfile*" # Tools installation affects formatting environment
- "scripts/ci-diagnostics.sh" # CI diagnostics may affect formatting checks

run_objc_conversion_analysis_for_prs: &run_objc_conversion_analysis_for_prs
- "SwiftConversion/**"

Expand Down
59 changes: 35 additions & 24 deletions .github/workflows/lint-clang-formatting.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,32 +4,8 @@ on:
push:
branches:
- main
paths:
- "**/*.h"
- "**/*.hpp"
- "**/*.c"
- "**/*.cpp"
- "**/*.m"
- "**/*.mm"
- ".github/workflows/lint-clang-formatting.yml"
- ".clang-format"
- "Makefile" # Make commands used for formatting setup
- "Brewfile*" # Tools installation affects formatting environment
- "scripts/ci-diagnostics.sh"

pull_request:
paths:
- "**/*.h"
- "**/*.hpp"
- "**/*.c"
- "**/*.cpp"
- "**/*.m"
- "**/*.mm"
- ".github/workflows/lint-clang-formatting.yml"
- ".clang-format"
- "Makefile" # Make commands used for formatting setup
- "Brewfile*" # Tools installation affects formatting environment
- "scripts/ci-diagnostics.sh"

# Concurrency configuration:
# - We use workflow-specific concurrency groups to prevent multiple lint runs on the same code,
Expand All @@ -43,10 +19,27 @@ concurrency:
cancel-in-progress: ${{ github.event_name == 'pull_request' }}

jobs:
files-changed:
name: Detect File Changes
runs-on: ubuntu-latest
outputs:
run_lint_clang_formatting_for_prs: ${{ steps.changes.outputs.run_lint_clang_formatting_for_prs }}
steps:
- uses: actions/checkout@v5
- name: Get changed files
id: changes
uses: dorny/paths-filter@de90cc6fb38fc0963ad72b210f1f284cd68cea36 # v3.0.2
with:
token: ${{ github.token }}
filters: .github/file-filters.yml

lint:
# While ubuntu runners have clang-format preinstalled, they use an older version. We want to use the most recent one,
# that we can easily install locally via brew.
name: Lint
# Run the job only for PRs with related changes or non-PR events.
if: github.event_name != 'pull_request' || needs.files-changed.outputs.run_lint_clang_formatting_for_prs == 'true'
needs: files-changed
runs-on: macos-15
steps:
- uses: actions/checkout@v5
Expand All @@ -70,3 +63,21 @@ jobs:
- name: Run CI Diagnostics
if: failure()
run: ./scripts/ci-diagnostics.sh

lint_clang_formatting-required-check:
needs:
[
files-changed,
lint,
]
name: Lint Clang
# This is necessary since a failed/skipped dependent job would cause this job to be skipped
if: always()
runs-on: ubuntu-latest
steps:
# If any jobs we depend on fails gets cancelled or times out, this job will fail.
# Skipped jobs are not considered failures.
- name: Check for failures
if: contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled')
run: |
echo "One of the clang formatting check jobs has failed." && exit 1
Loading