Sofy integration

How to integrate your workflows with Sofy using codemagic.yaml

Sofy is a testing automation platform that uses testing capabilities to enable tests without writing a single line of code. It is possible to publish binaries generated by Codemagic and schedule automation tests with Sofy via codemagic.yaml.

A sample project that shows how to configure Sofy integration is available in our Sample projects repository.

Configuring Sofy access

You will need to sign up with Sofy so you can obtain an API Key which is required for deploying your apps via Codemagic. In addition, you will also need the Sofy subscription key and the Schedule ID, both obtainable from your Sofy account settings.

  1. Open your Codemagic app settings, and go to the Environment variables tab.

  2. Enter the desired Variable name, e.g. SOFY_API_KEY.

  3. Copy and paste the API key string as Variable value.

  4. Enter the variable group name, e.g. sofy_credentials. Click the button to create the group.

  5. Make sure the Secure option is selected.

  6. Click the Add button to add the variable.

  7. Repeat the steps to also add SOFY_SUBSCRIPTION_KEY, SOFY_SCHEDULE_ID, and $SOFY_SCHEDULE_GUID variables.

  8. Add the variable group to your codemagic.yaml file

      environment:
        groups:
          - sofy_credentials

Real Time and App Automation

The following examples show how to use cURL commands in your codemagic.yaml to deploy and test your app with Sofy.

Uploading apps

  scripts:
    - name: Publish APK / AAB / IPA to Sofy
      script: | 
        curl --location "https://public.sofy.ai/parser-microservice/build-upload" \ 
          --header "x-sofy-auth-key: $SOFY_SUBSCRIPTION_KEY" \ 
          --form "applicationFile=@/build/app/outputs/flutter-apk/app-release.apk" \ 

Uploading apps with Certificate Name (if any) for iOS builds

 scripts: 
    - name: Publishing IPA with a Certificate name
      script: |  
        curl --location "https://public.sofy.ai/parser-microservice/build-upload" \ 
          --header "x-sofy-auth-key: $SOFY_SUBSCRIPTION_KEY" \ 
          --form "applicationFile=@build/ios/ipa/native_ios_app.ipa" \ 
          --form 'CertificateName=""' 

Uploading apps with Application Guid (linking application)

 scripts: 
    - name: Publishing APK with Application Guid 
      script: |        
        curl --location "https://public.sofy.ai/parser-microservice/build-upload" \ 
          --header "x-sofy-auth-key: SOFY_SUBSCRIPTION_KEY" \ 
          --form "applicationFile=@/build/app/outputs/flutter-apk/app-release.apk" \ 
          --form 'ApplicationGUID=""'

Scheduling automation tests

  scripts:
    - name: Schedule an automation test with Sofy
      script: | 
          curl --location --request POST "https://public.sofy.ai/scheduler-microservice/scheduled-runs/:scheduledRunGuid/execute" \
            --header "x-sofy-auth-key: SOFY_SUBSCRIPTION_KEY" 

Scheduling automation tests on a particular build using application hash

  scripts: 
      - name: Schedule an automation test (on a specific build) with Sofy 
        script: | 
          curl --location --request POST "https://public.sofy.ai/scheduler-microservice/scheduled-runs/:scheduledRunGuid/execute?appHash=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" \
            --header "x-sofy-auth-key: SOFY_SUBSCRIPTION_KEY"
Note: :scheduledRunGuid will be replaced by the SOFY_SCHEDULE_GUID variable which can be found in your Sofy account, appHash will be fetched from the app upload API response mentioned above.

Fetching test run group IDs

  scripts: 
      - name: Fetch test run group IDs with Sofy 
        script: | 
          curl --location "https://public.sofy.ai/scheduler-microservice/scheduled-runs/$SOFY_SCHEDULE_GUID/test-run-groups" \
            --header "x-sofy-auth-key: SOFY_SUBSCRIPTION_KEY" 

Checking the status of scheduled tests

   scripts: 
      - name: Checking the status of scheduled tests 
        script: |  
          curl --location "https://public.sofy.ai/scheduler-microservice/scheduled-runs/$SOFY_SCHEDULE_GUID/status/:testRunGroupId" \
            --header "x-sofy-auth-key: SOFY_SUBSCRIPTION_KEY"
:testRunGroupId will be replaced by test run group ID fetched from the response of the Fetching test run group IDs step above.

As soon as your .ipa and .apk are successfully built, they will appear in the Sofy UI and any preferred devices can be selected for testing with Real Time. If devices need to be pre-chosen, then some capabilities provided by Sofy device settings must be injected into your project’s test scripts first.