@@ -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 : " preternatural-derived-data "
2020
2121runs :
2222 using : ' composite'
@@ -33,14 +33,52 @@ 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 : " ~/preternatural-derived-data"
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')
41- DERIVED_DATA_PATH=${{ github.workspace }}/${{ inputs.derived_data_path }}
48+ DERIVED_DATA_PATH=$HOME/${{ inputs.derived_data_path }}
49+
50+ # Construct the command as a string
51+ PRETERNATURAL_CMD="script -q /dev/null preternatural build --derived-data-path \"$DERIVED_DATA_PATH\" --platforms $PLATFORMS --configurations $CONFIGURATIONS"
52+
53+ echo "Running preternatural build command:"
54+ echo "${PRETERNATURAL_CMD}"
55+
56+ # First attempt
57+ set +e # Don't exit on error
58+ eval ${PRETERNATURAL_CMD} 2>&1
59+ BUILD_STATUS=$?
60+ set -e # Return to exit on error
4261
43- preternatural build \
44- --derived-data-path "$DERIVED_DATA_PATH" \
45- --platforms "$PLATFORMS" \
46- --configurations "$CONFIGURATIONS"
62+ if [ $BUILD_STATUS -ne 0 ]; then
63+ echo "First build attempt failed (status: $BUILD_STATUS). Cleaning derived data and retrying..."
64+ rm -rf "$DERIVED_DATA_PATH"
65+ echo "Cleaned derived data"
66+
67+ # Second attempt
68+ eval ${PRETERNATURAL_CMD} 2>&1
69+ RETRY_STATUS=$?
70+
71+ if [ $RETRY_STATUS -ne 0 ]; then
72+ echo "Second build attempt failed (status: $RETRY_STATUS) after cleaning derived data. Failing the workflow."
73+ exit 1
74+ fi
75+ fi
76+
77+ echo "build_succeeded=true" >> $GITHUB_OUTPUT
78+
79+ - name : Save DerivedData Cache
80+ if : steps.build.outputs.build_succeeded == 'true'
81+ uses : actions/cache/save@v4
82+ with :
83+ path : " ~/preternatural-derived-data"
84+ key : ${{ runner.os }}-${{ github.repository }}-${{ github.ref_name }}-derived-data
0 commit comments