33 branches :
44 - main
55 - staging
6- paths-ignore :
7- - ' .github/workflows/release-plz.yml'
8- - ' docs/**'
96 pull_request :
107 branches :
118 - " **"
12- paths-ignore :
13- - ' .github/workflows/release-plz.yml'
14- - ' docs/**'
159
1610
1711name : CI
@@ -31,6 +25,31 @@ concurrency:
3125 cancel-in-progress : true
3226
3327jobs :
28+
29+ check-needs-run :
30+ runs-on : ubuntu-latest
31+ outputs :
32+ any-changes : ${{ steps.changes.outputs.src }}
33+ permissions :
34+ pull-requests : read
35+ contents : read
36+ steps :
37+ - name : Checkout
38+ uses : actions/checkout@v4
39+ - uses : dorny/paths-filter@v3
40+ id : changes
41+ with :
42+ base : main
43+ filters : |
44+ src:
45+ - 'src/**'
46+ - 'crates/**'
47+ - 'examples/**'
48+ - 'assets/**'
49+ - 'docs/**'
50+ - '.github/workflows/bevy_mod_scripting.yml'
51+
52+
3453 generate-job-matrix :
3554 runs-on : ubuntu-latest
3655 # container: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest
3958 steps :
4059 - name : Checkout
4160 uses : actions/checkout@v4
61+ - name : Rust Cache
62+ 63+ with :
64+ # reasoning: we want to cache xtask, most of the jobs in the matrix will be sped up a good bit thanks to that
65+ save-if : ${{ github.ref == 'refs/heads/main' }}
66+ cache-all-crates : true
4267 - name : Generate matrix
4368 id : generate-matrix
4469 run : |
@@ -49,52 +74,75 @@ jobs:
4974 echo "matrix=$(cat matrix-one-line.json)" >> $GITHUB_OUTPUT
5075
5176 check :
77+ needs : [check-needs-run, generate-job-matrix]
5278 permissions :
5379 pull-requests : write
5480 contents : write
5581 issues : write
5682 name : Check - ${{ matrix.run_args.name }}
5783 runs-on : ${{ matrix.run_args.os }}
58- # container: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest
59- needs :
60- - generate-job-matrix
6184 strategy :
6285 matrix :
6386 run_args : ${{fromJson(needs.generate-job-matrix.outputs.matrix)}}
6487 steps :
88+ # - name: Free Disk Space (Ubuntu)
89+ # if: runner.os == 'Linux'
90+ # uses: jlumbroso/free-disk-space@main
91+ # with:
92+ # tool-cache: false
93+ # android: true
94+ # dotnet: true
95+ # haskell: true
96+ # large-packages: true
97+ # docker-images: true
98+ # swap-storage: true
99+ # # - if: runner.os == 'linux'
100+ # # run: |
101+ # # sudo rm -rf /usr/share/dotnet; sudo rm -rf /opt/ghc; sudo rm -rf "/usr/local/share/boost"; sudo rm -rf "$AGENT_TOOLSDIRECTORY"
65102 - name : Checkout
103+ if : ${{ needs.check-needs-run.outputs.any-changes == 'true' }}
66104 uses : actions/checkout@v4
67-
68- - name : Install alsa and udev
69- if : runner.os == 'linux'
70- run : |
71- sudo apt-get update; sudo apt-get install --no-install-recommends libasound2-dev libudev-dev
72- sudo rm -rf /usr/share/dotnet; sudo rm -rf /opt/ghc; sudo rm -rf "/usr/local/share/boost"; sudo rm -rf "$AGENT_TOOLSDIRECTORY"
73105 - uses : actions-rs/toolchain@v1
106+ if : ${{ needs.check-needs-run.outputs.any-changes == 'true' }}
74107 with :
75108 toolchain : stable
76109 override : true
77-
78110 - name : Rust Cache
79- 111+ if : ${{ needs.check-needs-run.outputs.any-changes == 'true' }}
112+ 113+ with :
114+ # reasoning: we want to cache xtask, most of the jobs in the matrix will be sped up a good bit thanks to that
115+ save-if : ${{ github.ref == 'refs/heads/main' }}
116+ cache-all-crates : true
80117
81118 - name : Setup
119+ if : ${{ needs.check-needs-run.outputs.any-changes == 'true' }}
82120 run : |
83121 cargo xtask init
84122
123+ - name : Setup GPU Drivers
124+ if : ${{ needs.check-needs-run.outputs.any-changes == 'true' && matrix.run_args.requires_gpu }}
125+ run : |
126+ sudo add-apt-repository ppa:kisak/turtle -y
127+ sudo apt-get install --no-install-recommends libxkbcommon-x11-0 xvfb libgl1-mesa-dri libxcb-xfixes0-dev mesa-vulkan-drivers
85128 - name : Check
129+ if : ${{ needs.check-needs-run.outputs.any-changes == 'true' && !matrix.run_args.requires_gpu }}
86130 run : |
87131 ${{ matrix.run_args.command }}
132+ - name : Check With virtual X11 server
133+ if : ${{ needs.check-needs-run.outputs.any-changes == 'true' && matrix.run_args.requires_gpu }}
134+ run : |
135+ xvfb-run ${{ matrix.run_args.command }}
88136
89137 - name : Upload coverage artifact
90- if : ${{ matrix.run_args.generates_coverage }}
138+ if : ${{ needs.check-needs-run.outputs.any-changes == 'true' && matrix.run_args.generates_coverage }}
91139 uses : actions/upload-artifact@v4
92140 with :
93141 name : code-coverage-report
94142 path : target/coverage/html/
95143
96144 - name : Update coverage badge
97- if : ${{ matrix.run_args.generates_coverage }}
145+ if : ${{ needs.check-needs-run.outputs.any-changes == 'true' && matrix.run_args.generates_coverage }}
98146 continue-on-error : true
99147 run : |
100148 git checkout -b chore/_update-coverage-badge || git checkout chore/_update-coverage-badge
@@ -122,6 +170,15 @@ jobs:
122170 steps :
123171 - name : Checkout
124172 uses : actions/checkout@v4
173+ with :
174+ ref : ${{ github.head_ref || github.ref_name }}
175+ - name : Rust Cache
176+ if : ${{ needs.check-needs-run.outputs.any-changes == 'true' }}
177+ 178+ with :
179+ # reasoning: we want to cache xtask, most of the jobs in the matrix will be sped up a good bit thanks to that
180+ save-if : ${{ github.ref == 'refs/heads/main' }}
181+ cache-all-crates : true
125182 - name : Setup Bot GitHub Credentials
126183 run : |
127184 git config user.name "github-actions[bot]"
@@ -141,19 +198,6 @@ jobs:
141198 - name : Commit Changes
142199 if : steps.check_changes.outputs.changes
143200 run : |
144- git checkout -b ${{ env.CODEGEN_BRANCH_NAME }} || git checkout ${{ env.CODEGEN_BRANCH_NAME }}
145201 git add -A
146202 git commit -m "chore(codegen): update bevy bindings"
147- git push -u origin ${{ env.CODEGEN_BRANCH_NAME }} --force
148- - uses : jwalton/gh-find-current-pr@master
149- if : steps.check_changes.outputs.changes
150- id : findPR
151- with :
152- state : all
153- - name : Create Or Update PR
154- if : steps.check_changes.outputs.changes && success() && steps.findPR.outputs.number
155- run : |
156- gh pr list --base ${{ github.ref }} --search "chore(codegen): update bevy bindings" --json number > prs.json
157- if [ $(jq '. | length' prs.json) -eq 0 ]; then
158- gh pr create --title "chore(codegen): update bevy bindings" --body "This PR updates the bevy bindings for #${{ steps.findPR.outputs.number }}" --base ${{ github.ref }} --head ${{ env.CODEGEN_BRANCH_NAME }} || true
159- fi
203+ git push
0 commit comments