blob: 90cf2b0d91fee056b8756a3d2eadad3bcb8ab4db [file] [edit]
# 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.
name: Sync generated proto files
on:
schedule:
# Run every day at 2 AM UTC
- cron: '0 2 * * *'
workflow_dispatch: # Allow manual triggering
permissions: {}
jobs:
sync-protos:
runs-on: self-hosted
environment: perfetto-automation
timeout-minutes: 60
steps:
- name: Mint app token
id: app-token
uses: actions/create-github-app-token@v2
with:
app-id: ${{ secrets.PERFETTO_BOT_APP_ID }}
private-key: ${{ secrets.PERFETTO_BOT_PRIVATE_KEY }}
- name: Checkout repository
uses: actions/checkout@v4
with:
ref: main
fetch-depth: 0
token: ${{ steps.app-token.outputs.token }}
- uses: ./.github/actions/install-build-deps
- name: Install GitHub CLI
run: |
if ! command -v gh >/dev/null 2>&1; then
# When bumping, re-verify GH_SHA256 against the upstream checksums:
# https://github.com/cli/cli/releases/download/v${GH_VERSION}/gh_${GH_VERSION}_checksums.txt
GH_VERSION=2.90.0
GH_SHA256=b2aef7b23ec6899bf27f37a32c57a7935d0a178568ac33dc9bb03842f724195a
GH_TARBALL="gh_${GH_VERSION}_linux_amd64.tar.gz"
mkdir -p "$HOME/.local/bin"
curl -fsSLO "https://github.com/cli/cli/releases/download/v${GH_VERSION}/${GH_TARBALL}"
echo "${GH_SHA256} ${GH_TARBALL}" | sha256sum --check --status
tar -xzf "${GH_TARBALL}" --strip-components=2 -C "$HOME/.local/bin" \
"gh_${GH_VERSION}_linux_amd64/bin/gh"
rm "${GH_TARBALL}"
echo "$HOME/.local/bin" >> "$GITHUB_PATH"
export PATH="$HOME/.local/bin:$PATH"
fi
gh --version
- name: Setup build directory
run: |
tools/gn gen out/proto_sync --args="is_debug=false"
- name: Generate proto files
run: |
tools/gen_all --protos out/proto_sync
- name: Check for changes
id: check_changes
run: |
if [ -n "$(git status --porcelain)" ]; then
echo "has_changes=true" >> $GITHUB_OUTPUT
else
echo "has_changes=false" >> $GITHUB_OUTPUT
fi
- name: Close existing proto sync PRs
if: steps.check_changes.outputs.has_changes == 'true'
env:
GH_TOKEN: ${{ steps.app-token.outputs.token }}
run: |
EXISTING_PRS=$(gh pr list --head dev/github-bot/sync-protos --json number --jq '.[].number')
if [ -n "$EXISTING_PRS" ]; then
for PR_NUMBER in $EXISTING_PRS; do
echo "Closing existing PR #$PR_NUMBER"
gh pr close $PR_NUMBER --comment "Closing in favor of a new proto sync PR with updated changes."
done
fi
# Delete any stale remote branch so peter-evans can push cleanly.
# `|| true` covers the case where the branch doesn't exist.
- name: Delete stale sync-protos branch
if: steps.check_changes.outputs.has_changes == 'true'
run: |
git push origin --delete dev/github-bot/sync-protos || true
- name: Create Pull Request
if: steps.check_changes.outputs.has_changes == 'true'
uses: peter-evans/create-pull-request@v7
with:
token: ${{ steps.app-token.outputs.token }}
# Email must match the CLA-approved address for the automation app.
committer: perfetto-automation[bot] <perfetto-automation-github-app@google.com>
author: perfetto-automation[bot] <perfetto-automation-github-app@google.com>
commit-message: |
Sync generated proto files
This is an automated update of generated proto files (.gen.cc/h,
.pcz.h, descriptors, etc.) to match their .proto definitions.
branch: dev/github-bot/sync-protos
delete-branch: true
title: 'Sync generated proto files'
body: |
This PR automatically synchronizes generated proto files with their `.proto` definitions.
## Generated files updated
- `.gen.cc` and `.gen.h` files
- `.pcz.h` files
- Binary descriptors
- Python proto bindings
This is an automated PR generated by the `sync-protos` workflow.
labels: automated