Skip to content

chore: try fix CI for forks #432

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Jul 3, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/bencher_on_pr_or_fork.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
76 changes: 24 additions & 52 deletions .github/workflows/bevy_mod_scripting.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -103,49 +116,49 @@ 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
save-if: ${{ github.ref == 'refs/heads/main' }}
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
Expand All @@ -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
56 changes: 56 additions & 0 deletions .github/workflows/synchronize_bindings.yml
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion crates/bevy_mod_scripting_functions/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#![allow(missing_docs)]

use ::bevy::prelude::*;
use bevy::prelude::*;
pub mod bevy_bindings;
pub mod core;
pub use core::*;
Expand Down
3 changes: 3 additions & 0 deletions crates/xtask/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 { .. }),
}
}
Expand Down Expand Up @@ -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 {
Expand Down
Loading