diff --git a/.github/workflows/bencher_on_pr_or_fork.yml b/.github/workflows/bencher_on_pr_or_fork.yml index 48699a1295..17c8651596 100644 --- a/.github/workflows/bencher_on_pr_or_fork.yml +++ b/.github/workflows/bencher_on_pr_or_fork.yml @@ -6,7 +6,7 @@ on: jobs: benchmark_fork_pr_branch: - name: Run Fork PR Benchmarks + name: Run PR Benchmarks runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 diff --git a/.github/workflows/bevy_mod_scripting.yml b/.github/workflows/bevy_mod_scripting.yml index 1d65b982e3..d686faa960 100644 --- a/.github/workflows/bevy_mod_scripting.yml +++ b/.github/workflows/bevy_mod_scripting.yml @@ -75,8 +75,21 @@ jobs: jq -c . matrix.json > matrix-one-line.json echo "matrix=$(cat matrix-one-line.json)" >> $GITHUB_OUTPUT + check-is-fork: + runs-on: ubuntu-latest + outputs: + is_fork: ${{ steps.check-fork.outputs.is_fork }} + steps: + - name: Check if fork + id: check-fork + run: | + if [ "${{ github.repository }}" != "${{ github.event.pull_request.head.repo.full_name }}" ]; then + echo "is_fork=true" >> $GITHUB_OUTPUT + else + echo "is_fork=false" >> $GITHUB_OUTPUT + fi check: - needs: [check-needs-run, generate-job-matrix] + needs: [check-needs-run, generate-job-matrix, check-is-fork] permissions: pull-requests: write contents: write @@ -103,15 +116,15 @@ jobs: # # run: | # # sudo rm -rf /usr/share/dotnet; sudo rm -rf /opt/ghc; sudo rm -rf "/usr/local/share/boost"; sudo rm -rf "$AGENT_TOOLSDIRECTORY" - name: Checkout - if: ${{ needs.check-needs-run.outputs.any-changes == 'true' }} + if: ${{ needs.check-needs-run.outputs.any-changes == 'true' && (matrix.run_args.run_on_forks == 'true' || needs.check-is-fork.is_fork != 'true') }} uses: actions/checkout@v4 - uses: actions-rs/toolchain@v1 - if: ${{ needs.check-needs-run.outputs.any-changes == 'true' }} + if: ${{ needs.check-needs-run.outputs.any-changes == 'true' && (matrix.run_args.run_on_forks == 'true' || needs.check-is-fork.is_fork != 'true') }} with: toolchain: stable override: true - name: Rust Cache - if: ${{ needs.check-needs-run.outputs.any-changes == 'true' }} + if: ${{ needs.check-needs-run.outputs.any-changes == 'true' && (matrix.run_args.run_on_forks == 'true' || needs.check-is-fork.is_fork != 'true') }} uses: Swatinem/rust-cache@v2.7.7 with: # reasoning: we want to cache xtask, most of the jobs in the matrix will be sped up a good bit thanks to that @@ -119,33 +132,33 @@ jobs: cache-all-crates: true - name: Setup - if: ${{ needs.check-needs-run.outputs.any-changes == 'true' }} + if: ${{ needs.check-needs-run.outputs.any-changes == 'true' && (matrix.run_args.run_on_forks == 'true' || needs.check-is-fork.is_fork != 'true') }} run: | cargo xtask init - name: Setup GPU Drivers - if: ${{ needs.check-needs-run.outputs.any-changes == 'true' && matrix.run_args.requires_gpu }} + if: ${{ needs.check-needs-run.outputs.any-changes == 'true' && (matrix.run_args.run_on_forks == 'true' || needs.check-is-fork.is_fork != 'true') && matrix.run_args.requires_gpu }} run: | sudo add-apt-repository ppa:kisak/turtle -y sudo apt-get install --no-install-recommends libxkbcommon-x11-0 xvfb libgl1-mesa-dri libxcb-xfixes0-dev mesa-vulkan-drivers - name: Check - if: ${{ needs.check-needs-run.outputs.any-changes == 'true' && !matrix.run_args.requires_gpu }} + if: ${{ needs.check-needs-run.outputs.any-changes == 'true' && (matrix.run_args.run_on_forks == 'true' || needs.check-is-fork.is_fork != 'true') && !matrix.run_args.requires_gpu }} run: | ${{ matrix.run_args.command }} - name: Check With virtual X11 server - if: ${{ needs.check-needs-run.outputs.any-changes == 'true' && matrix.run_args.requires_gpu }} + if: ${{ needs.check-needs-run.outputs.any-changes == 'true' && (matrix.run_args.run_on_forks == 'true' || needs.check-is-fork.is_fork != 'true') && matrix.run_args.requires_gpu }} run: | xvfb-run ${{ matrix.run_args.command }} - name: Upload coverage artifact - if: ${{ needs.check-needs-run.outputs.any-changes == 'true' && matrix.run_args.generates_coverage }} + if: ${{ needs.check-needs-run.outputs.any-changes == 'true' && (matrix.run_args.run_on_forks == 'true' || needs.check-is-fork.is_fork != 'true') && matrix.run_args.generates_coverage }} uses: actions/upload-artifact@v4 with: name: code-coverage-report path: target/coverage/html/ - name: Update coverage badge - if: ${{ needs.check-needs-run.outputs.any-changes == 'true' && matrix.run_args.generates_coverage }} + if: ${{ needs.check-needs-run.outputs.any-changes == 'true' && (matrix.run_args.run_on_forks == 'true' || needs.check-is-fork.is_fork != 'true') && matrix.run_args.generates_coverage }} continue-on-error: true run: | git checkout -b chore/_update-coverage-badge || git checkout chore/_update-coverage-badge @@ -163,45 +176,4 @@ jobs: sed -n 's/.*pull\/\([0-9]*\).*/\1/p' pr.txt > pr_number.txt PRNUMBER=$(cat pr_number.txt) gh pr merge $PRNUMBER --squash - fi - generate_bindings: - name: Bindings - Synchronise - permissions: - contents: write - pull-requests: write - runs-on: ubuntu-latest - if: github.repository_owner == 'makspll' - steps: - - name: Checkout - uses: actions/checkout@v4 - with: - ref: ${{ github.head_ref || github.ref_name }} - - name: Rust Cache - if: ${{ needs.check-needs-run.outputs.any-changes == 'true' }} - uses: Swatinem/rust-cache@v2.7.7 - with: - # reasoning: we want to cache xtask, most of the jobs in the matrix will be sped up a good bit thanks to that - save-if: ${{ github.ref == 'refs/heads/main' }} - cache-all-crates: true - - name: Setup Bot GitHub Credentials - run: | - git config user.name "github-actions[bot]" - git config user.email "41898282+github-actions[bot]@users.noreply.github.com" - - name: Setup - run: | - cargo xtask init - - name: Generate Bindings - run: | - cargo xtask codegen - - name: Check for changes - id: check_changes - run: | - if [[ -n $(git status --porcelain) ]]; then - echo "changes=true" >> "$GITHUB_OUTPUT"; - fi - - name: Commit Changes - if: steps.check_changes.outputs.changes - run: | - git add -A - git commit -m "chore(codegen): update bevy bindings" - git push + fi \ No newline at end of file diff --git a/.github/workflows/synchronize_bindings.yml b/.github/workflows/synchronize_bindings.yml new file mode 100644 index 0000000000..c5148fd111 --- /dev/null +++ b/.github/workflows/synchronize_bindings.yml @@ -0,0 +1,56 @@ +on: + pull_request: + branches: + - "**" + +name: Synchronize Bindings + +concurrency: + # Use github.run_id on main branch + # Use github.event.pull_request.number on pull requests, so it's unique per pull request + # Use github.ref on other branches, so it's unique per branch + group: ${{ github.workflow }}-${{ github.ref == 'refs/heads/main' && github.run_id || github.event.pull_request.number || github.ref }} + cancel-in-progress: true + +jobs: + generate_bindings: + name: Synchronise Bindings (Not Fork) + permissions: + contents: write + pull-requests: write + runs-on: ubuntu-latest + if: github.event.pull_request.head.repo.full_name == github.repository + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + ref: ${{ github.head_ref || github.ref_name }} + - name: Rust Cache + if: ${{ needs.check-needs-run.outputs.any-changes == 'true' }} + uses: Swatinem/rust-cache@v2.7.7 + with: + # reasoning: we want to cache xtask, most of the jobs in the matrix will be sped up a good bit thanks to that + save-if: ${{ github.ref == 'refs/heads/main' }} + cache-all-crates: true + - name: Setup Bot GitHub Credentials + run: | + git config user.name "github-actions[bot]" + git config user.email "41898282+github-actions[bot]@users.noreply.github.com" + - name: Setup + run: | + cargo xtask init + - name: Generate Bindings + run: | + cargo xtask codegen + - name: Check for changes + id: check_changes + run: | + if [[ -n $(git status --porcelain) ]]; then + echo "changes=true" >> "$GITHUB_OUTPUT"; + fi + - name: Commit Changes + if: steps.check_changes.outputs.changes + run: | + git add -A + git commit -m "chore(codegen): update bevy bindings" + git push diff --git a/crates/bevy_mod_scripting_functions/src/lib.rs b/crates/bevy_mod_scripting_functions/src/lib.rs index 5f998f4cb4..b9174ae4e0 100644 --- a/crates/bevy_mod_scripting_functions/src/lib.rs +++ b/crates/bevy_mod_scripting_functions/src/lib.rs @@ -1,6 +1,6 @@ #![allow(missing_docs)] -use ::bevy::prelude::*; +use bevy::prelude::*; pub mod bevy_bindings; pub mod core; pub use core::*; diff --git a/crates/xtask/src/main.rs b/crates/xtask/src/main.rs index 1b664a20ab..cfe7487c5b 100644 --- a/crates/xtask/src/main.rs +++ b/crates/xtask/src/main.rs @@ -457,6 +457,7 @@ impl App { ), os: os.to_string(), generates_coverage: self.global_args.coverage, + run_on_forks: !matches!(self.subcmd, Xtasks::Bencher { .. } | Xtasks::Bench { .. }), requires_gpu: matches!(self.subcmd, Xtasks::Docs { .. }), } } @@ -734,6 +735,8 @@ struct CiMatrixRow { generates_coverage: bool, /// If this step requires a gpu requires_gpu: bool, + /// if it should run on fork PR's + run_on_forks: bool, } impl Xtasks {