Skip to content

IOS-27 Add solutions to 1657, 2352 problems #110

IOS-27 Add solutions to 1657, 2352 problems

IOS-27 Add solutions to 1657, 2352 problems #110

Workflow file for this run

name: Build & Test app workflow
on:
pull_request:
branches: [ "main", "develop" ]
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
build:
name: Build & Test app
permissions:
contents: read
pull-requests: write
runs-on: self-hosted
steps:
- name: Labeler
id: label-the-PR
uses: actions/labeler@v5
with:
repo-token: "${{ secrets.GITHUB_TOKEN }}"
sync-labels: true
- name: Checkout
uses: actions/checkout@v4
- name: Set Schemes
run: |
scheme_list=$(xcodebuild -list -json | tr -d "\n")
grp=$(echo)
if ${{ contains(steps.label-the-PR.outputs.all-labels, 'LeetCode75') && contains(steps.label-the-PR.outputs.all-labels, 'LeetCode100') || contains(steps.label-the-PR.outputs.all-labels, 'Core') || contains(steps.label-the-PR.outputs.all-labels, 'Release') }}; then
grp=$(echo 'LeetCode[0-9]{0,3}\b')
else
if ${{ contains(steps.label-the-PR.outputs.all-labels, 'LeetCode100') }}; then
grp=$(echo 'LeetCode100\b')
else
if ${{ contains(steps.label-the-PR.outputs.all-labels, 'LeetCode100') }}; then
grp=$(echo 'LeetCode75\b')
fi
fi
fi
echo ____________________GRP: $grp
targets=$(echo $scheme_list | ruby -e "require 'json'; puts JSON.parse(STDIN.gets)['project']['targets']" | grep -oE $grp)
echo ____________________TARGETS: $targets
echo $targets | cat >schemes
echo; echo The following schemes will be used: [$targets].; echo
- name: Build
env:
schemes: ${{ 'schemes' }}
platform: ${{ 'OS X' }}
run: |
# xcrun xctrace returns via stderr, not the expected stdout (https://developer.apple.com/forums/thread/663959)
device=`xcrun xctrace list devices 2>&1 | grep -oE 'MacBook' | head -1 | awk '{$1=$1;print}'`
if [ $schemes = schemes ]; then schemes=$(cat schemes); else schemes=[]; fi
for scheme in $schemes
do
echo "|"; echo "Scheme used: [$scheme]"; echo "|"
if [ "`ls -A | grep -i \\.xcworkspace\$`" ]
then filetype_parameter="workspace" && file_to_build="`ls -A | grep -i \\.xcworkspace\$`"
else filetype_parameter="project" && file_to_build="`ls -A | grep -i \\.xcodeproj\$`"
fi
file_to_build=`echo $file_to_build | awk '{$1=$1;print}'`
xcodebuild build -scheme "$scheme" -$filetype_parameter "$file_to_build" -destination "platform=$platform,name=$device,arch=arm64"
xcodebuild build-for-testing -scheme "$scheme" -$filetype_parameter "$file_to_build" -destination "platform=$platform,name=$device,arch=arm64"
done
- name: Add Build Fail label
uses: actions/labeler@v5
with:
repo-token: "${{ secrets.GITHUB_TOKEN }}"
configuration-path: .github/BuildFailLabeler.yml
sync-labels: true
if: ${{ failure() }}
- name: Unit Test
env:
schemes: ${{ 'schemes' }}
platform: ${{ 'OS X' }}
run: |
# xcrun xctrace returns via stderr, not the expected stdout (see https://developer.apple.com/forums/thread/663959)
device=`xcrun xctrace list devices 2>&1 | grep -oE 'MacBook' | head -1 | awk '{$1=$1;print}'`
if [ $schemes = schemes ]; then schemes=$(cat schemes); else schemes=[]; fi
for scheme in $schemes
do
echo "|"; echo "Scheme used: [$scheme]"; echo "|"
if [ "`ls -A | grep -i \\.xcworkspace\$`" ]
then filetype_parameter="workspace" && file_to_build="`ls -A | grep -i \\.xcworkspace\$`"
else filetype_parameter="project" && file_to_build="`ls -A | grep -i \\.xcodeproj\$`"
fi
file_to_build=`echo $file_to_build | awk '{$1=$1; print}'`
xcodebuild test-without-building -scheme "$scheme" -$filetype_parameter "$file_to_build" -destination "platform=$platform,name=$device,arch=arm64"
done
- name: Add Test Fail Label
uses: actions/labeler@v5
with:
repo-token: "${{ secrets.GITHUB_TOKEN }}"
configuration-path: .github/TestFailLabeler.yml
sync-labels: true
if: ${{ failure() }}