Skip to content

Commit 171fc9d

Browse files
committed
# Conflicts: # badges/coverage.svg
2 parents 837cef3 + 5108fbb commit 171fc9d

File tree

302 files changed

+97854
-35309
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

302 files changed

+97854
-35309
lines changed

.cargo/config.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
TARGET_DIR = { value = "target", relative = true }
33

44
[alias]
5-
xtask = "run --package xtask --"
5+
xtask = "run --manifest-path xtask/Cargo.toml --package xtask --"

.dockerignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
**/target
2+
**/Cargo.lock

.gitattributes

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
crates/bevy_script_api/providers/*.rs linguist-generated
2-
crates/bevy_script_api/providers/*.rs -diff -merge
1+
crates/bindings/**/* linguist-generated
2+
crates/bindings/**/* -diff -merge

.github/workflows/bencher_on_pr_or_fork.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ on:
66

77
jobs:
88
benchmark_fork_pr_branch:
9-
name: Run Fork PR Benchmarks
9+
name: Run PR Benchmarks
1010
runs-on: ubuntu-latest
1111
steps:
1212
- uses: actions/checkout@v4

.github/workflows/bevy_mod_scripting.yml

Lines changed: 48 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ jobs:
4444
base: main
4545
filters: |
4646
src:
47+
- 'bindings/**'
4748
- 'src/**'
4849
- 'crates/**'
4950
- 'examples/**'
@@ -75,8 +76,23 @@ jobs:
7576
jq -c . matrix.json > matrix-one-line.json
7677
echo "matrix=$(cat matrix-one-line.json)" >> $GITHUB_OUTPUT
7778
79+
check-is-fork:
80+
runs-on: ubuntu-latest
81+
outputs:
82+
is_fork: ${{ steps.check-fork.outputs.is_fork }}
83+
steps:
84+
- name: Check if fork
85+
id: check-fork
86+
run: |
87+
if [ "${{ github.event_name }}" == "pull_request" && "${{ github.repository }}" != "${{ github.event.pull_request.head.repo.full_name }}" ]; then
88+
echo "This is a forked repository."
89+
echo "is_fork=true" >> $GITHUB_OUTPUT
90+
else
91+
echo "This is not a forked repository."
92+
echo "is_fork=false" >> $GITHUB_OUTPUT
93+
fi
7894
check:
79-
needs: [check-needs-run, generate-job-matrix]
95+
needs: [check-needs-run, generate-job-matrix, check-is-fork]
8096
permissions:
8197
pull-requests: write
8298
contents: write
@@ -103,49 +119,57 @@ jobs:
103119
# # run: |
104120
# # sudo rm -rf /usr/share/dotnet; sudo rm -rf /opt/ghc; sudo rm -rf "/usr/local/share/boost"; sudo rm -rf "$AGENT_TOOLSDIRECTORY"
105121
- name: Checkout
106-
if: ${{ needs.check-needs-run.outputs.any-changes == 'true' }}
122+
if: ${{ needs.check-needs-run.outputs.any-changes == 'true' && (matrix.run_args.run_on_forks || needs.check-is-fork.outputs.is_fork != 'true') }}
107123
uses: actions/checkout@v4
108124
- uses: actions-rs/toolchain@v1
109-
if: ${{ needs.check-needs-run.outputs.any-changes == 'true' }}
125+
if: ${{ needs.check-needs-run.outputs.any-changes == 'true' && (matrix.run_args.run_on_forks || needs.check-is-fork.outputs.is_fork != 'true') }}
110126
with:
111127
toolchain: stable
112-
override: true
128+
override: false
129+
- name: Print versions
130+
if: ${{ needs.check-needs-run.outputs.any-changes == 'true' && (matrix.run_args.run_on_forks || needs.check-is-fork.outputs.is_fork != 'true') }}
131+
run: |
132+
echo "Rust version: $(rustc --version)"
133+
echo "Clippy version: $(cargo clippy --version)"
134+
echo "Active toolchain: $(rustup show active-toolchain)"
135+
continue-on-error: true
136+
113137
- name: Rust Cache
114-
if: ${{ needs.check-needs-run.outputs.any-changes == 'true' }}
138+
if: ${{ needs.check-needs-run.outputs.any-changes == 'true' && (matrix.run_args.run_on_forks || needs.check-is-fork.outputs.is_fork != 'true') }}
115139
uses: Swatinem/[email protected]
116140
with:
117141
# reasoning: we want to cache xtask, most of the jobs in the matrix will be sped up a good bit thanks to that
118142
save-if: ${{ github.ref == 'refs/heads/main' }}
119143
cache-all-crates: true
120144

121145
- name: Setup
122-
if: ${{ needs.check-needs-run.outputs.any-changes == 'true' }}
146+
if: ${{ needs.check-needs-run.outputs.any-changes == 'true' && (matrix.run_args.run_on_forks || needs.check-is-fork.outputs.is_fork != 'true') }}
123147
run: |
124148
cargo xtask init
125149
126150
- name: Setup GPU Drivers
127-
if: ${{ needs.check-needs-run.outputs.any-changes == 'true' && matrix.run_args.requires_gpu }}
151+
if: ${{ needs.check-needs-run.outputs.any-changes == 'true' && (matrix.run_args.run_on_forks || needs.check-is-fork.outputs.is_fork != 'true') && matrix.run_args.requires_gpu }}
128152
run: |
129153
sudo add-apt-repository ppa:kisak/turtle -y
130154
sudo apt-get install --no-install-recommends libxkbcommon-x11-0 xvfb libgl1-mesa-dri libxcb-xfixes0-dev mesa-vulkan-drivers
131155
- name: Check
132-
if: ${{ needs.check-needs-run.outputs.any-changes == 'true' && !matrix.run_args.requires_gpu }}
156+
if: ${{ needs.check-needs-run.outputs.any-changes == 'true' && (matrix.run_args.run_on_forks || needs.check-is-fork.outputs.is_fork != 'true') && !matrix.run_args.requires_gpu }}
133157
run: |
134158
${{ matrix.run_args.command }}
135159
- name: Check With virtual X11 server
136-
if: ${{ needs.check-needs-run.outputs.any-changes == 'true' && matrix.run_args.requires_gpu }}
160+
if: ${{ needs.check-needs-run.outputs.any-changes == 'true' && (matrix.run_args.run_on_forks || needs.check-is-fork.outputs.is_fork != 'true') && matrix.run_args.requires_gpu }}
137161
run: |
138162
xvfb-run ${{ matrix.run_args.command }}
139163
140164
- name: Upload coverage artifact
141-
if: ${{ needs.check-needs-run.outputs.any-changes == 'true' && matrix.run_args.generates_coverage }}
165+
if: ${{ needs.check-needs-run.outputs.any-changes == 'true' && (matrix.run_args.run_on_forks || needs.check-is-fork.outputs.is_fork != 'true') && matrix.run_args.generates_coverage }}
142166
uses: actions/upload-artifact@v4
143167
with:
144168
name: code-coverage-report
145169
path: target/coverage/html/
146170

147171
- name: Update coverage badge
148-
if: ${{ needs.check-needs-run.outputs.any-changes == 'true' && matrix.run_args.generates_coverage }}
172+
if: ${{ needs.check-needs-run.outputs.any-changes == 'true' && (matrix.run_args.run_on_forks || needs.check-is-fork.outputs.is_fork != 'true') && matrix.run_args.generates_coverage }}
149173
continue-on-error: true
150174
run: |
151175
git checkout -b chore/_update-coverage-badge || git checkout chore/_update-coverage-badge
@@ -164,43 +188,18 @@ jobs:
164188
PRNUMBER=$(cat pr_number.txt)
165189
gh pr merge $PRNUMBER --squash
166190
fi
167-
generate_bindings:
168-
name: Bindings - Synchronise
169-
permissions:
170-
contents: write
171-
pull-requests: write
191+
192+
rollup-check:
193+
name: Required Checks Successful
194+
needs: [check]
172195
runs-on: ubuntu-latest
196+
if: ${{ always() }}
173197
steps:
174-
- name: Checkout
175-
uses: actions/checkout@v4
176-
with:
177-
ref: ${{ github.head_ref || github.ref_name }}
178-
- name: Rust Cache
179-
if: ${{ needs.check-needs-run.outputs.any-changes == 'true' }}
180-
uses: Swatinem/[email protected]
181-
with:
182-
# reasoning: we want to cache xtask, most of the jobs in the matrix will be sped up a good bit thanks to that
183-
save-if: ${{ github.ref == 'refs/heads/main' }}
184-
cache-all-crates: true
185-
- name: Setup Bot GitHub Credentials
186-
run: |
187-
git config user.name "github-actions[bot]"
188-
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
189-
- name: Setup
190-
run: |
191-
cargo xtask init
192-
- name: Generate Bindings
193-
run: |
194-
cargo xtask codegen
195-
- name: Check for changes
196-
id: check_changes
197-
run: |
198-
if [[ -n $(git status --porcelain) ]]; then
199-
echo "changes=true" >> "$GITHUB_OUTPUT";
200-
fi
201-
- name: Commit Changes
202-
if: steps.check_changes.outputs.changes
203-
run: |
204-
git add -A
205-
git commit -m "chore(codegen): update bevy bindings"
206-
git push
198+
- name: Check if all jobs succeeded
199+
run: |
200+
if [[ "${{ needs.check.result }}" != "success" ]]; then
201+
echo "One or more checks failed. See detailed job results above."
202+
exit 1
203+
else
204+
echo "All checks passed successfully!"
205+
fi
Lines changed: 44 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,59 @@
1-
on:
2-
workflow_dispatch:
3-
1+
name: Build and Push Docker Image
42

5-
env:
6-
REGISTRY: ghcr.io
7-
IMAGE_NAME: bevy-mod-scripting
3+
on:
4+
workflow_dispatch: # Allow manual triggering
85

96
jobs:
10-
build-runner-image:
7+
docker:
8+
runs-on: ubuntu-latest
119
permissions:
1210
contents: read
1311
packages: write
14-
runs-on: ubuntu-latest
15-
name: Build multi-platform Docker image
16-
outputs:
17-
image: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.meta.outputs.tags }}
12+
1813
steps:
19-
- uses: actions/checkout@v4
20-
- uses: docker/setup-qemu-action@v3
21-
- uses: docker/setup-buildx-action@v3
22-
- name: Docker meta
23-
id: meta
24-
uses: docker/metadata-action@v5
14+
- name: Checkout repository
15+
uses: actions/checkout@v4
16+
with:
17+
submodules: 'recursive'
18+
19+
- name: Set up Docker Buildx
20+
uses: docker/setup-buildx-action@v3
21+
22+
- name: Set up QEMU
23+
uses: docker/setup-qemu-action@v3
2524
with:
26-
images: |
27-
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
28-
- name: Login to GitHub Container Registry
25+
platforms: 'arm64,amd64'
26+
27+
- name: Login to DockerHub
28+
if: github.event_name != 'pull_request'
2929
uses: docker/login-action@v3
3030
with:
31-
registry: ghcr.io
32-
username: ${{ github.actor }}
33-
password: ${{ secrets.GITHUB_TOKEN }}
34-
- uses: docker/build-push-action@v5
31+
username: ${{ secrets.DOCKERHUB_USER }}
32+
password: ${{ secrets.DOCKERHUB_TOKEN }}
33+
34+
- name: Extract metadata for Docker
35+
id: meta
36+
uses: docker/metadata-action@v5
37+
with:
38+
images: makspll/bevy_mod_scripting
39+
flavor: |
40+
prefix=xtask-
41+
tags: |
42+
type=ref,event=branch
43+
type=ref,event=pr
44+
type=semver,pattern={{version}}
45+
type=semver,pattern={{major}}.{{minor}}
46+
type=sha,format=short
47+
type=raw,value=latest,enable=${{ github.ref == format('refs/heads/{0}', github.event.repository.default_branch) }}
48+
49+
- name: Build and push Docker image
50+
uses: docker/build-push-action@v5
3551
with:
3652
context: .
37-
file: ./crates/xtask/Dockerfile
53+
file: ./Dockerfile
3854
platforms: linux/amd64,linux/arm64
39-
cache-from: type=gha
40-
cache-to: type=gha,mode=max
55+
push: true
4156
tags: ${{ steps.meta.outputs.tags }}
4257
labels: ${{ steps.meta.outputs.labels }}
58+
cache-from: type=gha
59+
cache-to: type=gha,mode=max

.github/workflows/pr-titles.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ jobs:
2828
docs
2929
refactor
3030
perf
31+
changed
3132
3233
scopes: |
3334
ladfile
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
on:
2+
pull_request:
3+
types: [opened, reopened, edited, synchronize]
4+
5+
name: Synchronize Bindings
6+
7+
concurrency:
8+
group: ${{ github.workflow }}-${{ github.ref == 'refs/heads/main' && github.run_id || github.event.pull_request.number || github.ref }}
9+
cancel-in-progress: true
10+
11+
jobs:
12+
generate_bindings:
13+
name: Generate Diff
14+
runs-on: ubuntu-latest
15+
steps:
16+
- name: Checkout
17+
uses: actions/checkout@v4
18+
- name: Rust Cache
19+
uses: Swatinem/[email protected]
20+
with:
21+
save-if: ${{ github.ref == 'refs/heads/main' }}
22+
cache-all-crates: true
23+
- name: Setup
24+
run: |
25+
cargo xtask init
26+
- name: Generate Bindings
27+
run: |
28+
cargo xtask codegen
29+
cargo fmt
30+
- name: Check for changes and create diff
31+
id: check_changes
32+
run: |
33+
if [[ -n $(git status --porcelain) ]]; then
34+
echo "changes=true" >> "$GITHUB_OUTPUT"
35+
git diff > bindings.diff
36+
echo "Diff created:"
37+
cat bindings.diff
38+
else
39+
echo "changes=false" >> "$GITHUB_OUTPUT"
40+
fi
41+
- name: Upload Diff Artifact
42+
if: steps.check_changes.outputs.changes == 'true'
43+
uses: actions/upload-artifact@v4
44+
with:
45+
name: bindings.diff
46+
path: bindings.diff
47+
retention-days: 1
48+
- name: Upload GitHub Pull Request Event
49+
uses: actions/upload-artifact@v4
50+
with:
51+
name: event-bindings.json
52+
path: ${{ github.event_path }}
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
on:
2+
workflow_run:
3+
workflows: [Synchronize Bindings]
4+
types: [completed]
5+
6+
name: Synchronize Bindings (Check Diff)
7+
8+
permissions: write-all
9+
10+
jobs:
11+
apply_fork_bindings:
12+
name: Apply Bindings (Fork)
13+
runs-on: ubuntu-latest
14+
if: github.event.workflow_run.conclusion == 'success'
15+
env:
16+
DIFF_ARTIFACT: bindings.diff
17+
PR_EVENT: event-bindings.json
18+
steps:
19+
- name: Download Benchmark Results
20+
uses: dawidd6/action-download-artifact@v6
21+
with:
22+
name: ${{ env.DIFF_ARTIFACT }}
23+
run_id: ${{ github.event.workflow_run.id }}
24+
- name: Download PR Event
25+
uses: dawidd6/action-download-artifact@v6
26+
with:
27+
name: ${{ env.PR_EVENT }}
28+
run_id: ${{ github.event.workflow_run.id }}
29+
- name: Export PR Event Data
30+
uses: actions/github-script@v6
31+
with:
32+
script: |
33+
let fs = require('fs');
34+
let prEvent = JSON.parse(fs.readFileSync(process.env.PR_EVENT, {encoding: 'utf8'}));
35+
core.exportVariable("PR_HEAD", prEvent.pull_request.head.ref);
36+
core.exportVariable("PR_BASE", prEvent.pull_request.base.ref);
37+
core.exportVariable("PR_BASE_SHA", prEvent.pull_request.base.sha);
38+
core.exportVariable("PR_NUMBER", prEvent.number);
39+
core.exportVariable("HEAD_REPO", prEvent.pull_request.head.repo.full_name);
40+
core.exportVariable("HEAD_REPO_URL", prEvent.pull_request.head.repo.git_url);
41+
- name: Fail PR With URL
42+
uses: actions/github-script@v6
43+
with:
44+
script: |
45+
core.setFailed(`Running `cargo xtask codegen` produces changes in the bindings, please make sure to run this command locally and commit the changes to the PR.`);
46+
47+
48+
49+

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ assets/scripts/tlconfig.lua
1515
**.log
1616
**build/
1717
.html
18+
.idea/
1819

1920
/assets/**/*.lad.json
20-
/docs/src/ladfiles/*.lad.json
21+
/docs/src/ladfiles/*.lad.json

0 commit comments

Comments
 (0)