Compare commits

...
Author SHA1 Message Date
admin 944ed19e3b Skip unchanged Unity proto generation in CI 2026-06-17 10:39:17 -07:00
5 changed files with 135 additions and 8 deletions
+52 -6
View File
@@ -16,6 +16,8 @@ on:
- "scripts/build_windows_plugin.sh"
- "ci/github_actions/build_unity.sh"
- "ci/github_actions/test_unity_editmode.sh"
- "ci/github_actions/detect_unity_proto_changes.sh"
- "ci/github_actions/ensure_unity_protos.sh"
- "ci/github_actions/ensure_bazel_installed.sh"
- ".github/actions/setup-bazel/**"
- "ci/github_actions/detect_addressables_changes.sh"
@@ -41,6 +43,8 @@ on:
- "scripts/build_windows_plugin.sh"
- "ci/github_actions/build_unity.sh"
- "ci/github_actions/test_unity_editmode.sh"
- "ci/github_actions/detect_unity_proto_changes.sh"
- "ci/github_actions/ensure_unity_protos.sh"
- "ci/github_actions/ensure_bazel_installed.sh"
- ".github/actions/setup-bazel/**"
- "ci/github_actions/detect_addressables_changes.sh"
@@ -103,15 +107,34 @@ jobs:
clean: false # Library/ persists between runs on self-hosted runners
fetch-depth: 2
- name: Detect Unity proto changes
id: unity-protos
shell: bash
run: |
set -euo pipefail
if [[ "${{ github.event_name }}" == "pull_request" ]]; then
BASE_SHA="${{ github.event.pull_request.base.sha }}"
else
BASE_SHA="${{ github.event.before }}"
fi
./ci/github_actions/detect_unity_proto_changes.sh "$BASE_SHA" "${{ github.sha }}"
- name: Clean stale files
run: |
git clean -ffd
UNITY_ROOT="src/main/csharp/net/eagle0/clients/unity/eagle0"
# These ignored proto outputs are mutually exclusive across proto-generation
# layouts. Clean both before regenerating to avoid stale DLL/source duplicates
# when a self-hosted runner switches between main and PR branches.
# layouts. Always clean generated source protos; clean the DLL only when
# proto inputs changed so unchanged runs can reuse the previous DLL
# without paying Bazel analysis/startup cost.
rm -rf "$UNITY_ROOT/Assets/GeneratedProtos"
rm -rf "$UNITY_ROOT/Assets/Plugins/Eagle0Protos"
if [ "${{ steps.unity-protos.outputs.changed }}" = "true" ]; then
rm -rf "$UNITY_ROOT/Assets/Plugins/Eagle0Protos"
else
echo "Keeping existing Eagle0Protos DLL because Unity proto inputs are unchanged."
fi
LIBRARY_DIR="src/main/csharp/net/eagle0/clients/unity/eagle0/Library"
VERSION_CACHE="$LIBRARY_DIR/.last_unity_version"
PROJECT_VERSION_FILE="src/main/csharp/net/eagle0/clients/unity/eagle0/ProjectSettings/ProjectVersion.txt"
@@ -158,6 +181,8 @@ jobs:
uses: ./.github/actions/setup-bazel
- name: Run Unity EditMode tests
env:
UNITY_PROTOS_CHANGED: ${{ steps.unity-protos.outputs.changed }}
run: ./ci/github_actions/test_unity_editmode.sh
- name: Archive EditMode test artifacts
@@ -218,15 +243,34 @@ jobs:
clean: false # Library/ persists between runs on self-hosted runners
fetch-depth: 2 # Keep the previous main commit available for Addressables change detection
- name: Detect Unity proto changes
id: unity-protos
shell: bash
run: |
set -euo pipefail
if [[ "${{ github.event_name }}" == "pull_request" ]]; then
BASE_SHA="${{ github.event.pull_request.base.sha }}"
else
BASE_SHA="${{ github.event.before }}"
fi
./ci/github_actions/detect_unity_proto_changes.sh "$BASE_SHA" "${{ github.sha }}"
- name: Clean stale files
run: |
git clean -ffd
UNITY_ROOT="src/main/csharp/net/eagle0/clients/unity/eagle0"
# These ignored proto outputs are mutually exclusive across proto-generation
# layouts. Clean both before regenerating to avoid stale DLL/source duplicates
# when a self-hosted runner switches between main and PR branches.
# layouts. Always clean generated source protos; clean the DLL only when
# proto inputs changed so unchanged runs can reuse the previous DLL
# without paying Bazel analysis/startup cost.
rm -rf "$UNITY_ROOT/Assets/GeneratedProtos"
rm -rf "$UNITY_ROOT/Assets/Plugins/Eagle0Protos"
if [ "${{ steps.unity-protos.outputs.changed }}" = "true" ]; then
rm -rf "$UNITY_ROOT/Assets/Plugins/Eagle0Protos"
else
echo "Keeping existing Eagle0Protos DLL because Unity proto inputs are unchanged."
fi
LIBRARY_DIR="src/main/csharp/net/eagle0/clients/unity/eagle0/Library"
VERSION_CACHE="$LIBRARY_DIR/.last_unity_version"
PROJECT_VERSION_FILE="src/main/csharp/net/eagle0/clients/unity/eagle0/ProjectSettings/ProjectVersion.txt"
@@ -287,6 +331,8 @@ jobs:
./ci/github_actions/detect_addressables_changes.sh "$BASE_SHA" "${{ github.sha }}"
- name: Build Windows unity
env:
UNITY_PROTOS_CHANGED: ${{ steps.unity-protos.outputs.changed }}
run: ./ci/github_actions/build_unity.sh "${{ env.EAGLE0_BUILD_DIR }}/eagle0WIN" "${{ steps.addressables.outputs.changed }}" "${{ steps.addressables.outputs.changed }}"
- name: Save build SHA for Bee/ cache invalidation
+1 -1
View File
@@ -8,7 +8,7 @@ BUILD_BASE="${EAGLE0_BUILD_DIR:-/tmp/eagle0}"
COMMIT=$(/usr/bin/git rev-parse --short HEAD)
/bin/echo "build protos"
./scripts/build_protos.sh
./ci/github_actions/ensure_unity_protos.sh
git log -3
+59
View File
@@ -0,0 +1,59 @@
#!/usr/bin/env bash
set -euo pipefail
BASE_SHA=${1:-}
HEAD_SHA=${2:-HEAD}
OUTPUT_FILE=${GITHUB_OUTPUT:-}
if [ -z "$BASE_SHA" ] || [[ "$BASE_SHA" =~ ^0+$ ]]; then
echo "No usable base SHA for this run; building Unity protos as a safe default."
changed=true
elif ! git cat-file -e "$BASE_SHA^{commit}"; then
echo "Base SHA $BASE_SHA is not available locally; building Unity protos as a safe default."
changed=true
else
UNITY_PROTO_INPUT_PREFIXES=(
"src/main/protobuf/"
"src/main/csharp/net/eagle0/clients/unity/eagle0/BUILD.bazel"
"scripts/build_protos.sh"
"ci/github_actions/detect_unity_proto_changes.sh"
"ci/github_actions/ensure_unity_protos.sh"
"MODULE.bazel"
"MODULE.bazel.lock"
".bazelrc"
"WORKSPACE"
)
is_unity_proto_input() {
local file="$1"
for prefix in "${UNITY_PROTO_INPUT_PREFIXES[@]}"; do
if [[ "$file" == "$prefix"* ]]; then
return 0
fi
done
return 1
}
changed=false
while IFS= read -r file; do
if is_unity_proto_input "$file"; then
echo "Unity-proto-impacting change: $file"
changed=true
break
fi
done < <(git diff --name-only "$BASE_SHA" "$HEAD_SHA")
fi
if [ "$changed" = "true" ]; then
echo "Building Unity protos because their inputs changed."
else
echo "Skipping Unity proto build; no Unity proto inputs changed."
fi
if [ -n "$OUTPUT_FILE" ]; then
echo "changed=$changed" >> "$OUTPUT_FILE"
else
echo "changed=$changed"
fi
+22
View File
@@ -0,0 +1,22 @@
#!/usr/bin/env bash
set -euo pipefail
UNITY_ROOT="src/main/csharp/net/eagle0/clients/unity/eagle0"
PLUGIN_DIR="$UNITY_ROOT/Assets/Plugins/Eagle0Protos"
GENERATED_SOURCES_DIR="$UNITY_ROOT/Assets/GeneratedProtos"
PROTO_DLL="$PLUGIN_DIR/Eagle0Protos.dll"
PROTO_XML="$PLUGIN_DIR/Eagle0Protos.xml"
UNITY_PROTOS_CHANGED=${UNITY_PROTOS_CHANGED:-true}
if [ "$UNITY_PROTOS_CHANGED" = "false" ] && [ -s "$PROTO_DLL" ] && [ -s "$PROTO_XML" ]; then
echo "Skipping Unity proto build; existing Eagle0Protos DLL/XML are present and proto inputs are unchanged."
rm -rf "$GENERATED_SOURCES_DIR"
exit 0
fi
if [ "$UNITY_PROTOS_CHANGED" = "false" ]; then
echo "Unity proto inputs are unchanged, but generated DLL/XML are missing; rebuilding."
fi
./scripts/build_protos.sh
+1 -1
View File
@@ -16,7 +16,7 @@ RESULTS_PATH="${BUILD_BASE}/editmode-test-results.xml"
mkdir -p "$BUILD_BASE"
echo "Building protos"
./scripts/build_protos.sh
./ci/github_actions/ensure_unity_protos.sh
echo "Running Unity EditMode tests"