From 76a265f995f4c144359654c3addb94cd0a8d3953 Mon Sep 17 00:00:00 2001 From: "novr (Nobuhisa Komiya)" Date: Tue, 16 Jul 2024 10:57:51 +0900 Subject: [PATCH 1/2] feat: test matrix --- .github/workflows/test.yml | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 7d6a350..1566717 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -2,32 +2,44 @@ name: Test on: push: - branches: [ "main" ] + branches: ["main"] pull_request_target: - branches: [ "main" ] + branches: ["main"] # Allows you to run this workflow manually from the Actions tab workflow_dispatch: jobs: - build: + 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: Test env: - scheme: ${{ 'YumemiWeather' }} 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$//"` - xcodebuild -scheme "$scheme" -resultBundlePath TestResults test -destination "platform=$platform,name=$device" + cd ${{ matrix.dir }} + xcodebuild -scheme "${{ matrix.scheme }}" -resultBundlePath ${{ matrix.scheme }} test -destination "platform=$platform,name=$device" - name: Format uses: kishikawakatsumi/xcresulttool@v1 with: - path: TestResults.xcresult + path: ${{ matrix.scheme }}.xcresult if: success() || failure() From 4baf43c1203473c3659d6c5612fbe0191940269b Mon Sep 17 00:00:00 2001 From: "novr (Nobuhisa Komiya)" Date: Tue, 16 Jul 2024 11:16:48 +0900 Subject: [PATCH 2/2] fix: matrix config --- .github/workflows/test.yml | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 1566717..8da6fb4 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -17,7 +17,7 @@ jobs: steps: - id: setmatrix run: | - object="{\"targets\":[{\"scheme\": \"YumemiWeather\", \"dir\": \".\"}, {\"scheme\": \"Example\", \"dir\": \"Example\"}]}" + object="[{\"scheme\":\"YumemiWeather\",\"dir\":\".\"},{\"scheme\":\"Example\",\"dir\":\"Example\"}]" echo "matrix=$object" >> $GITHUB_OUTPUT test: needs: setup @@ -26,7 +26,8 @@ jobs: contents: read checks: write strategy: - matrix: ${{ fromJson(needs.setup.outputs.matrix) }} + matrix: + config: ${{fromJson(needs.setup.outputs.matrix)}} steps: - name: Checkout uses: actions/checkout@v4 @@ -36,10 +37,10 @@ jobs: 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: Format + cd ${{ matrix.config.dir }} + xcodebuild -scheme "${{ matrix.config.scheme }}" -resultBundlePath ${{ matrix.config.scheme }} test -destination "platform=$platform,name=$device" + - name: Report uses: kishikawakatsumi/xcresulttool@v1 with: - path: ${{ matrix.scheme }}.xcresult + path: ${{ matrix.config.scheme }}.xcresult if: success() || failure()