Skip to content

Commit 36bceed

Browse files
committed
chore: returned removed action
1 parent 68449ff commit 36bceed

File tree

1 file changed

+145
-0
lines changed

1 file changed

+145
-0
lines changed
Lines changed: 145 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,145 @@
1+
name: Cache Binding Artifact
2+
description: Generic cache management for compiled binding artifacts (restore or save)
3+
4+
inputs:
5+
binding-name:
6+
description: 'Language binding name (python, ruby, go, java, csharp, php, node, wasm, ffi)'
7+
required: true
8+
cache-key:
9+
description: 'Full cache key for this artifact'
10+
required: true
11+
cache-restore-keys:
12+
description: 'Fallback restore keys (one per line)'
13+
required: false
14+
default: ''
15+
cache-paths:
16+
description: 'Paths to cache (one per line)'
17+
required: true
18+
operation:
19+
description: 'Operation to perform: restore or save'
20+
required: true
21+
enable-crossplatform-cache:
22+
description: 'Enable cross-OS caching (experimental, may have issues)'
23+
required: false
24+
default: 'false'
25+
26+
outputs:
27+
cache-hit:
28+
description: 'Whether the cache was restored (exact match)'
29+
value: ${{ steps.cache-restore.outputs.cache-hit }}
30+
cache-matched-key:
31+
description: 'The cache key that was matched (exact or partial)'
32+
value: ${{ steps.cache-restore.outputs.cache-matched-key || steps.cache-save.outputs.cache-key }}
33+
cache-primary-key:
34+
description: 'The primary cache key used'
35+
value: ${{ inputs.cache-key }}
36+
37+
runs:
38+
using: composite
39+
steps:
40+
- name: Validate inputs
41+
shell: bash
42+
run: |
43+
if [[ "${{ inputs.operation }}" != "restore" && "${{ inputs.operation }}" != "save" ]]; then
44+
echo "❌ Error: operation must be 'restore' or 'save'"
45+
exit 1
46+
fi
47+
48+
if [[ -z "${{ inputs.binding-name }}" ]]; then
49+
echo "❌ Error: binding-name is required"
50+
exit 1
51+
fi
52+
53+
if [[ -z "${{ inputs.cache-key }}" ]]; then
54+
echo "❌ Error: cache-key is required"
55+
exit 1
56+
fi
57+
58+
if [[ -z "${{ inputs.cache-paths }}" ]]; then
59+
echo "❌ Error: cache-paths is required"
60+
exit 1
61+
fi
62+
63+
echo "✓ Input validation passed"
64+
echo " Binding: ${{ inputs.binding-name }}"
65+
echo " Operation: ${{ inputs.operation }}"
66+
echo " Cache key: ${{ inputs.cache-key }}"
67+
68+
- name: Restore cache
69+
id: cache-restore
70+
if: inputs.operation == 'restore'
71+
uses: actions/cache/restore@v5
72+
with:
73+
key: ${{ inputs.cache-key }}
74+
restore-keys: ${{ inputs.cache-restore-keys }}
75+
path: ${{ inputs.cache-paths }}
76+
enableCrossOsArchive: ${{ inputs.enable-crossplatform-cache }}
77+
fail-on-cache-miss: false
78+
lookup-only: false
79+
80+
- name: Report cache restore result
81+
if: inputs.operation == 'restore'
82+
shell: bash
83+
run: |
84+
echo "=== Cache Restore Result for ${{ inputs.binding-name }} ==="
85+
86+
if [[ "${{ steps.cache-restore.outputs.cache-hit }}" == "true" ]]; then
87+
echo "✓ Cache HIT (exact match)"
88+
echo " Matched key: ${{ steps.cache-restore.outputs.cache-matched-key }}"
89+
elif [[ -n "${{ steps.cache-restore.outputs.cache-matched-key }}" ]]; then
90+
echo "⚠ Cache PARTIAL HIT (fallback key matched)"
91+
echo " Matched key: ${{ steps.cache-restore.outputs.cache-matched-key }}"
92+
echo " Primary key: ${{ inputs.cache-key }}"
93+
else
94+
echo "✗ Cache MISS (no match found)"
95+
echo " Primary key: ${{ inputs.cache-key }}"
96+
fi
97+
98+
- name: Save cache
99+
id: cache-save
100+
if: inputs.operation == 'save'
101+
uses: actions/cache/save@v5
102+
with:
103+
key: ${{ inputs.cache-key }}
104+
path: ${{ inputs.cache-paths }}
105+
enableCrossOsArchive: ${{ inputs.enable-crossplatform-cache }}
106+
107+
- name: Report cache save result
108+
if: inputs.operation == 'save'
109+
shell: bash
110+
run: |
111+
echo "=== Cache Save Result for ${{ inputs.binding-name }} ==="
112+
echo "✓ Saved to cache"
113+
echo " Cache key: ${{ inputs.cache-key }}"
114+
echo " Paths cached:"
115+
echo "${{ inputs.cache-paths }}" | while IFS= read -r path; do
116+
if [[ -n "$path" ]]; then
117+
if [[ -e "$path" ]] || ls $path 1> /dev/null 2>&1; then
118+
echo " ✓ $path"
119+
else
120+
echo " ⚠ $path (not found, skipped)"
121+
fi
122+
fi
123+
done
124+
125+
- name: Show cache statistics
126+
if: always()
127+
shell: bash
128+
run: |
129+
echo ""
130+
echo "=== Cache Statistics ==="
131+
echo "Binding: ${{ inputs.binding-name }}"
132+
echo "Operation: ${{ inputs.operation }}"
133+
134+
if [[ "${{ inputs.operation }}" == "restore" ]]; then
135+
echo "Hit: ${{ steps.cache-restore.outputs.cache-hit == 'true' && 'Yes' || 'No' }}"
136+
fi
137+
138+
# Calculate total size of cached paths
139+
TOTAL_SIZE=0
140+
echo "${{ inputs.cache-paths }}" | while IFS= read -r path; do
141+
if [[ -n "$path" ]] && [[ -e "$path" ]] || ls $path 1> /dev/null 2>&1; then
142+
SIZE=$(du -sh "$path" 2>/dev/null | cut -f1 || echo "unknown")
143+
echo " $path: $SIZE"
144+
fi
145+
done

0 commit comments

Comments
 (0)