From 94f5e51d1acaac4aa1e2e25a3820febf30fd5f42 Mon Sep 17 00:00:00 2001 From: "Lucas.Xu" Date: Fri, 8 Nov 2024 09:26:57 +0800 Subject: [PATCH] chore: enable ios ci --- .github/workflows/ios_ci.yaml | 40 ++++++------ .github/workflows/mobile_ci.yml | 108 ++++++++++++++++++++++++++++++++ 2 files changed, 130 insertions(+), 18 deletions(-) create mode 100644 .github/workflows/mobile_ci.yml diff --git a/.github/workflows/ios_ci.yaml b/.github/workflows/ios_ci.yaml index a39a2704c8179..ef64a9741da84 100644 --- a/.github/workflows/ios_ci.yaml +++ b/.github/workflows/ios_ci.yaml @@ -97,21 +97,25 @@ jobs: cargo make --profile development-ios-arm64-sim appflowy-core-dev-ios cargo make --profile development-ios-arm64-sim code_generation - # - uses: futureware-tech/simulator-action@v3 - # id: simulator-action - # with: - # model: "iPhone 15" - # shutdown_after_job: false - - # - name: Run AppFlowy on simulator - # working-directory: frontend/appflowy_flutter - # run: | - # flutter run -d ${{ steps.simulator-action.outputs.udid }} & - # pid=$! - # sleep 500 - # kill $pid - # continue-on-error: true - - # - name: Run integration tests - # working-directory: frontend/appflowy_flutter - # run: flutter test integration_test/runner.dart -d ${{ steps.simulator-action.outputs.udid }} + - uses: futureware-tech/simulator-action@v3 + id: simulator-action + with: + model: "iPhone 15" + shutdown_after_job: false + + - name: Run AppFlowy on simulator + working-directory: frontend/appflowy_flutter + run: | + flutter run -d ${{ steps.simulator-action.outputs.udid }} & + pid=$! + sleep 500 + kill $pid + continue-on-error: true + + - name: Run integration tests + working-directory: frontend/appflowy_flutter + # The integration tests are flaky and sometimes fail with "Connection timed out": + # Don't block the CI. If the tests fail, the CI will still pass. + # Instead, we're using Code Magic to re-run the tests to check if they pass. + continue-on-error: true + run: flutter test integration_test/runner.dart -d ${{ steps.simulator-action.outputs.udid }} diff --git a/.github/workflows/mobile_ci.yml b/.github/workflows/mobile_ci.yml new file mode 100644 index 0000000000000..31de45ccd818a --- /dev/null +++ b/.github/workflows/mobile_ci.yml @@ -0,0 +1,108 @@ +name: Mobile-CI + +on: + workflow_dispatch: + inputs: + branch: + description: "Branch to build" + required: true + default: "main" + workflow_id: + description: "Codemagic workflow ID" + required: true + default: "ios-workflow" + type: choice + options: + - ios-workflow + - android-workflow + +env: + CODEMAGIC_API_TOKEN: 3G8VZRVsbYPb5-RuFjw-xqqlyA7y-nfue-rmybupLZw + APP_ID: "64cb77ba5da3347bf6d22fba" + +jobs: + trigger-mobile-build: + runs-on: ubuntu-latest + steps: + - name: Trigger Codemagic Build + id: trigger_build + run: | + RESPONSE=$(curl -X POST \ + --header "Content-Type: application/json" \ + --header "x-auth-token: $CODEMAGIC_API_TOKEN" \ + --data '{ + "appId": "${{ env.APP_ID }}", + "workflowId": "${{ github.event.inputs.workflow_id }}", + "branch": "${{ github.event.inputs.branch }}" + }' \ + https://api.codemagic.io/builds) + + BUILD_ID=$(echo $RESPONSE | jq -r '.buildId') + echo "build_id=$BUILD_ID" >> $GITHUB_OUTPUT + + - name: Wait for build and check status + id: check_status + run: | + while true; do + RESPONSE=$(curl -X GET \ + --header "Content-Type: application/json" \ + --header "x-auth-token: $CODEMAGIC_API_TOKEN" \ + https://api.codemagic.io/builds/${{ steps.trigger_build.outputs.build_id }}) + + STATUS=$(echo $RESPONSE | jq -r '.status') + + if [ "$STATUS" = "finished" ]; then + SUCCESS=$(echo $RESPONSE | jq -r '.success') + BUILD_URL=$(echo $RESPONSE | jq -r '.buildUrl') + echo "status=$STATUS" >> $GITHUB_OUTPUT + echo "success=$SUCCESS" >> $GITHUB_OUTPUT + echo "build_url=$BUILD_URL" >> $GITHUB_OUTPUT + break + elif [ "$STATUS" = "failed" ]; then + echo "status=failed" >> $GITHUB_OUTPUT + break + fi + + sleep 60 + done + + - name: Send Slack Notification + if: always() + run: | + BUILD_STATUS="${{ steps.check_status.outputs.status }}" + SUCCESS="${{ steps.check_status.outputs.success }}" + BUILD_URL="${{ steps.check_status.outputs.build_url }}" + + if [ "$SUCCESS" = "true" ]; then + COLOR="#36a64f" + STATUS_TEXT="✅ Success" + else + COLOR="#ff0000" + STATUS_TEXT="❌ Failed" + fi + + curl -X POST -H 'Content-type: application/json' \ + --data "{ + \"attachments\": [ + { + \"color\": \"$COLOR\", + \"blocks\": [ + { + \"type\": \"section\", + \"text\": { + \"type\": \"mrkdwn\", + \"text\": \"*Mobile CI Build Result*\n$STATUS_TEXT\" + } + }, + { + \"type\": \"section\", + \"text\": { + \"type\": \"mrkdwn\", + \"text\": \"*Branch:* ${{ github.event.inputs.branch }}\n*Workflow:* ${{ github.event.inputs.workflow_id }}\n*Build URL:* $BUILD_URL\" + } + } + ] + } + ] + }" \ + ${{ secrets.RELEASE_SLACK_WEBHOOK }}