|
| 1 | +name: Example Run |
| 2 | + |
| 3 | +on: |
| 4 | + merge_group: |
| 5 | + pull_request: |
| 6 | + # also run when pushed to main to update reference screenshots |
| 7 | + push: |
| 8 | + branches: |
| 9 | + - main |
| 10 | + |
| 11 | +env: |
| 12 | + CARGO_TERM_COLOR: always |
| 13 | + CARGO_INCREMENTAL: 0 |
| 14 | + CARGO_PROFILE_TEST_DEBUG: 0 |
| 15 | + CARGO_PROFILE_DEV_DEBUG: 0 |
| 16 | + |
| 17 | +jobs: |
| 18 | + run-examples-macos-metal: |
| 19 | + runs-on: macos-latest |
| 20 | + timeout-minutes: 30 |
| 21 | + steps: |
| 22 | + - uses: actions/checkout@v4 |
| 23 | + - uses: dtolnay/rust-toolchain@stable |
| 24 | + - name: Disable audio |
| 25 | + # Disable audio through a patch. on github m1 runners, audio timeouts after 15 minutes |
| 26 | + run: git apply --ignore-whitespace tools/example-showcase/disable-audio.patch |
| 27 | + - name: Run examples |
| 28 | + run: | |
| 29 | + for example in .github/example-run/*.ron; do |
| 30 | + example_name=`basename $example .ron` |
| 31 | + echo -n $example_name > last_example_run |
| 32 | + echo "running $example_name - "`date` |
| 33 | + time TRACE_CHROME=trace-$example_name.json CI_TESTING_CONFIG=$example cargo run --example $example_name --features "bevy_ci_testing,trace,trace_chrome" |
| 34 | + sleep 10 |
| 35 | + if [ `find ./ -maxdepth 1 -name 'screenshot-*.png' -print -quit` ]; then |
| 36 | + mkdir screenshots-$example_name |
| 37 | + mv screenshot-*.png screenshots-$example_name/ |
| 38 | + fi |
| 39 | + done |
| 40 | + mkdir traces && mv trace*.json traces/ |
| 41 | + mkdir screenshots && mv screenshots-* screenshots/ |
| 42 | + - name: save traces |
| 43 | + uses: actions/upload-artifact@v4 |
| 44 | + with: |
| 45 | + name: example-traces-macos |
| 46 | + path: traces |
| 47 | + - name: Save PR number |
| 48 | + if: ${{ github.event_name == 'pull_request' }} |
| 49 | + run: | |
| 50 | + echo ${{ github.event.number }} > ./screenshots/PR |
| 51 | + - name: save screenshots |
| 52 | + uses: actions/upload-artifact@v4 |
| 53 | + with: |
| 54 | + name: screenshots-macos |
| 55 | + path: screenshots |
| 56 | + - uses: actions/upload-artifact@v4 |
| 57 | + if: ${{ failure() && github.event_name == 'pull_request' }} |
| 58 | + with: |
| 59 | + name: example-run-macos |
| 60 | + path: example-run/ |
| 61 | + |
| 62 | + compare-macos-screenshots: |
| 63 | + if: ${{ github.event_name != 'pull_request' }} |
| 64 | + name: Compare Macos screenshots |
| 65 | + needs: [run-examples-macos-metal] |
| 66 | + uses: ./.github/workflows/send-screenshots-to-pixeleagle.yml |
| 67 | + with: |
| 68 | + commit: ${{ github.sha }} |
| 69 | + branch: ${{ github.ref_name }} |
| 70 | + artifact: screenshots-macos |
| 71 | + os: macos |
| 72 | + secrets: inherit |
| 73 | + |
| 74 | + run-examples-linux-vulkan: |
| 75 | + if: ${{ github.event_name != 'pull_request' }} |
| 76 | + runs-on: ubuntu-latest |
| 77 | + timeout-minutes: 30 |
| 78 | + steps: |
| 79 | + - uses: actions/checkout@v4 |
| 80 | + - name: Install Linux dependencies |
| 81 | + uses: ./.github/actions/install-linux-deps |
| 82 | + # At some point this may be merged into `install-linux-deps`, but for now it is its own step. |
| 83 | + - name: Install additional Linux dependencies for Vulkan |
| 84 | + run: | |
| 85 | + sudo add-apt-repository ppa:kisak/turtle -y |
| 86 | + sudo apt-get install --no-install-recommends libxkbcommon-x11-0 xvfb libgl1-mesa-dri libxcb-xfixes0-dev mesa-vulkan-drivers |
| 87 | + - uses: actions/cache@v4 |
| 88 | + with: |
| 89 | + path: | |
| 90 | + ~/.cargo/bin/ |
| 91 | + ~/.cargo/registry/index/ |
| 92 | + ~/.cargo/registry/cache/ |
| 93 | + ~/.cargo/git/db/ |
| 94 | + target/ |
| 95 | + key: ${{ runner.os }}-cargo-run-examples-${{ hashFiles('**/Cargo.toml') }} |
| 96 | + - uses: dtolnay/rust-toolchain@stable |
| 97 | + - name: Run examples |
| 98 | + run: | |
| 99 | + for example in .github/example-run/*.ron; do |
| 100 | + example_name=`basename $example .ron` |
| 101 | + echo -n $example_name > last_example_run |
| 102 | + echo "running $example_name - "`date` |
| 103 | + time TRACE_CHROME=trace-$example_name.json CI_TESTING_CONFIG=$example xvfb-run cargo run --example $example_name --features "bevy_ci_testing,trace,trace_chrome" |
| 104 | + sleep 10 |
| 105 | + if [ `find ./ -maxdepth 1 -name 'screenshot-*.png' -print -quit` ]; then |
| 106 | + mkdir screenshots-$example_name |
| 107 | + mv screenshot-*.png screenshots-$example_name/ |
| 108 | + fi |
| 109 | + done |
| 110 | + mkdir traces && mv trace*.json traces/ |
| 111 | + mkdir screenshots && mv screenshots-* screenshots/ |
| 112 | + - name: save traces |
| 113 | + uses: actions/upload-artifact@v4 |
| 114 | + with: |
| 115 | + name: example-traces-linux |
| 116 | + path: traces |
| 117 | + - name: save screenshots |
| 118 | + uses: actions/upload-artifact@v4 |
| 119 | + with: |
| 120 | + name: screenshots-linux |
| 121 | + path: screenshots |
| 122 | + - uses: actions/upload-artifact@v4 |
| 123 | + if: ${{ failure() && github.event_name == 'pull_request' }} |
| 124 | + with: |
| 125 | + name: example-run-linux |
| 126 | + path: example-run/ |
| 127 | + |
| 128 | + compare-linux-screenshots: |
| 129 | + name: Compare Linux screenshots |
| 130 | + needs: [run-examples-linux-vulkan] |
| 131 | + uses: ./.github/workflows/send-screenshots-to-pixeleagle.yml |
| 132 | + with: |
| 133 | + commit: ${{ github.sha }} |
| 134 | + branch: ${{ github.ref_name }} |
| 135 | + artifact: screenshots-linux |
| 136 | + os: linux |
| 137 | + secrets: inherit |
| 138 | + |
| 139 | + run-examples-on-windows-dx12: |
| 140 | + if: ${{ github.event_name != 'pull_request' }} |
| 141 | + runs-on: windows-latest |
| 142 | + timeout-minutes: 30 |
| 143 | + steps: |
| 144 | + - uses: actions/checkout@v4 |
| 145 | + - uses: dtolnay/rust-toolchain@stable |
| 146 | + - name: Run examples |
| 147 | + shell: bash |
| 148 | + run: | |
| 149 | + for example in .github/example-run/*.ron; do |
| 150 | + example_name=`basename $example .ron` |
| 151 | + echo -n $example_name > last_example_run |
| 152 | + echo "running $example_name - "`date` |
| 153 | + time WGPU_BACKEND=dx12 TRACE_CHROME=trace-$example_name.json CI_TESTING_CONFIG=$example cargo run --example $example_name --features "statically-linked-dxc,bevy_ci_testing,trace,trace_chrome" |
| 154 | + sleep 10 |
| 155 | + if [ `find ./ -maxdepth 1 -name 'screenshot-*.png' -print -quit` ]; then |
| 156 | + mkdir screenshots-$example_name |
| 157 | + mv screenshot-*.png screenshots-$example_name/ |
| 158 | + fi |
| 159 | + done |
| 160 | + mkdir traces && mv trace*.json traces/ |
| 161 | + mkdir screenshots && mv screenshots-* screenshots/ |
| 162 | + - name: save traces |
| 163 | + uses: actions/upload-artifact@v4 |
| 164 | + with: |
| 165 | + name: example-traces-windows |
| 166 | + path: traces |
| 167 | + - name: save screenshots |
| 168 | + uses: actions/upload-artifact@v4 |
| 169 | + with: |
| 170 | + name: screenshots-windows |
| 171 | + path: screenshots |
| 172 | + - uses: actions/upload-artifact@v4 |
| 173 | + if: ${{ failure() && github.event_name == 'pull_request' }} |
| 174 | + with: |
| 175 | + name: example-run-windows |
| 176 | + path: example-run/ |
| 177 | + |
| 178 | + compare-windows-screenshots: |
| 179 | + name: Compare Windows screenshots |
| 180 | + needs: [run-examples-on-windows-dx12] |
| 181 | + uses: ./.github/workflows/send-screenshots-to-pixeleagle.yml |
| 182 | + with: |
| 183 | + commit: ${{ github.sha }} |
| 184 | + branch: ${{ github.ref_name }} |
| 185 | + artifact: screenshots-windows |
| 186 | + os: windows |
| 187 | + secrets: inherit |
0 commit comments