Skip to content

Commit 2f633c1

Browse files
authored
Split example runs to their own GitHub workflow (#18039)
# Objective - next step for #15918 ## Solution - Move jobs for macOS, Linux and Windows to their own workflow - Remove running on push to `main` from workflows CI and validation
1 parent 0f153ff commit 2f633c1

File tree

6 files changed

+268
-227
lines changed

6 files changed

+268
-227
lines changed

.github/workflows/ci-comment-failures.yml

Lines changed: 0 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -178,64 +178,3 @@ jobs:
178178
issue_number: issue_number,
179179
body: 'Your PR increases Bevy Minimum Supported Rust Version. Please update the `rust-version` field in the root Cargo.toml file.'
180180
});
181-
182-
make-macos-screenshots-available:
183-
runs-on: ubuntu-latest
184-
timeout-minutes: 30
185-
outputs:
186-
branch-name: ${{ steps.branch-name.outputs.result }}
187-
steps:
188-
- name: 'Download artifact'
189-
id: find-artifact
190-
uses: actions/github-script@v7
191-
with:
192-
result-encoding: string
193-
script: |
194-
var artifacts = await github.rest.actions.listWorkflowRunArtifacts({
195-
owner: context.repo.owner,
196-
repo: context.repo.repo,
197-
run_id: ${{github.event.workflow_run.id }},
198-
});
199-
var matchArtifacts = artifacts.data.artifacts.filter((artifact) => {
200-
return artifact.name == "screenshots-macos"
201-
});
202-
if (matchArtifacts.length == 0) { return "false" }
203-
var matchArtifact = matchArtifacts[0];
204-
var download = await github.rest.actions.downloadArtifact({
205-
owner: context.repo.owner,
206-
repo: context.repo.repo,
207-
artifact_id: matchArtifact.id,
208-
archive_format: 'zip',
209-
});
210-
var fs = require('fs');
211-
fs.writeFileSync('${{github.workspace}}/screenshots-macos.zip', Buffer.from(download.data));
212-
return "true"
213-
- name: prepare artifact folder
214-
run: |
215-
unzip screenshots-macos.zip
216-
mkdir screenshots
217-
mv screenshots-* screenshots/
218-
- name: save screenshots
219-
uses: actions/upload-artifact@v4
220-
with:
221-
name: screenshots-macos
222-
path: screenshots
223-
- name: branch name
224-
id: branch-name
225-
run: |
226-
if [ -f PR ]; then
227-
echo "result=PR-$(cat PR)-${{ github.event.workflow_run.head_branch }}" >> $GITHUB_OUTPUT
228-
else
229-
echo "result=${{ github.event.workflow_run.head_branch }}" >> $GITHUB_OUTPUT
230-
fi
231-
232-
compare-macos-screenshots:
233-
name: Compare macOS screenshots
234-
needs: [make-macos-screenshots-available]
235-
uses: ./.github/workflows/send-screenshots-to-pixeleagle.yml
236-
with:
237-
commit: ${{ github.event.workflow_run.head_sha }}
238-
branch: ${{ needs.make-macos-screenshots-available.outputs.branch-name }}
239-
artifact: screenshots-macos
240-
os: macos
241-
secrets: inherit

.github/workflows/ci.yml

Lines changed: 0 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ on:
55
pull_request:
66
push:
77
branches:
8-
- main
98
- release-*
109

1110
env:
@@ -254,49 +253,6 @@ jobs:
254253
echo 'if you use VSCode, you can also install `Typos Spell Checker'
255254
echo 'You can find the extension here: https://marketplace.visualstudio.com/items?itemName=tekumara.typos-vscode'
256255
257-
run-examples-macos-metal:
258-
runs-on: macos-latest
259-
timeout-minutes: 30
260-
steps:
261-
- uses: actions/checkout@v4
262-
- uses: dtolnay/rust-toolchain@stable
263-
- name: Disable audio
264-
# Disable audio through a patch. on github m1 runners, audio timeouts after 15 minutes
265-
run: git apply --ignore-whitespace tools/example-showcase/disable-audio.patch
266-
- name: Run examples
267-
run: |
268-
for example in .github/example-run/*.ron; do
269-
example_name=`basename $example .ron`
270-
echo -n $example_name > last_example_run
271-
echo "running $example_name - "`date`
272-
time TRACE_CHROME=trace-$example_name.json CI_TESTING_CONFIG=$example cargo run --example $example_name --features "bevy_ci_testing,trace,trace_chrome"
273-
sleep 10
274-
if [ `find ./ -maxdepth 1 -name 'screenshot-*.png' -print -quit` ]; then
275-
mkdir screenshots-$example_name
276-
mv screenshot-*.png screenshots-$example_name/
277-
fi
278-
done
279-
mkdir traces && mv trace*.json traces/
280-
mkdir screenshots && mv screenshots-* screenshots/
281-
- name: save traces
282-
uses: actions/upload-artifact@v4
283-
with:
284-
name: example-traces-macos
285-
path: traces
286-
- name: Save PR number
287-
if: ${{ github.event_name == 'pull_request' }}
288-
run: |
289-
echo ${{ github.event.number }} > ./screenshots/PR
290-
- name: save screenshots
291-
uses: actions/upload-artifact@v4
292-
with:
293-
name: screenshots-macos
294-
path: screenshots
295-
- uses: actions/upload-artifact@v4
296-
if: ${{ failure() && github.event_name == 'pull_request' }}
297-
with:
298-
name: example-run-macos
299-
path: example-run/
300256
check-doc:
301257
runs-on: ubuntu-latest
302258
timeout-minutes: 30
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
name: Example Run - PR Comments
2+
3+
# This workflow has write permissions on the repo
4+
# It must not checkout a PR and run untrusted code
5+
6+
# Also requesting write permissions on PR to be able to comment
7+
permissions:
8+
pull-requests: "write"
9+
10+
on:
11+
workflow_run:
12+
workflows: ["Example Run"]
13+
types:
14+
- completed
15+
16+
jobs:
17+
make-macos-screenshots-available:
18+
if: github.event.workflow_run.event == 'pull_request'
19+
runs-on: ubuntu-latest
20+
timeout-minutes: 30
21+
outputs:
22+
branch-name: ${{ steps.branch-name.outputs.result }}
23+
steps:
24+
- name: "Download artifact"
25+
id: find-artifact
26+
uses: actions/github-script@v7
27+
with:
28+
result-encoding: string
29+
script: |
30+
var artifacts = await github.rest.actions.listWorkflowRunArtifacts({
31+
owner: context.repo.owner,
32+
repo: context.repo.repo,
33+
run_id: ${{github.event.workflow_run.id }},
34+
});
35+
var matchArtifacts = artifacts.data.artifacts.filter((artifact) => {
36+
return artifact.name == "screenshots-macos"
37+
});
38+
if (matchArtifacts.length == 0) { return "false" }
39+
var matchArtifact = matchArtifacts[0];
40+
var download = await github.rest.actions.downloadArtifact({
41+
owner: context.repo.owner,
42+
repo: context.repo.repo,
43+
artifact_id: matchArtifact.id,
44+
archive_format: 'zip',
45+
});
46+
var fs = require('fs');
47+
fs.writeFileSync('${{github.workspace}}/screenshots-macos.zip', Buffer.from(download.data));
48+
return "true"
49+
- name: prepare artifact folder
50+
run: |
51+
unzip screenshots-macos.zip
52+
mkdir screenshots
53+
mv screenshots-* screenshots/
54+
- name: save screenshots
55+
uses: actions/upload-artifact@v4
56+
with:
57+
name: screenshots-macos
58+
path: screenshots
59+
- name: branch name
60+
id: branch-name
61+
run: |
62+
if [ -f PR ]; then
63+
echo "result=PR-$(cat PR)-${{ github.event.workflow_run.head_branch }}" >> $GITHUB_OUTPUT
64+
else
65+
echo "result=${{ github.event.workflow_run.head_branch }}" >> $GITHUB_OUTPUT
66+
fi
67+
68+
compare-macos-screenshots:
69+
name: Compare macOS screenshots
70+
needs: [make-macos-screenshots-available]
71+
uses: ./.github/workflows/send-screenshots-to-pixeleagle.yml
72+
with:
73+
commit: ${{ github.event.workflow_run.head_sha }}
74+
branch: ${{ needs.make-macos-screenshots-available.outputs.branch-name }}
75+
artifact: screenshots-macos
76+
os: macos
77+
secrets: inherit

.github/workflows/example-run.yml

Lines changed: 187 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,187 @@
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

Comments
 (0)