forked from google/perfetto
-
Notifications
You must be signed in to change notification settings - Fork 1
82 lines (75 loc) · 3.21 KB
/
bazel-tests.yml
File metadata and controls
82 lines (75 loc) · 3.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
# Copyright (C) 2025 The Android Open Source Project
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# This workflow is triggered by analyze.yml
name: Perfetto CI [bazel]
on:
workflow_call:
env:
# /tmp/cache contains {ccache, bazelcache} and generally any other cache
# that should be persisted across jobs, but only updated from the main
# branch. This is populated by the "Restore cache" step below.
PERFETTO_CACHE_DIR: /tmp/cache
PERFETTO_ARTIFACTS_ROOT: /tmp/artifacts
PYTHONUNBUFFERED: 1
jobs:
bazel:
runs-on: self-hosted
timeout-minutes: 45
env:
PERFETTO_CI_BUILD_CACHE_KEY: build-cache-bazel
PERFETTO_CI_JOB_ID: gh-${{ github.run_id }}-bazel
steps:
- uses: actions/checkout@v4
- name: Setup artifacts
shell: bash
run: |
PERFETTO_ARTIFACTS_DIR=$PERFETTO_ARTIFACTS_ROOT/$PERFETTO_CI_JOB_ID
echo "PERFETTO_ARTIFACTS_DIR=$PERFETTO_ARTIFACTS_DIR" >> $GITHUB_ENV
mkdir -p $PERFETTO_ARTIFACTS_DIR
- name: Restore cache
uses: ./.github/actions/cache-on-google-cloud-storage/restore
with:
directory: ${{ env.PERFETTO_CACHE_DIR }}
cache_key: ${{ env.PERFETTO_CI_BUILD_CACHE_KEY }}
- uses: ./.github/actions/install-build-deps
with:
install-flags: --bazel
- name: Build Bazel
shell: bash
run: |
BAZEL_DISK_CACHE_FOLDER="$PERFETTO_CACHE_DIR/bazel-disk-cache"
# Cleanup the cache if any of the two conditions are true.
BAZEL_DISK_CACHE_GC_OPTIONS="--experimental_disk_cache_gc_max_age=7d --experimental_disk_cache_gc_max_size=10G"
# We don't run a bazel daemon in background, so we do a GC during the build,
# that's why we specify _idle_delay=0.
BAZEL_DISK_CACHE_GC_OPTIONS+=" --experimental_disk_cache_gc_idle_delay=0"
BAZEL_DISK_CACHE_FLAGS="--disk_cache=${BAZEL_DISK_CACHE_FOLDER} ${BAZEL_DISK_CACHE_GC_OPTIONS}"
tools/bazel build //:all ${BAZEL_DISK_CACHE_FLAGS} --verbose_failures
tools/bazel build //python:all ${BAZEL_DISK_CACHE_FLAGS} --verbose_failures
- name: Smoke tests
shell: bash
run: |
./bazel-bin/traced &
./bazel-bin/traced_probes &
sleep 5
TRACE="$PERFETTO_ARTIFACTS_DIR/bazel.trace"
./bazel-bin/perfetto -c :test -o $TRACE
kill $(jobs -p)
./bazel-bin/trace_processor_shell -q <(echo 'select count(1) from sched') $TRACE
- name: Update cache (if on main)
if: github.ref == 'refs/heads/main'
uses: ./.github/actions/cache-on-google-cloud-storage/save
with:
directory: ${{ env.PERFETTO_CACHE_DIR }}
cache_key: ${{ env.PERFETTO_CI_BUILD_CACHE_KEY }}