Skip to content

Commit d246ca5

Browse files
committed
Cache and reuse derived data
1 parent 026124c commit d246ca5

File tree

1 file changed

+36
-5
lines changed

1 file changed

+36
-5
lines changed

preternatural-build/action.yml

Lines changed: 36 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ inputs:
1616
derived_data_path:
1717
description: 'The path to the derived data folder'
1818
required: false
19-
default: DerivedData/ProjectBuild
19+
default: DerivedData
2020

2121
runs:
2222
using: 'composite'
@@ -33,14 +33,45 @@ runs:
3333
brew tap PreternaturalAI/preternatural
3434
brew install preternatural
3535
36+
- name: Restore DerivedData Cache
37+
uses: actions/cache/restore@v4
38+
with:
39+
path: "**/DerivedData"
40+
key: ${{ runner.os }}-${{ github.repository }}-${{ github.ref_name }}-derived-data
41+
3642
- name: Execute preternatural build command
43+
id: build
3744
shell: bash
3845
run: |
3946
PLATFORMS=$(echo '${{ inputs.platforms }}' | tr -d '[]' | sed 's/, /,/g')
4047
CONFIGURATIONS=$(echo '${{ inputs.configurations }}' | tr -d '[]' | sed 's/, /,/g')
4148
DERIVED_DATA_PATH=${{ github.workspace }}/${{ inputs.derived_data_path }}
4249
43-
preternatural build \
44-
--derived-data-path "$DERIVED_DATA_PATH" \
45-
--platforms "$PLATFORMS" \
46-
--configurations "$CONFIGURATIONS"
50+
defaults write com.apple.dt.Xcode IDESkipMacroFingerprintValidation -bool YES
51+
52+
function run_build() {
53+
preternatural build \
54+
--derived-data-path "$DERIVED_DATA_PATH" \
55+
--platforms "$PLATFORMS" \
56+
--configurations "$CONFIGURATIONS"
57+
}
58+
59+
# First attempt
60+
if ! run_build; then
61+
echo "First build attempt failed. Cleaning derived data and retrying..."
62+
rm -rf "$DERIVED_DATA_PATH"
63+
64+
# Second attempt
65+
if ! run_build; then
66+
echo "Second build attempt failed after cleaning derived data. Failing the workflow."
67+
exit 1
68+
fi
69+
fi
70+
echo "build_succeeded=true" >> $GITHUB_OUTPUT
71+
72+
- name: Save DerivedData Cache
73+
if: steps.build.outputs.build_succeeded == 'true'
74+
uses: actions/cache/save@v4
75+
with:
76+
path: "**/DerivedData"
77+
key: ${{ runner.os }}-${{ github.repository }}-${{ github.ref_name }}-derived-data

0 commit comments

Comments
 (0)