- Introduces the `RDIFF_ACCEPT_NEW_GOLDENS` commit message tag. - Conditionally skip the `test-renderdiff` presubmit comparison if this tag is present. - Extracts renderdiff generation into a reusable `.github/actions/renderdiff-generate` composite action. - Modifies `postsubmit-main.yml` to automatically generate new goldens and push them to a temporary `accept-goldens-<short-hash>` branch before merging them into `main` when the tag is found.
125 lines
4.9 KiB
YAML
125 lines
4.9 KiB
YAML
name: 'Postsubmit Tasks'
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- main
|
|
|
|
jobs:
|
|
# Update the renderdiff goldens in filament-assets. This will add or merge the new goldens from
|
|
# a branch on filament-assets.
|
|
update-renderdiff-goldens:
|
|
name: update-renderdiff-goldens
|
|
runs-on: 'macos-14-xlarge'
|
|
steps:
|
|
- uses: actions/checkout@v4.1.6
|
|
with:
|
|
fetch-depth: 0
|
|
- id: get_commit_msg
|
|
uses: ./.github/actions/get-commit-msg
|
|
- name: Check if accepting new goldens
|
|
id: check_accept
|
|
env:
|
|
COMMIT_MESSAGE: ${{ steps.get_commit_msg.outputs.msg }}
|
|
run: |
|
|
if echo "${COMMIT_MESSAGE}" | python3 test/renderdiff/src/commit_msg.py --mode=accept_new_goldens; then
|
|
echo "accept=true" >> "$GITHUB_OUTPUT"
|
|
else
|
|
echo "accept=false" >> "$GITHUB_OUTPUT"
|
|
fi
|
|
shell: bash
|
|
- name: Renderdiff Generate for new goldens
|
|
if: steps.check_accept.outputs.accept == 'true'
|
|
uses: ./.github/actions/renderdiff-generate
|
|
- name: Run update script
|
|
env:
|
|
GH_TOKEN: ${{ secrets.FILAMENTBOT_TOKEN }}
|
|
COMMIT_MESSAGE: ${{ steps.get_commit_msg.outputs.msg }}
|
|
run: |
|
|
GOLDEN_BRANCH=$(echo "${COMMIT_MESSAGE}" | python3 test/renderdiff/src/commit_msg.py)
|
|
COMMIT_HASH="${{ steps.get_commit_msg.outputs.hash }}"
|
|
|
|
git config --global user.email "filament.bot@gmail.com"
|
|
git config --global user.name "Filament Bot"
|
|
git config --global credential.helper cache
|
|
|
|
if [[ "${{ steps.check_accept.outputs.accept }}" == "true" ]]; then
|
|
SHORT_HASH="${COMMIT_HASH:0:8}"
|
|
GOLDEN_BRANCH="accept-goldens-${SHORT_HASH}"
|
|
echo "Generating new goldens for branch ${GOLDEN_BRANCH}"
|
|
python3 test/renderdiff/src/update_golden.py \
|
|
--branch=${GOLDEN_BRANCH} \
|
|
--source=$(pwd)/out/renderdiff/renders \
|
|
--commit-msg="Auto-update goldens from ${COMMIT_HASH}" \
|
|
--push-to-remote \
|
|
--golden-repo-token=${GH_TOKEN}
|
|
fi
|
|
|
|
if [[ "${GOLDEN_BRANCH}" != "main" ]]; then
|
|
echo "branch==${GOLDEN_BRANCH}"
|
|
echo "hash==${COMMIT_HASH}"
|
|
python3 test/renderdiff/src/update_golden.py --branch=${GOLDEN_BRANCH} \
|
|
--merge-to-main --filament-tag=${COMMIT_HASH} --golden-repo-token=${GH_TOKEN}
|
|
fi
|
|
|
|
# Update the /docs (offiicla github-hosted Filament site) if necessary
|
|
update-docs:
|
|
name: update-docs
|
|
runs-on: 'ubuntu-24.04-4core'
|
|
steps:
|
|
- uses: actions/checkout@v4.1.6
|
|
with:
|
|
fetch-depth: 0
|
|
- uses: ./.github/actions/linux-prereq
|
|
- id: get_commit_msg
|
|
uses: ./.github/actions/get-commit-msg
|
|
- name: Prerequisites
|
|
run: pip install selenium
|
|
- name: Run update script
|
|
env:
|
|
GH_TOKEN: ${{ secrets.FILAMENTBOT_TOKEN }}
|
|
run: |
|
|
bash docs_src/build/install_mdbook.sh && source ~/.bashrc
|
|
COMMIT_HASH="${{ steps.get_commit_msg.outputs.hash }}"
|
|
git config --global user.email "filament.bot@gmail.com"
|
|
git config --global user.name "Filament Bot"
|
|
git config --global credential.helper cache
|
|
bash docs_src/build/postsubmit.sh ${COMMIT_HASH} ${GH_TOKEN}
|
|
|
|
# Produce a json that describes the android artifact sizes, and will push that json to a folder in
|
|
# filament-assets
|
|
update-sizeguard:
|
|
name: update-sizeguard
|
|
runs-on: 'ubuntu-24.04-16core'
|
|
steps:
|
|
- uses: actions/checkout@v4.1.6
|
|
with:
|
|
fetch-depth: 0
|
|
- uses: ./.github/actions/linux-prereq
|
|
- uses: actions/setup-java@v3
|
|
with:
|
|
distribution: 'temurin'
|
|
java-version: '17'
|
|
- id: get_commit_msg
|
|
uses: ./.github/actions/get-commit-msg
|
|
- name: Build and generate size report
|
|
run: |
|
|
cd build/android && printf "y" | ./build.sh release all
|
|
cd ../..
|
|
COMMIT_HASH="${{ steps.get_commit_msg.outputs.hash }}"
|
|
python3 test/sizeguard/dump_artifact_size.py out/*.tgz out/*.aar > "${COMMIT_HASH}.json"
|
|
- name: Push to filament-assets
|
|
env:
|
|
GH_TOKEN: ${{ secrets.FILAMENTBOT_TOKEN }}
|
|
run: |
|
|
COMMIT_HASH="${{ steps.get_commit_msg.outputs.hash }}"
|
|
git config --global user.email "filament.bot@gmail.com"
|
|
git config --global user.name "Filament Bot"
|
|
git clone https://x-access-token:${GH_TOKEN}@github.com/google/filament-assets.git filament-assets
|
|
mkdir -p filament-assets/sizeguard
|
|
mv "${COMMIT_HASH}.json" filament-assets/sizeguard/
|
|
cd filament-assets
|
|
git add sizeguard/"${COMMIT_HASH}.json"
|
|
git commit -m "Update sizeguard for filament@${COMMIT_HASH}" || echo "No changes to commit"
|
|
git push https://x-access-token:${GH_TOKEN}@github.com/google/filament-assets.git main
|