blob: ff9fb81ec501119e115e54f0a80fb456e2a0958b [file] [log] [blame]
Primiano Tucci171b0462025-03-27 15:20:24 +00001# 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
16name: Perfetto CI [bazel]
17on:
18 workflow_call:
19env:
20 # /tmp/cache contains {ccache, bazelcache} and generally any other cache
21 # that should be persisted across jobs, but only updated from the main
Kirill Timofeev5cca7912025-08-07 20:40:18 +010022 # branch. This is populated by the "Restore cache" step below.
Primiano Tucci171b0462025-03-27 15:20:24 +000023 PERFETTO_CACHE_DIR: /tmp/cache
24 PERFETTO_ARTIFACTS_ROOT: /tmp/artifacts
25 PYTHONUNBUFFERED: 1
26jobs:
27 bazel:
28 runs-on: self-hosted
29 timeout-minutes: 45
30 env:
Kirill Timofeev5cca7912025-08-07 20:40:18 +010031 PERFETTO_CI_BUILD_CACHE_KEY: build-cache-bazel
Primiano Tucci171b0462025-03-27 15:20:24 +000032 PERFETTO_CI_JOB_ID: gh-${{ github.run_id }}-bazel
33 steps:
34 - uses: actions/checkout@v4
35
Primiano Tucci171b0462025-03-27 15:20:24 +000036 - name: Setup artifacts
Kirill Timofeev09d5f152025-08-06 15:49:16 +010037 shell: bash
Primiano Tucci171b0462025-03-27 15:20:24 +000038 run: |
39 PERFETTO_ARTIFACTS_DIR=$PERFETTO_ARTIFACTS_ROOT/$PERFETTO_CI_JOB_ID
40 echo "PERFETTO_ARTIFACTS_DIR=$PERFETTO_ARTIFACTS_DIR" >> $GITHUB_ENV
41 mkdir -p $PERFETTO_ARTIFACTS_DIR
42
43 - name: Restore cache
Kirill Timofeev5cca7912025-08-07 20:40:18 +010044 uses: ./.github/actions/cache-on-google-cloud-storage/restore
Primiano Tucci171b0462025-03-27 15:20:24 +000045 with:
Kirill Timofeev5cca7912025-08-07 20:40:18 +010046 directory: ${{ env.PERFETTO_CACHE_DIR }}
47 cache_key: ${{ env.PERFETTO_CI_BUILD_CACHE_KEY }}
Primiano Tucci171b0462025-03-27 15:20:24 +000048
49 - uses: ./.github/actions/install-build-deps
50 with:
51 install-flags: --bazel
52
53 - name: Build Bazel
Kirill Timofeev09d5f152025-08-06 15:49:16 +010054 shell: bash
Primiano Tucci171b0462025-03-27 15:20:24 +000055 run: |
56 BAZEL_DISK_CACHE_FOLDER="$PERFETTO_CACHE_DIR/bazel-disk-cache"
57 # Cleanup the cache if any of the two conditions are true.
58 BAZEL_DISK_CACHE_GC_OPTIONS="--experimental_disk_cache_gc_max_age=7d --experimental_disk_cache_gc_max_size=10G"
59 # We don't run a bazel daemon in background, so we do a GC during the build,
60 # that's why we specify _idle_delay=0.
61 BAZEL_DISK_CACHE_GC_OPTIONS+=" --experimental_disk_cache_gc_idle_delay=0"
62 BAZEL_DISK_CACHE_FLAGS="--disk_cache=${BAZEL_DISK_CACHE_FOLDER} ${BAZEL_DISK_CACHE_GC_OPTIONS}"
63 tools/bazel build //:all ${BAZEL_DISK_CACHE_FLAGS} --verbose_failures
64 tools/bazel build //python:all ${BAZEL_DISK_CACHE_FLAGS} --verbose_failures
65
66 - name: Smoke tests
Kirill Timofeev09d5f152025-08-06 15:49:16 +010067 shell: bash
Primiano Tucci171b0462025-03-27 15:20:24 +000068 run: |
69 ./bazel-bin/traced &
70 ./bazel-bin/traced_probes &
71 sleep 5
72 TRACE="$PERFETTO_ARTIFACTS_DIR/bazel.trace"
73 ./bazel-bin/perfetto -c :test -o $TRACE
74 kill $(jobs -p)
75 ./bazel-bin/trace_processor_shell -q <(echo 'select count(1) from sched') $TRACE
76
77 - name: Update cache (if on main)
78 if: github.ref == 'refs/heads/main'
Kirill Timofeev5cca7912025-08-07 20:40:18 +010079 uses: ./.github/actions/cache-on-google-cloud-storage/save
Primiano Tucci171b0462025-03-27 15:20:24 +000080 with:
Kirill Timofeev5cca7912025-08-07 20:40:18 +010081 directory: ${{ env.PERFETTO_CACHE_DIR }}
82 cache_key: ${{ env.PERFETTO_CI_BUILD_CACHE_KEY }}