Skip to content

Commit 11cec3f

Browse files
Unified CI workflow for smarter PR gating (#148)
1 parent 07b3a20 commit 11cec3f

10 files changed

Lines changed: 527 additions & 332 deletions

File tree

‎.github/workflows/builds.yml‎

Lines changed: 117 additions & 191 deletions
Large diffs are not rendered by default.

‎.github/workflows/ci.yml‎

Lines changed: 138 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,138 @@
1+
name: CI
2+
3+
on:
4+
workflow_dispatch:
5+
pull_request:
6+
types: [opened, reopened, synchronize, ready_for_review]
7+
branches: ["main"]
8+
push:
9+
branches: ["main"]
10+
11+
permissions:
12+
contents: read
13+
actions: read
14+
packages: read
15+
16+
jobs:
17+
# Compute once which path groups changed; every other job references these
18+
# outputs. dorny/paths-filter handles PR base diff, push base diff, and
19+
# empty results on non-diff events (workflow_dispatch); the `if:` guards
20+
# below explicitly opt manual runs back into running everything.
21+
changes:
22+
name: Detect Changes
23+
runs-on: ubuntu-latest
24+
outputs:
25+
builds: ${{ steps.filter.outputs.builds }}
26+
tests: ${{ steps.filter.outputs.tests }}
27+
docs: ${{ steps.filter.outputs.docs }}
28+
cpp_checks: ${{ steps.filter.outputs.cpp_checks }}
29+
steps:
30+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
31+
- uses: dorny/paths-filter@fbd0ab8f3e69293af611ebaee6363fc25e6d187d # v4.0.1
32+
id: filter
33+
with:
34+
filters: |
35+
builds:
36+
- src/**
37+
- include/**
38+
- benchmarks/**
39+
- cpp-example-collection
40+
- cpp-example-collection/**
41+
- client-sdk-rust/**
42+
- cmake/**
43+
- docker/**
44+
- CMakeLists.txt
45+
- CMakePresets.json
46+
- build*
47+
- .build*
48+
- vcpkg.json
49+
- .github/workflows/ci.yml
50+
- .github/workflows/builds.yml
51+
tests:
52+
- src/**
53+
- include/**
54+
- client-sdk-rust/**
55+
- cmake/**
56+
- .token_helpers/**
57+
- CMakeLists.txt
58+
- CMakePresets.json
59+
- build*
60+
- .build*
61+
- vcpkg.json
62+
- .github/workflows/ci.yml
63+
- .github/workflows/tests.yml
64+
docs:
65+
- README.md
66+
- include/**
67+
- docs/**
68+
- scripts/generate-docs.sh
69+
- .github/workflows/ci.yml
70+
- .github/workflows/generate-docs.yml
71+
- .github/workflows/publish-docs.yml
72+
- "!AGENTS.md"
73+
cpp_checks:
74+
- src/**
75+
- include/**
76+
- benchmarks/**
77+
- client-sdk-rust/**
78+
- cmake/**
79+
- CMakeLists.txt
80+
- CMakePresets.json
81+
- scripts/clang-format.sh
82+
- scripts/clang-tidy.sh
83+
- .clang-format
84+
- .clang-tidy
85+
- .github/workflows/ci.yml
86+
- .github/workflows/cpp-checks.yml
87+
88+
builds:
89+
name: Builds
90+
needs: changes
91+
if: ${{ needs.changes.outputs.builds == 'true' || github.event_name == 'workflow_dispatch' }}
92+
uses: ./.github/workflows/builds.yml
93+
secrets: inherit
94+
95+
tests:
96+
name: Tests
97+
needs: changes
98+
if: ${{ needs.changes.outputs.tests == 'true' || github.event_name == 'workflow_dispatch' }}
99+
uses: ./.github/workflows/tests.yml
100+
secrets: inherit
101+
102+
# license-check is cheap (seconds) and broad enough that it should run on
103+
# every PR.
104+
license-check:
105+
name: License Check
106+
uses: ./.github/workflows/license_check.yml
107+
108+
cpp-checks:
109+
name: C++ Checks
110+
needs: changes
111+
if: ${{ needs.changes.outputs.cpp_checks == 'true' || github.event_name == 'workflow_dispatch' }}
112+
uses: ./.github/workflows/cpp-checks.yml
113+
114+
generate-docs:
115+
name: Generate Docs
116+
needs: changes
117+
if: ${{ needs.changes.outputs.docs == 'true' || github.event_name == 'workflow_dispatch' }}
118+
uses: ./.github/workflows/generate-docs.yml
119+
120+
# Context: GitHub repository rulesets "required checks" actually need a job name to list.
121+
# This job is an aggregate job
122+
ci:
123+
name: CI
124+
runs-on: ubuntu-latest
125+
# List all the jobs that need to succeed for the CI to pass
126+
needs:
127+
- changes
128+
- builds
129+
- tests
130+
- license-check
131+
- cpp-checks
132+
- generate-docs
133+
if: always()
134+
steps:
135+
- name: Verify required CI jobs
136+
uses: suzuki-shunsuke/required-status-check-action@2b5a46064846b09381852c2c4217e898f639e768 # v0.1.3
137+
with:
138+
needs: ${{ toJson(needs) }}

‎.github/workflows/cpp-checks.yml‎

Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
name: C++ Checks
2+
3+
# Called by top-level ci.yml
4+
on:
5+
workflow_call: {}
6+
workflow_dispatch: {}
7+
8+
permissions:
9+
contents: read
10+
11+
jobs:
12+
clang-format:
13+
name: clang-format
14+
runs-on: ubuntu-latest
15+
continue-on-error: false
16+
17+
steps:
18+
- name: Checkout
19+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
20+
with:
21+
# No submodules: scripts/clang-format.sh only walks our own src/ tree
22+
fetch-depth: 1
23+
24+
- name: Install clang-format 22
25+
run: |
26+
set -eux
27+
# Pin clang-format 22 to match the current macOS Homebrew LLVM
28+
# Ubuntu 24.04's default clang-format ships with LLVM 18
29+
sudo install -m 0755 -d /etc/apt/keyrings
30+
wget -qO- https://apt.llvm.org/llvm-snapshot.gpg.key \
31+
| sudo tee /etc/apt/keyrings/llvm.asc >/dev/null
32+
sudo chmod a+r /etc/apt/keyrings/llvm.asc
33+
codename=$(lsb_release -cs)
34+
echo "deb [signed-by=/etc/apt/keyrings/llvm.asc] http://apt.llvm.org/${codename}/ llvm-toolchain-${codename}-22 main" \
35+
| sudo tee /etc/apt/sources.list.d/llvm-22.list >/dev/null
36+
sudo apt-get update
37+
sudo apt-get install -y clang-format-22
38+
sudo ln -sf /usr/bin/clang-format-22 /usr/local/bin/clang-format
39+
clang-format --version
40+
41+
- name: Run clang-format
42+
env:
43+
FORMAT_BLOB_SHA: ${{ github.event.pull_request.head.sha || github.sha }}
44+
run: ./scripts/clang-format.sh
45+
46+
clang-tidy:
47+
name: clang-tidy
48+
runs-on: ubuntu-latest
49+
continue-on-error: false
50+
51+
steps:
52+
- name: Checkout (with submodules)
53+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
54+
with:
55+
submodules: recursive
56+
fetch-depth: 1
57+
58+
- name: Install dependencies
59+
run: |
60+
set -eux
61+
sudo apt-get update
62+
sudo apt-get install -y \
63+
build-essential cmake ninja-build pkg-config \
64+
llvm-dev libclang-dev clang \
65+
libssl-dev wget ca-certificates gnupg
66+
67+
- name: Install clang-tidy 19 (for ExcludeHeaderFilterRegex support)
68+
run: |
69+
set -eux
70+
# Ubuntu 24.04 apt ships clang-tidy 18, which doesn't understand
71+
# ExcludeHeaderFilterRegex (added in 19). Pull clang-tidy 19 from
72+
# the upstream LLVM apt repository and pin the unversioned names.
73+
sudo install -m 0755 -d /etc/apt/keyrings
74+
wget -qO- https://apt.llvm.org/llvm-snapshot.gpg.key \
75+
| sudo tee /etc/apt/keyrings/llvm.asc >/dev/null
76+
sudo chmod a+r /etc/apt/keyrings/llvm.asc
77+
codename=$(lsb_release -cs)
78+
echo "deb [signed-by=/etc/apt/keyrings/llvm.asc] http://apt.llvm.org/${codename}/ llvm-toolchain-${codename}-19 main" \
79+
| sudo tee /etc/apt/sources.list.d/llvm-19.list >/dev/null
80+
sudo apt-get update
81+
sudo apt-get install -y clang-tidy-19 clang-tools-19
82+
sudo ln -sf /usr/bin/clang-tidy-19 /usr/local/bin/clang-tidy
83+
sudo ln -sf /usr/bin/run-clang-tidy-19 /usr/local/bin/run-clang-tidy
84+
clang-tidy --version
85+
run-clang-tidy --help | head -1 || true
86+
87+
- name: Install Rust (stable)
88+
uses: dtolnay/rust-toolchain@3c5f7ea28cd621ae0bf5283f0e981fb97b8a7af9
89+
with:
90+
toolchain: stable
91+
92+
- name: Set Linux build environment
93+
run: |
94+
echo "CXXFLAGS=-Wno-deprecated-declarations" >> "$GITHUB_ENV"
95+
echo "CFLAGS=-Wno-deprecated-declarations" >> "$GITHUB_ENV"
96+
LLVM_VERSION=$(llvm-config --version | cut -d. -f1)
97+
echo "LIBCLANG_PATH=/usr/lib/llvm-${LLVM_VERSION}/lib" >> "$GITHUB_ENV"
98+
99+
- name: CMake configure
100+
run: cmake --preset linux-release
101+
102+
- name: Generate protobuf headers
103+
run: cmake --build build-release --target livekit_proto
104+
105+
- name: Run clang-tidy
106+
env:
107+
TIDY_BLOB_SHA: ${{ github.event.pull_request.head.sha || github.sha }}
108+
# This script is intended to be run locally and in CI. It will auto-detect
109+
# the GHA environment and add PR annotations and a run summary.
110+
# As of writing all warnings are treateded as errors to avoid tech debt build up
111+
run: ./scripts/clang-tidy.sh --fail-on-warning

‎.github/workflows/docker-images.yml‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,11 @@ on:
1515
- CMakePresets.json
1616
- cmake/**
1717
- data/**
18+
- cpp-example-collection
1819
- docker/Dockerfile.base
1920
- docker/Dockerfile.sdk
21+
- .github/workflows/docker-images.yml
22+
- .github/workflows/docker-validate.yml
2023

2124
permissions:
2225
contents: read
@@ -89,7 +92,7 @@ jobs:
8992
fi
9093
9194
case "${path}" in
92-
docker/Dockerfile.sdk|src/*|include/*|client-sdk-rust/*|cmake/*|data/*|CMakeLists.txt|build.sh|build.cmd|build.h.in|.build-info.json.in|CMakePresets.json)
95+
docker/Dockerfile.sdk|src/*|include/*|client-sdk-rust/*|cmake/*|data/*|cpp-example-collection|CMakeLists.txt|build.sh|build.cmd|build.h.in|.build-info.json.in|CMakePresets.json|.github/workflows/docker-images.yml|.github/workflows/docker-validate.yml)
9396
sdk_changed=true
9497
;;
9598
esac

‎.github/workflows/docker-validate.yml‎

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,6 @@ permissions:
99
contents: read
1010
packages: read
1111

12-
env:
13-
# Pinned commit for cpp-example-collection smoke build (https://github.com/livekit-examples/cpp-example-collection)
14-
CPP_EXAMPLE_COLLECTION_REF: bbf0fdf72dac2239117213475449565686f8c58b
15-
1612
jobs:
1713
validate-x64:
1814
name: Validate Docker image (linux-x64)
@@ -23,6 +19,11 @@ jobs:
2319
github.event.workflow_run.head_branch == 'main'
2420
2521
steps:
22+
- name: Checkout
23+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
24+
with:
25+
fetch-depth: 1
26+
2627
- name: Resolve image name
2728
id: refs
2829
shell: bash
@@ -52,7 +53,8 @@ jobs:
5253
5354
- name: Build cpp-example-collection against installed SDK
5455
run: |
55-
docker run -e CPP_EX_REF="${{ env.CPP_EXAMPLE_COLLECTION_REF }}" --rm "${{ steps.refs.outputs.sdk_image }}" bash -lc '
56+
cpp_ex_ref="$(git rev-parse HEAD:cpp-example-collection)"
57+
docker run -e CPP_EX_REF="${cpp_ex_ref}" --rm "${{ steps.refs.outputs.sdk_image }}" bash -lc '
5658
set -euxo pipefail
5759
git clone https://github.com/livekit-examples/cpp-example-collection.git /tmp/cpp-example-collection
5860
cd /tmp/cpp-example-collection
@@ -71,6 +73,11 @@ jobs:
7173
github.event.workflow_run.head_branch == 'main'
7274
7375
steps:
76+
- name: Checkout
77+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
78+
with:
79+
fetch-depth: 1
80+
7481
- name: Resolve image name
7582
id: refs
7683
shell: bash
@@ -100,7 +107,8 @@ jobs:
100107
101108
- name: Build cpp-example-collection against installed SDK
102109
run: |
103-
docker run -e CPP_EX_REF="${{ env.CPP_EXAMPLE_COLLECTION_REF }}" --rm "${{ steps.refs.outputs.sdk_image }}" bash -lc '
110+
cpp_ex_ref="$(git rev-parse HEAD:cpp-example-collection)"
111+
docker run -e CPP_EX_REF="${cpp_ex_ref}" --rm "${{ steps.refs.outputs.sdk_image }}" bash -lc '
104112
set -euxo pipefail
105113
git clone https://github.com/livekit-examples/cpp-example-collection.git /tmp/cpp-example-collection
106114
cd /tmp/cpp-example-collection

‎.github/workflows/generate-docs.yml‎

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,9 @@ permissions:
1010
# The artifact is attached to the workflow run so reviewers can download a preview,
1111
# but also to verify the documentation artifact is valid for subsequent release runs
1212
# that will publish them to the LiveKit docs web page: https://docs.livekit.io/reference/client-sdk-cpp/
13+
# Called by top-level ci.yml on PRs. PR trigger lives in the parent
14+
# so a single "CI" check gates every PR regardless of paths.
1315
on:
14-
pull_request:
15-
branches: ["main"]
16-
paths:
17-
- include/**
18-
- src/**
19-
- docs/**
20-
- scripts/generate-docs.sh
21-
- .github/workflows/generate-docs.yml
22-
- .github/workflows/publish-docs.yml
2316
workflow_call:
2417
inputs:
2518
version:

‎.github/workflows/make-release.yml‎

Lines changed: 9 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,6 @@ on:
1313

1414
env:
1515
CARGO_TERM_COLOR: always
16-
# sccache caches rustc invocations across runs. RUSTC_WRAPPER is exported
17-
# only after the setup step verifies the GHA cache backend is reachable, so
18-
# transient cache backend failures fall back to uncached rustc instead of
19-
# failing the build.
20-
SCCACHE_GHA_ENABLED: "true"
2116
VCPKG_BINARY_SOURCES: "clear;x-gha,readwrite"
2217
VCPKG_DEFAULT_TRIPLET: x64-windows-static-md
2318
VCPKG_DEFAULT_HOST_TRIPLET: x64-windows-static-md
@@ -140,21 +135,16 @@ jobs:
140135
if: matrix.name == 'macos-x64'
141136
run: rustup target add x86_64-apple-darwin
142137

143-
# ---------- Setup sccache ----------
144-
- name: Setup sccache
145-
uses: mozilla-actions/sccache-action@054db53350805f83040bf3e6e9b8cf5a139aa7c9 # v0.0.7
146-
147-
- name: Enable sccache wrapping (probe first)
138+
# ---------- Cache Cargo ----------
139+
# Key the target cache on the client-sdk-rust submodule SHA (Cargo.lock is
140+
# pinned inside the submodule and froze the old cache). No clean step runs
141+
# in this workflow, so the combined actions/cache post-job save captures
142+
# the populated target/ correctly once the key busts on a submodule bump.
143+
- name: Resolve Rust submodule SHA
144+
id: rust_sha
148145
shell: bash
149-
run: |
150-
if sccache --start-server >/dev/null 2>&1; then
151-
echo "RUSTC_WRAPPER=sccache" >> "$GITHUB_ENV"
152-
echo "::notice::sccache enabled (RUSTC_WRAPPER=sccache)"
153-
else
154-
echo "::warning::sccache backend unreachable; building without compile cache this run"
155-
fi
146+
run: echo "sha=$(git -C client-sdk-rust rev-parse HEAD)" >> "$GITHUB_OUTPUT"
156147

157-
# ---------- Cache Cargo ----------
158148
- name: Cache Cargo registry
159149
uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
160150
with:
@@ -170,7 +160,7 @@ jobs:
170160
uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
171161
with:
172162
path: client-sdk-rust/target/
173-
key: ${{ runner.os }}-${{ matrix.name }}-cargo-target-${{ hashFiles('client-sdk-rust/Cargo.lock') }}
163+
key: ${{ runner.os }}-${{ matrix.name }}-cargo-target-${{ steps.rust_sha.outputs.sha }}
174164
restore-keys: |
175165
${{ runner.os }}-${{ matrix.name }}-cargo-target-
176166

0 commit comments

Comments
 (0)