ci: move to GitHub Actions (#1060)
Move the CI over to GH Actions
diff --git a/.github/workflows/bazel-tests.yml b/.github/workflows/bazel-tests.yml
new file mode 100644
index 0000000..acfec96
--- /dev/null
+++ b/.github/workflows/bazel-tests.yml
@@ -0,0 +1,84 @@
+# 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 "actions/cache/restore" 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_JOB_NAME: bazel
+ PERFETTO_CI_JOB_ID: gh-${{ github.run_id }}-bazel
+ steps:
+ - uses: actions/checkout@v4
+
+ - name: Setup ccache
+ run: bash .github/workflows/ccache_env.sh | tee -a $GITHUB_ENV
+
+ - name: Setup artifacts
+ 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: actions/cache/restore@v4
+ with:
+ path: ${{ env.PERFETTO_CACHE_DIR }}
+ key: cache-${{ env.PERFETTO_CI_JOB_NAME }}-${{ github.run_id }}
+ restore-keys: |
+ cache-${{ env.PERFETTO_CI_JOB_NAME }}-
+
+ - uses: ./.github/actions/install-build-deps
+ with:
+ install-flags: --bazel
+
+ - name: Build Bazel
+ 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
+ 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: actions/cache/save@v4
+ with:
+ path: ${{ env.PERFETTO_CACHE_DIR }}
+ key: cache-${{ env.PERFETTO_CI_JOB_NAME }}-${{ github.run_id }}