This repository was archived by the owner on Apr 9, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
135 lines (116 loc) · 5.32 KB
/
function-cross-ref.yml
File metadata and controls
135 lines (116 loc) · 5.32 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
name: Function Cross-Reference
env:
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: "true"
on:
push:
branches: [ main ]
paths:
- '**/*.mcfunction'
- '.github/workflows/function-cross-ref.yml'
pull_request:
branches: [ main ]
paths:
- '**/*.mcfunction'
jobs:
# ─────────────────────────────────────────────
# Tüm .mcfunction dosyalarındaki inline function
# çağrılarını tarar ve hedef fonksiyonların
# gerçekten var olup olmadığını kontrol eder.
#
# validate-and-release.yml yalnızca tags/function/*.json
# referanslarını kontrol eder; bu job execute/function
# satırlarını doğrudan tarar.
# ─────────────────────────────────────────────
cross-ref:
name: Inline Function Call Integrity
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- name: Extract and validate all function calls
run: |
FAILED=0
CHECKED=0
SKIPPED=0
# BUG FIX: "data" değil "." — base="data" ile
# "$base/data/$ns/function/..." = "data/data/..." olurdu;
# tüm refler MISSING raporlanırdı.
BASES=". _pre_1_21_4 compat_1_21_4 1_20_3 1_21_4 1_21_5 1_21_6 26_1"
# Skip listesi:
# macro:cmd/ → dinamik dispatch: function macro:cmd/$(type) $(arguments)
# macro:input → storage path, fonksiyon değil (with storage macro:input {})
# macro:engine → storage path, fonksiyon değil
# Yorum satırlarındaki "mymap:*" örnek refler comment skip ile zaten atlanır.
SKIP_PATTERN='^macro:(cmd/|input$|engine$)'
while IFS= read -r mcfile; do
lineno=0
while IFS= read -r line; do
lineno=$((lineno + 1))
# Yorum ve boş satırları atla
stripped=$(echo "$line" | sed 's/^[[:space:]]*//')
[[ "$stripped" == "#"* || -z "$stripped" ]] && continue
# "function ns:path" kalıbını çıkar.
# Dinamik makro: $execute ... run function macro:cmd/$(type)
# → regex [a-z0-9_/]+ ile $(type) başlamaz, "macro:cmd/" çıkar.
# → SKIP_PATTERN tarafından atlanır.
refs=$(echo "$line" | grep -oP '\bfunction\s+\K[a-z_][a-z0-9_]*:[a-z0-9_/]+' || true)
for ref in $refs; do
if echo "$ref" | grep -qP "$SKIP_PATTERN"; then
SKIPPED=$((SKIPPED + 1))
continue
fi
ns="${ref%%:*}"
path="${ref#*:}"
found=0
for base in $BASES; do
[ -f "$base/data/$ns/function/$path.mcfunction" ] && found=1 && break
done
CHECKED=$((CHECKED + 1))
if [ $found -eq 0 ]; then
echo "FAIL [missing-func]: $mcfile:$lineno"
echo " call : function $ref"
echo " expect: data/$ns/function/$path.mcfunction (or overlay)"
FAILED=1
fi
done
done < "$mcfile"
done < <(find data _pre_1_21_4 compat_1_21_4 1_20_3 1_21_4 1_21_5 1_21_6 26_1 -name "*.mcfunction" 2>/dev/null)
echo ""
echo "Summary: $CHECKED refs checked, $SKIPPED skipped (dynamic/storage)"
if [ $FAILED -ne 0 ]; then
echo "FAILED: One or more function references point to non-existent files."
exit 1
fi
echo "PASSED: All inline function references resolved."
# ─────────────────────────────────────────────
# Overlay Orphan Check
# Base'de silinmiş ama overlay'de kalmış dosyaları tespit eder.
# v1.0.5'te manuel bulunmak zorunda kalınan tam bu sorun.
# ─────────────────────────────────────────────
overlay-leakage:
name: Overlay Orphan Check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- name: Check overlay files have base equivalents
run: |
FOUND=0
# Her overlay için: find "<overlay>" döndürdüğü yollar "<overlay>/data/..." formatında gelir.
# ${f#"$overlay"/} ile prefix'i strip edip base'de karşılığını kontrol ediyoruz.
for overlay in "_pre_1_21_4" "compat_1_21_4" "1_20_3" "1_21_4" "1_21_5" "1_21_6" "26_1"; do
[ ! -d "$overlay" ] && continue
while IFS= read -r f; do
rel="${f#"$overlay"/}"
if [ ! -f "$rel" ]; then
echo "WARN [orphan-overlay]: $f"
echo " Base equivalent missing: $rel"
echo " (Likely leftover from a deletion — remove from overlay too)"
FOUND=$((FOUND + 1))
fi
done < <(find "$overlay" -name "*.mcfunction" -o -name "*.json" 2>/dev/null)
done
if [ $FOUND -gt 0 ]; then
echo ""
echo "WARN: $FOUND orphan file(s) in overlays with no base equivalent."
else
echo "PASSED: All overlay files have base equivalents."
fi