Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
78 changes: 78 additions & 0 deletions preternatural-build/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ inputs:
description: 'Build configurations (array of: debug, release)'
required: false
default: '["debug", "release"]'
working-directory:
description: 'Directory to run the preternatural command from'
required: false
default: ''
derived_data_path:
description: 'The path to the derived data folder'
required: false
Expand Down Expand Up @@ -40,13 +44,20 @@ runs:
key: ${{ runner.os }}-${{ github.repository }}-${{ github.ref_name }}-derived-data

- name: Execute preternatural build command
continue-on-error: true
id: build
shell: bash
run: |
PLATFORMS=$(echo '${{ inputs.platforms }}' | tr -d '[]' | sed 's/, /,/g')
CONFIGURATIONS=$(echo '${{ inputs.configurations }}' | tr -d '[]' | sed 's/, /,/g')
DERIVED_DATA_PATH=$HOME/${{ inputs.derived_data_path }}

# Change directory if working-directory is provided
if [ ! -z "${{ inputs.working-directory }}" ]; then
cd "${{ inputs.working-directory }}"
echo "Changed working directory to: ${{ inputs.working-directory }}"
fi

# Construct the command as a string
PRETERNATURAL_CMD="script -q /dev/null preternatural build --derived-data-path \"$DERIVED_DATA_PATH\" --platforms $PLATFORMS --configurations $CONFIGURATIONS"

Expand Down Expand Up @@ -82,3 +93,70 @@ runs:
with:
path: "~/preternatural-derived-data"
key: ${{ runner.os }}-${{ github.repository }}-${{ github.ref_name }}-derived-data

- name: Install xclogparser
if: steps.build.outputs.build_succeeded != 'true'
continue-on-error: true
shell: bash
run: |
brew install xclogparser

- name: Find and process logs
if: steps.build.outputs.build_succeeded != 'true'
continue-on-error: true
shell: bash
run: |
DERIVED_DATA_PATH=$HOME/${{ inputs.derived_data_path }}
echo "Searching for logs in: $DERIVED_DATA_PATH"

mkdir -p ./artifacts/xcactivitylogs
mkdir -p ./artifacts/json_logs
mkdir -p ./artifacts/xcresults

# Find and copy xcactivitylog files
find "$DERIVED_DATA_PATH" -name "*.xcactivitylog" -type f -print0 | while IFS= read -r -d '' log; do
cp "$log" "./artifacts/xcactivitylogs/$(basename "$log")"
echo "Copied $log to ./artifacts/xcactivitylogs/"

# Convert to JSON
json_file="./artifacts/json_logs/$(basename "$log" .xcactivitylog).json"
xclogparser parse --file "$log" --reporter json --output "$json_file"
echo "Converted $log to JSON: $json_file"
done

# Find and copy xcresult bundles
find "$DERIVED_DATA_PATH" -name "*.xcresult" -type d -print0 | while IFS= read -r -d '' result; do
cp -R "$result" "./artifacts/xcresults/"
echo "Copied $result to ./artifacts/xcresults/"
done

# Debug information
echo "Contents of artifacts directory:"
ls -R ./artifacts

# Check if any logs were found and copied
if [ -z "$(ls -A ./artifacts/xcactivitylogs)" ] && [ -z "$(ls -A ./artifacts/xcresults)" ]; then
echo "No log files or xcresult bundles found in $DERIVED_DATA_PATH"
exit 1
fi

# Create zip archive
cd ./artifacts
zip -r ../build-artifacts.zip ./*
cd ..

- name: Upload build artifacts
if: steps.build.outputs.build_succeeded != 'true'
continue-on-error: true
uses: actions/upload-artifact@v4
with:
name: build-artifacts
path: build-artifacts.zip
if-no-files-found: error

- name: Check build status and fail if necessary
if: steps.build.outputs.build_succeeded != 'true'
shell: bash
run: |
echo "Build failed earlier in the workflow"
exit 1
Loading