Repository navigation
189 lines (175 loc) · 7.66 KB
/
Copy pathbevy_mod_scripting.yml
File metadata and controls
189 lines (175 loc) · 7.66 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
on:
push:
branches:
- main
- staging
pull_request:
branches:
- "**"
workflow_dispatch:
name: CI
env:
REGISTRY: ghcr.io
IMAGE_NAME: bevy-mod-scripting
GH_TOKEN: ${{ github.token }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
BENCHER_API_TOKEN: ${{ secrets.BENCHER_API_TOKEN }}
RUST_BACKTRACE: 1
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:
check-needs-run:
runs-on: ubuntu-latest
outputs:
any-changes: ${{ steps.changes.outputs.src }}
permissions:
pull-requests: read
contents: read
steps:
- name: Checkout
uses: actions/checkout@v4
- uses: dorny/paths-filter@v3
id: changes
with:
base: main
filters: |
src:
- 'bindings/**'
- 'src/**'
- 'crates/**'
- 'examples/**'
- 'assets/**'
- 'docs/**'
- 'xtask/**'
- '.github/workflows/bevy_mod_scripting.yml'
generate-job-matrix:
runs-on: ubuntu-latest
# container: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest
outputs:
matrix: ${{ steps.generate-matrix.outputs.matrix }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Rust Cache
uses: Swatinem/rust-cache@v2.7.7
with:
# we want to cache xtask, most of the jobs in the matrix will be sped up a good bit thanks to that
shared-key: xtask
save-if: ${{ github.ref == 'refs/heads/main' }}
cache-all-crates: true
- name: Generate matrix
id: generate-matrix
env:
# pull requests get a reduced matrix to leave runner capacity for others, everything else runs the lot
MATRIX_ARGS: ${{ github.event_name != 'pull_request' && '--full' || '' }}
run: |
cargo xtask ci-matrix $MATRIX_ARGS > matrix.json
cat matrix.json
echo "Convert to single line JSON"
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.event_name }}" == "pull_request" && "${{ github.repository }}" != "${{ github.event.pull_request.head.repo.full_name }}" ]]; then
echo "This is a forked repository."
echo "is_fork=true" >> $GITHUB_OUTPUT
else
echo "This is not a forked repository."
echo "is_fork=false" >> $GITHUB_OUTPUT
fi
check:
needs: [check-needs-run, generate-job-matrix, check-is-fork]
permissions:
pull-requests: write
contents: write
issues: write
checks: write
name: Check - ${{ matrix.run_args.name }}
runs-on: ${{ matrix.run_args.os }}
strategy:
matrix:
run_args: ${{fromJson(needs.generate-job-matrix.outputs.matrix)}}
steps:
- name: Checkout
if: ${{ needs.check-needs-run.outputs.any-changes == 'true' && (matrix.run_args.run_on_forks || needs.check-is-fork.outputs.is_fork != 'true') }}
uses: actions/checkout@v4
- uses: actions-rs/toolchain@v1
if: ${{ needs.check-needs-run.outputs.any-changes == 'true' && (matrix.run_args.run_on_forks || needs.check-is-fork.outputs.is_fork != 'true') }}
with:
toolchain: stable
override: false
- name: Print versions
if: ${{ needs.check-needs-run.outputs.any-changes == 'true' && (matrix.run_args.run_on_forks || needs.check-is-fork.outputs.is_fork != 'true') }}
run: |
echo "Rust version: $(rustc --version)"
echo "Clippy version: $(cargo clippy --version)"
echo "Active toolchain: $(rustup show active-toolchain)"
continue-on-error: true
- name: Rust Cache
if: ${{ needs.check-needs-run.outputs.any-changes == 'true' && (matrix.run_args.run_on_forks || needs.check-is-fork.outputs.is_fork != 'true') }}
uses: Swatinem/rust-cache@v2.7.7
with:
# jobs doing the same kind of work share a cache (the matrix `cache_key`), jobs of different kinds would
# otherwise race to save one cache with whatever they built, and the others would never get a hit.
# Only main saves caches: PRs read main's (a PR can't read caches from other PRs or staging anyway),
# and PR saves would only push main's caches out of the repository's cache quota.
# `~/.cargo/bin` is part of the cache, so tools installed by `xtask init` are not rebuilt on a hit.
shared-key: ${{ matrix.run_args.cache_key }}
save-if: ${{ github.ref == 'refs/heads/main' }}
cache-all-crates: true
cache-bin: true
cache-on-failure: true
- name: Setup
if: ${{ needs.check-needs-run.outputs.any-changes == 'true' && (matrix.run_args.run_on_forks || needs.check-is-fork.outputs.is_fork != 'true') }}
run: |
cargo xtask init ${{ matrix.run_args.init_args }}
- name: Setup GPU Drivers
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 }}
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: Enable KVM
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_android_emulator }}
run: |
echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules
sudo udevadm control --reload-rules
sudo udevadm trigger --name-match=kvm
- name: Check With Android emulator
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_android_emulator }}
uses: reactivecircus/android-emulator-runner@v2
with:
api-level: 30
arch: x86_64
script: ${{ matrix.run_args.command }}
- name: Check
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 && !matrix.run_args.requires_android_emulator }}
run: |
${{ matrix.run_args.command }}
- name: Check With virtual X11 server
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 }}
run: |
xvfb-run ${{ matrix.run_args.command }}
rollup-check:
name: Required Checks Successful
needs: [check]
runs-on: ubuntu-latest
if: ${{ always() }}
steps:
- name: Check if all jobs succeeded
run: |
if [[ "${{ needs.check.result }}" != "success" ]]; then
echo "One or more checks failed. See detailed job results above."
exit 1
else
echo "All checks passed successfully!"
fi