Skip to content

Example report - Status and Screenshots #6792

Example report - Status and Screenshots

Example report - Status and Screenshots #6792

Workflow file for this run

name: Example report - Status and Screenshots
on:
workflow_dispatch:
schedule:
- cron: '0 6,18 * * *'
concurrency:
group: ${{ github.repository }}-example-report
env:
PER_PAGE: 20
jobs:
get-environment:
name: Get Environment
runs-on: ubuntu-latest
outputs:
pages: ${{ steps.env.outputs.pages }}
gitref: ${{ steps.env.outputs.gitref }}
date: ${{ steps.env.outputs.date }}
updated: ${{ steps.version-check.outputs.updated }}
steps:
- name: Checkout Bevy main branch
uses: actions/checkout@v4
with:
repository: 'bevyengine/bevy'
ref: 'main'
- name: Get Environment
id: env
run: |
example_count=`cat Cargo.toml | grep '\[\[example\]\]' | wc -l`
page_count=$((example_count / ${{ env.PER_PAGE }} + 1))
echo "gitref=`git rev-parse HEAD`" >> $GITHUB_OUTPUT
echo "date=`date +%Y%m%d%H%M`" >> $GITHUB_OUTPUT
echo "pages=`python -c \"import json; print(json.dumps([i for i in range($page_count)]))\"`" >> $GITHUB_OUTPUT
- uses: actions/checkout@v4
with:
ref: 'results'
path: 'results'
- name: Check if current Bevy version already ran
id: version-check
run: |
gitref=`git rev-parse HEAD`
updated=`if ls results/*-$gitref 1> /dev/null 2>&1; then echo "false"; else echo "true"; fi`
echo "updated=$updated" >> $GITHUB_OUTPUT
take-screenshots:
name: Take Screenshots
needs: get-environment
if: needs.get-environment.outputs.updated == 'true' || github.event_name == 'workflow_dispatch'
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-14]
page: [1]
steps:
- name: Checkout Bevy main branch
uses: actions/checkout@v4
with:
repository: 'bevyengine/bevy'
ref: ${{ needs.get-environment.outputs.gitref }}
- name: Checkout patches
uses: actions/checkout@v4
with:
path: 'runner-patches'
- name: Apply patches
shell: pwsh
run: |
Get-ChildItem "runner-patches/patches" -Filter *.patch |
Foreach-Object {
Write-Output "Processing $($_.FullName)"
git apply --ignore-whitespace $($_.FullName)
}
- name: Setup Rust
uses: dtolnay/rust-toolchain@stable
- name: Install Bevy dependencies
if: runner.os == 'linux'
run: |
sudo apt-get update;
DEBIAN_FRONTEND=noninteractive sudo apt-get install --no-install-recommends -yq \
libasound2-dev libudev-dev libxkbcommon-x11-0;
- name: install xvfb, llvmpipe and lavapipe
if: runner.os == 'linux'
run: |
sudo apt-get update -y -qq
sudo add-apt-repository ppa:kisak/turtle -y
sudo apt-get update
sudo apt install -y xvfb libegl1-mesa libgl1-mesa-dri libxcb-xfixes0-dev mesa-vulkan-drivers
- uses: actions/cache/restore@v4
id: restore-cache
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.toml') }}
restore-keys: ${{ runner.os }}-cargo-
- name: Take Screenshots (Linux)
id: screenshots-linux
if: runner.os == 'linux'
continue-on-error: true
run: xvfb-run -s "-screen 0 1280x1024x24" cargo run -p example-showcase -- --page ${{ matrix.page }} --per-page ${{ env.PER_PAGE }} run --screenshot-at 250 --frame-duration 0.02 --stop-at 350 --in-ci --ignore-stress-tests --report-details
- name: Take Screenshots (Windows)
id: screenshots-windows
if: runner.os == 'windows'
continue-on-error: true
shell: pwsh
run: |
Add-Type -AssemblyName System.Windows.Forms
$screen = [System.Windows.Forms.SystemInformation]::VirtualScreen
[Windows.Forms.Cursor]::Position = "$($screen.Width / 2),$($screen.Height / 2)"
cargo run -p example-showcase -- --page ${{ matrix.page }} --per-page ${{ env.PER_PAGE }} run --screenshot-at 250 --frame-duration 0.02 --stop-at 350 --in-ci --ignore-stress-tests --report-details
- name: Take Screenshots (macOS)
id: screenshots-macos
if: runner.os == 'macos'
continue-on-error: true
run: cargo run -p example-showcase -- --page ${{ matrix.page }} --per-page ${{ env.PER_PAGE }} run --screenshot-at 250 --frame-duration 0.02 --stop-at 350 --in-ci --ignore-stress-tests --report-details
- name: Log errors
shell: pwsh
run: |
if (Get-Content no_screenshots) {
perl -p -e 's/(.*) - [.0-9]*\n/\1, /g' no_screenshots > cleaned
$no_screenshots = Get-Content .\cleaned -Raw
echo "::warning title=No Screenshots ${{ runner.os }}/${{ matrix.page }}::$no_screenshots"
}
if (Get-Content failures) {
perl -p -e 's/(.*) - [.0-9]*\n/\1, /g' failures > cleaned
$failures = Get-Content .\cleaned -Raw
echo "::error title=Failed To Run ${{ runner.os }}/${{ matrix.page }}::$failures"
}
- name: Outputs run results
id: run-results
shell: pwsh
run: |
echo "has_success=$(![String]::IsNullOrWhiteSpace((Get-content successes)))" | Out-File -FilePath $env:GITHUB_OUTPUT -Append
- name: Upload Screenshots
uses: actions/upload-artifact@v4
with:
name: screenshots-${{ runner.os }}-${{ matrix.page }}
path: screenshots
- name: Upload Status
uses: actions/upload-artifact@v4
with:
name: status-${{ runner.os }}-${{ matrix.page }}
path: |
successes
failures
no_screenshots
send-to-pixel-eagle:
name: Send screenshots to Pixel Eagle
runs-on: macos-14
needs: [take-screenshots, get-environment]
strategy:
fail-fast: false
matrix:
include:
- os: Linux
- os: macOS
steps:
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
pattern: screenshots-${{ matrix.os }}-*
- name: Move examples to the correct folder
id: gather-examples
continue-on-error: true
run: |
mkdir screenshots-${{ matrix.os }}
for screenshotfolder in screenshots-${{ matrix.os }}-*
do
echo $screenshotfolder
rsync --verbose --archive $screenshotfolder/* screenshots-${{ matrix.os }}/
rm -rf $screenshotfolder
done
- name: Remove images that are all black
if: steps.gather-examples.outcome == 'success'
run: |
set +e
sudo apt install -y imagemagick
for image in screenshots-${{ matrix.os }}/*/*.png
do
mean=`convert "$image" -format "%[mean]" info:`
if [[ "$?" = "1" ]]; then
echo "Error reading $image"
rm "$image"
fi
if [ "$mean" = 0 ]; then
echo "$image is all black"
rm "$image"
fi
done
- name: Send to Pixel Eagle
if: steps.gather-examples.outcome == 'success'
run: |
uuid="B25A040A-A980-4602-B90C-D480AB84076D"
id=`curl https://pixel-eagle.vleue.com/$uuid/runs --json '{"os":"${{ matrix.os }}", "gitref": "${{ needs.get-environment.outputs.gitref }}"}' | jq '.id'`
SAVEIFS=$IFS
IFS=$'\n'
cd screenshots-${{ matrix.os }}
for screenshot in $(find ./ -type f -name "*.png");
do
echo $screenshot
sha=`shasum -a 256 $screenshot | awk '{print $1}'`
to_upload=`curl https://pixel-eagle.vleue.com/$uuid/runs/$id/hashes --json "[ [\"$screenshot\", \"$sha\"] ]" | jq '. | length'`
if [ $to_upload -eq 1 ]; then
curl https://pixel-eagle.vleue.com/$uuid/runs/$id/screenshots -F "data=@$screenshot" -F "screenshot=$screenshot" | jq
fi
done
IFS=$SAVEIFS