feat: test matrix [skip ci] #105
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Test | |
on: | |
push: | |
branches: ["main"] | |
pull_request_target: | |
branches: ["main"] | |
# Allows you to run this workflow manually from the Actions tab | |
workflow_dispatch: | |
jobs: | |
setup: | |
runs-on: ubuntu-latest | |
outputs: | |
matrix: ${{ steps.setmatrix.outputs.matrix }} | |
steps: | |
- id: setmatrix | |
run: | | |
object="{\"targets\":[{\"scheme\":\"YumemiWeather\",\"dir\":\".\"},{\"scheme\":\"Example\",\"dir\":\"Example\"}]}" | |
echo "matrix=$object" >> $GITHUB_OUTPUT | |
test: | |
needs: setup | |
runs-on: macos-latest | |
permissions: | |
contents: read | |
checks: write | |
strategy: | |
matrix: ${{fromJson(needs.setup.outputs.matrix)}} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: echo | |
run: | | |
echo ${{ matrix }} | |
echo ${{ matrix.dir }} | |
echo ${{ matrix.scheme }} | |
- name: Test | |
env: | |
platform: ${{ 'iOS Simulator' }} | |
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 'iPhone.*?[^\(]+' | head -1 | awk '{$1=$1;print}' | sed -e "s/ Simulator$//"` | |
cd ${{ matrix.dir }} | |
xcodebuild -scheme "${{ matrix.scheme }}" -resultBundlePath ${{ matrix.scheme }} test -destination "platform=$platform,name=$device" | |
- name: Report | |
uses: kishikawakatsumi/xcresulttool@v1 | |
with: | |
path: ${{ matrix.scheme }}.xcresult | |
if: success() || failure() |