11on :
22 push :
3+ branches :
4+ - main
5+ - staging
6+ paths-ignore :
7+ - ' .github/workflows/release-plz.yml'
8+ - ' docs/**'
9+ pull_request :
310 branches :
411 - " **"
512 paths-ignore :
6- - ' crates/bevy_api_gen/**'
7- - ' crates/macro_tests/**'
813 - ' .github/workflows/release-plz.yml'
9- - ' .github/workflows/bevy_api_gen.yml'
10- - ' .github/workflows/macro_tests.yml'
1114 - ' docs/**'
1215
1316
14- name : Check and Lint - bevy_mod_scripting
17+ name : CI
18+
19+
20+ env :
21+ REGISTRY : ghcr.io
22+ IMAGE_NAME : bevy-mod-scripting
23+ CODEGEN_BRANCH_NAME : __update-bevy-bindings-${{ github.head_ref || github.ref_name }}
24+ GH_TOKEN : ${{ github.token }}
1525
1626concurrency :
1727 # Use github.run_id on main branch
@@ -21,120 +31,121 @@ concurrency:
2131 cancel-in-progress : true
2232
2333jobs :
24- check :
25- name : Check - ${{ matrix.run_args.label }}
34+ generate-job-matrix :
35+ runs-on : ubuntu-latest
36+ # container: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest
37+ outputs :
38+ matrix : ${{ steps.generate-matrix.outputs.matrix }}
39+ steps :
40+ - name : Checkout
41+ uses : actions/checkout@v4
42+ - name : Generate matrix
43+ id : generate-matrix
44+ run : |
45+ cargo xtask ci-matrix > matrix.json
46+ cat matrix.json
47+ echo "Convert to single line JSON"
48+ jq -c . matrix.json > matrix-one-line.json
49+ echo "matrix=$(cat matrix-one-line.json)" >> $GITHUB_OUTPUT
50+
51+ check :
52+ permissions :
53+ pull-requests : write
54+ contents : write
55+ name : Check - ${{ matrix.run_args.name }}
2656 runs-on : ${{ matrix.run_args.os }}
57+ # container: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest
58+ needs :
59+ - generate-job-matrix
2760 strategy :
2861 matrix :
29- run_args : [
30- {label: Windows - All Features, os: windows-latest, features: "lua54,rhai,teal,lua_script_api,rhai_script_api,rune", cross: x86_64-pc-windows-msvc },
31- {label: MacOS - All Features, os: macOS-latest, features: "lua54,rhai,teal,lua_script_api,rhai_script_api,rune", cross: x86_64-apple-darwin },
32- {label: Ubuntu - All Features, os: ubuntu-latest, features: "lua54,lua_script_api,rhai,teal,rhai_script_api,rune", cross: x86_64-unknown-linux-gnu },
33- {label: Ubuntu Aarch64 - All Features, os: ubuntu-latest, features: "lua54,rhai,teal,lua_script_api,rhai_script_api,rune", cross: aarch64-unknown-linux-gnu },
34- {label: Ubuntu - Lua51, os: ubuntu-latest, features: "lua51,lua_script_api", cross: x86_64-unknown-linux-gnu },
35- {label: Ubuntu - Lua52, os: ubuntu-latest, features: "lua52,lua_script_api", cross: x86_64-unknown-linux-gnu },
36- {label: Ubuntu - Lua53, os: ubuntu-latest, features: "lua53,lua_script_api", cross: x86_64-unknown-linux-gnu },
37- {label: Ubuntu - Luajit, os: ubuntu-latest, features: "luajit,lua_script_api", cross: x86_64-unknown-linux-gnu },
38- {label: Ubuntu - Luajit52, os: ubuntu-latest, features: "luajit52,lua_script_api", cross: x86_64-unknown-linux-gnu },
39- {label: Ubuntu - Luau, os: ubuntu-latest, features: "luau,lua_script_api", cross: x86_64-unknown-linux-gnu }
40-
41- ]
62+ run_args : ${{fromJson(needs.generate-job-matrix.outputs.matrix)}}
4263 steps :
43- - if : runner.os == 'linux'
44- name : Install alsa and udev
45- run : sudo apt-get update; sudo apt-get install --no-install-recommends libasound2-dev libudev-dev
46- - uses : actions/checkout@v2
47- - uses : actions-rs/toolchain@v1
48- with :
49- profile : minimal
50- toolchain : stable
51- override : true
52- - name : Rust Cache
53- 54- - if : runner.os != 'windows'
55- name : Clear space
56- run : rm -rf /usr/share/dotnet; rm -rf /opt/ghc; rm -rf "/usr/local/share/boost"; rm -rf "$AGENT_TOOLSDIRECTORY"
57- - uses : houseabsolute/actions-rust-cross@v0
58- with :
59- command : check
60- target : ${{ matrix.run_args.cross }}
61- args : --workspace --features=${{ matrix.run_args.features }} --profile=ephemeral-build
64+ - name : Checkout
65+ uses : actions/checkout@v4
6266
63- fmt :
64- name : Rustfmt
65- runs-on : ubuntu-latest
66- steps :
6767 - name : Install alsa and udev
68- run : sudo apt-get update; sudo apt-get install --no-install-recommends libasound2-dev libudev-dev
69- - uses : actions/checkout@v2
68+ if : runner.os == 'linux'
69+ run : |
70+ sudo apt-get update; sudo apt-get install --no-install-recommends libasound2-dev libudev-dev
71+ sudo rm -rf /usr/share/dotnet; sudo rm -rf /opt/ghc; sudo rm -rf "/usr/local/share/boost"; sudo rm -rf "$AGENT_TOOLSDIRECTORY"
7072 - uses : actions-rs/toolchain@v1
7173 with :
72- profile : minimal
73- components : rustfmt
7474 toolchain : stable
7575 override : true
76- - name : Rust Cache
77- 78- - uses : actions-rs/cargo@v1
79- with :
80- command : fmt
81- args : --all -- --check
8276
83- clippy :
84- name : Clippy
85- runs-on : ubuntu-latest
86- steps :
87- - name : Install alsa and udev
88- run : sudo apt-get update; sudo apt-get install --no-install-recommends libasound2-dev libudev-dev
89- - uses : actions/checkout@v2
90- - uses : actions-rs/toolchain@v1
91- with :
92- toolchain : stable
93- components : clippy
94- override : true
95- - name : Rust Cache
96- 97- - uses : actions-rs/cargo@v1
98- with :
99- command : clippy
100- args : --features=lua54,rhai,teal,lua_script_api,rhai_script_api,rune --profile=ephemeral-build -- -D warnings
101- tests :
102- name : Tests
103- runs-on : ubuntu-latest
104- steps :
105- - name : Clear space
106- run : sudo rm -rf /usr/share/dotnet; sudo rm -rf /opt/ghc; sudo rm -rf "/usr/local/share/boost"; sudo rm -rf "$AGENT_TOOLSDIRECTORY"
107- - name : Checkout
108- uses : actions/checkout@v3
109- - name : Install alsa and udev
110- run : sudo apt-get update; sudo apt-get install --no-install-recommends libasound2-dev libudev-dev
111- - uses : actions-rs/toolchain@v1
112- with :
113- toolchain : stable
114- override : true
11577 - name : Rust Cache
11678117- - uses : actions-rs/cargo@v1
79+
80+ - name : Setup
81+ run : |
82+ cargo xtask init
83+
84+ - name : Check
85+ run : |
86+ ${{ matrix.run_args.command }}
87+
88+ - name : Upload coverage artifact
89+ if : ${{ matrix.run_args.generates_coverage }}
90+ uses : actions/upload-artifact@v4
11891 with :
119- command : test
120- args : --workspace --features=lua54,rhai,teal,lua_script_api,rhai_script_api,rune --profile=ephemeral-build
121- docs :
122- name : Docs
92+ name : code-coverage-report
93+ path : target/coverage/html/
94+
95+ - name : Update coverage badge
96+ if : ${{ matrix.run_args.generates_coverage && github.ref == 'refs/heads/main' }}
97+ run : |
98+ cp target/coverage/html/badges/for_the_badge.svg badges/coverage.svg
99+
100+ git config user.name "github-actions[bot]"
101+ git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
102+ git add badges/coverage.svg
103+
104+ if [[ -n $(git status -s) ]]; then
105+ git commit -m "chore(badge): Update coverage badge" -m "[skip ci]"
106+ git push
107+ fi
108+ generate_bindings :
109+ name : Bindings - Synchronise
110+ permissions :
111+ contents : write
112+ pull-requests : write
123113 runs-on : ubuntu-latest
124114 steps :
125- - name : Install alsa and udev
126- run : sudo apt-get update; sudo apt-get install --no-install-recommends libasound2-dev libudev-dev
127- - uses : actions/checkout@v2
128- - uses : actions-rs/toolchain@v1
129- with :
130- toolchain : stable
131- override : true
132- - name : Rust Cache
133- 134- - name : Find docs.rs features
135- run : echo "DOCS_FEATURES=$(cargo metadata --no-deps | python -c "import sys,json; [print(','.join(x['metadata']['docs.rs']['features'])) for x in json.load(sys.stdin)['packages'] if x['name'] == 'bevy_mod_scripting']")" >> $GITHUB_OUTPUT
136- id : features
137- - uses : actions-rs/cargo@v1
138- with :
139- command : doc
140- args : --workspace --features=${{ steps.features.outputs.DOCS_FEATURES }} --profile=ephemeral-build
115+ - name : Checkout
116+ uses : actions/checkout@v4
117+ - name : Setup Bot GitHub Credentials
118+ run : |
119+ git config user.name "github-actions[bot]"
120+ git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
121+ - name : Setup
122+ run : |
123+ cargo xtask init
124+ - name : Generate Bindings
125+ run : |
126+ cargo xtask codegen
127+ - name : Check for changes
128+ id : check_changes
129+ run : |
130+ if [[ -n $(git status --porcelain) ]]; then
131+ echo "changes=true" >> "$GITHUB_OUTPUT";
132+ fi
133+ - name : Commit Changes
134+ if : steps.check_changes.outputs.changes
135+ run : |
136+ git checkout -b ${{ env.CODEGEN_BRANCH_NAME }} || git checkout ${{ env.CODEGEN_BRANCH_NAME }}
137+ git add -A
138+ git commit -m "chore(codegen): update bevy bindings"
139+ git push -u origin ${{ env.CODEGEN_BRANCH_NAME }} --force
140+ - uses : jwalton/gh-find-current-pr@master
141+ if : steps.check_changes.outputs.changes
142+ id : findPR
143+ with :
144+ state : all
145+ - name : Create Or Update PR
146+ if : steps.check_changes.outputs.changes && success() && steps.findPR.outputs.number
147+ run : |
148+ gh pr list --base ${{ github.ref }} --search "chore(codegen): update bevy bindings" --json number > prs.json
149+ if [ $(jq '. | length' prs.json) -eq 0 ]; then
150+ 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
151+ fi
0 commit comments