Skip to content

Commit 0106453

Browse files
committed
CI: add Rust SDK checks
Only FYI and don't prevent CI from being green. Fixes: #3497
1 parent 2aabbe9 commit 0106453

File tree

3 files changed

+109
-1
lines changed

3 files changed

+109
-1
lines changed

.github/workflows/analyze.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,13 @@ jobs:
118118
needs: analyze
119119
uses: ./.github/workflows/repo-checks.yml
120120

121+
rust-sdk:
122+
needs: analyze
123+
if:
124+
needs.analyze.outputs.UI_ONLY_CHANGE == '0' &&
125+
needs.analyze.outputs.TRIVIAL_CHANGE == '0'
126+
uses: ./.github/workflows/rust-sdk-tests.yml
127+
121128
# This final step joins the results of the nested workflows and succeeds if
122129
# all the non-skipped workflows have suceeded. This job is used by the
123130
# "require CI to pass" GitHub ruleset.
@@ -130,6 +137,7 @@ jobs:
130137
- bazel
131138
- fuzzer
132139
- repo-checks
140+
- rust-sdk
133141
if: always()
134142
runs-on: ubuntu-latest
135143
steps:
@@ -144,9 +152,17 @@ jobs:
144152
exit 1
145153
fi
146154
}
155+
warn() {
156+
job="$1"
157+
result="$2"
158+
if [ "$result" != "success" ] && [ "$result" != "skipped" ]; then
159+
echo "::warning::$job failed with result: $result"
160+
fi
161+
}
147162
check linux ${{ needs.linux.result }}
148163
check android ${{ needs.android.result }}
149164
check ui ${{ needs.ui.result }}
150165
check bazel ${{ needs.bazel.result }}
151166
check fuzzer ${{ needs.fuzzer.result }}
152167
check repo-checks ${{ needs.repo-checks.result }}
168+
warn rust-sdk ${{ needs.rust-sdk.result }}
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
# Copyright (C) 2025 The Android Open Source Project
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
# This workflow is triggered by analyze.yml
16+
name: Perfetto Rust SDK CI
17+
18+
on:
19+
workflow_call:
20+
21+
permissions:
22+
pull-requests: read
23+
24+
env:
25+
# Pinned nightly version that receives extra testing by SDK maintainers.
26+
NIGHTLY_VERSION: "nightly-2025-01-03"
27+
NIGHTLY_FEATURES: "--features=intrinsics"
28+
29+
jobs:
30+
build-test:
31+
name: Rust ${{ matrix.name }}
32+
runs-on: self-hosted
33+
timeout-minutes: 20
34+
35+
strategy:
36+
matrix:
37+
include:
38+
- name: stable
39+
toolchain: stable
40+
features: ""
41+
- name: nightly
42+
toolchain: $NIGHTLY_VERSION
43+
features: $NIGHTLY_FEATURES
44+
steps:
45+
- name: Checkout source
46+
uses: actions/checkout@v4
47+
48+
- name: Install Rust (${{ matrix.name }})
49+
uses: dtolnay/rust-toolchain@stable
50+
with:
51+
toolchain: ${{ matrix.toolchain }}
52+
components: clippy
53+
54+
- name: Show Rust version
55+
run: rustc --version && cargo --version
56+
57+
- name: Install build dependencies
58+
uses: ./.github/actions/install-build-deps
59+
with:
60+
install-flags: --no-dev-tools
61+
62+
- name: Generate amalgamated shared library sources
63+
shell: bash
64+
run: tools/gen_amalgamated --gn_args "is_debug=false is_clang=true use_custom_libcxx=false enable_perfetto_ipc=true perfetto_enable_git_rev_version_header=true is_perfetto_build_generator=true enable_perfetto_zlib=false" --output contrib/rust-sdk/perfetto-sys/libperfetto_c/perfetto_c //src/shared_lib:libperfetto_c
65+
66+
- name: Build (${{ matrix.name }})
67+
run: cargo build --manifest-path=contrib/rust-sdk/Cargo.toml --verbose ${{ matrix.features }}
68+
69+
- name: Run tests (${{ matrix.name }})
70+
run: cargo test --manifest-path=contrib/rust-sdk/Cargo.toml --verbose ${{ matrix.features }}
71+
72+
- name: Run clippy (${{ matrix.name }})
73+
run: cargo clippy --manifest-path=contrib/rust-sdk/Cargo.toml --all-targets ${{ matrix.features }} -- -D warnings
74+
75+
fmt:
76+
name: Rust format (nightly)
77+
runs-on: self-hosted
78+
timeout-minutes: 10
79+
80+
steps:
81+
- name: Checkout source
82+
uses: actions/checkout@v4
83+
84+
- name: Install Rust (nightly)
85+
uses: dtolnay/rust-toolchain@stable
86+
with:
87+
# Use pinned nightly version to prevent correct format from changing over time.
88+
toolchain: $NIGHTLY_VERSION
89+
components: rustfmt
90+
91+
- name: Check format of source
92+
run: cargo fmt --manifest-path=contrib/rust-sdk/Cargo.toml -- --check

contrib/rust-sdk/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ This workspace consists of three crates:
3131
- **Protozero integration** — auto-generated Rust code from Perfetto `.proto` files via a protoc plugin.
3232
- **Vendored or system builds** — link against a bundled `perfetto_c` library or use an external one.
3333
- **FFI isolation**`perfetto-sys` is the only crate exposing an API with `unsafe` code.
34-
- **Cross-platform support** — Linux and macOS are tested.
34+
- **Cross-platform support** — Linux support is tested using CI.
3535

3636
---
3737

0 commit comments

Comments
 (0)