expo / eas-cli

Fastest way to build, submit, and update iOS and Android apps
https://docs.expo.dev/eas/
MIT License
833 stars 85 forks source link

EAS Custom Build issues #2261

Open dannyBies opened 8 months ago

dannyBies commented 8 months ago

Build/Submit details page URL

No response

Summary

Hi!

I'm using Custom EAS Builds to set up slack integration with eas/send_slack_message. I appreciate this might belong in https://github.com/expo/eas-build but I'm not able to create a new issue there.

I have created two almost identical build configs for android and ios. IOS:

build:
  name: My config
  steps:
    - pre_install_private_npm_registry

    - eas/build

    - eas/send_slack_message:
        if: ${ always() }
        name: Send Slack message when the build finishes
        inputs:
          slack_hook_url: ${ eas.env.live_slack_webhook_url }
          message: |
            Build Information:
            Status: ${ steps.run_fastlane.status_text }
            App Name: ${ eas.metadata.appName }
            App Identifier: ${ eas.metadata.appIdentifier }
            App Version: ${ eas.metadata.appVersion }
            App Build Version: ${ eas.metadata.appBuildVersion }
            Platform: ${ eas.job.platform }
            Expo Build URL: ${ eas.job.expoBuildUrl }
            Triggered By: ${ eas.job.triggeredBy }
            Git Commit Hash ${ eas.metadata.gitCommitHash }
            https://chart.googleapis.com/chart?cht=qr&chs=150x150&chl=${ eas.job.expoBuildUrl }

functions:
  pre_install_private_npm_registry:
    name: Pre install hook
    path: ./pre-install

Android:

build:
  name: My config
  steps:
    - pre_install_private_npm_registry

    - eas/build

    - eas/send_slack_message:
        if: ${ always() }
        name: Send Slack message when the build finishes
        inputs:
          slack_hook_url: ${ eas.env.live_slack_webhook_url }
          message: |
            Build Information:
            Status: ${ steps.run_gradle.status_text }
            App Name: ${ eas.metadata.appName }
            App Identifier: ${ eas.metadata.appIdentifier }
            App Version: ${ eas.metadata.appVersion }
            App Build Version: ${ eas.metadata.appBuildVersion }
            Platform: ${ eas.job.platform }
            Expo Build URL: ${ eas.job.expoBuildUrl }
            Triggered By: ${ eas.job.triggeredBy }
            Git Commit Hash ${ eas.metadata.gitCommitHash }
            https://chart.googleapis.com/chart?cht=qr&chs=150x150&chl=${ eas.job.expoBuildUrl }

functions:
  pre_install_private_npm_registry:
    name: Pre install hook
    path: ./pre-install

Whilst trying to configure this I'm running into a couple issues:

1) Unable to conditionally execute a step depending on the platform

Ideally I want to use a single yml file where I configure my build steps. I would then be able to use

 - eas/send_slack_message:
      if: ${ android() }
      ...

2) Unable to pass parameters into the config

My eas.json currently looks like

"build": {
  "common": {
    "android": {
      "config": "android.config.yml"
    },
    "ios": {
      "config": "ios.config.yml"
    }
  }

Depending on the config I want to use a different slack_url, ideally I can do something like:

"android": {
  "config": "android.config.yml",
  "parameters": {
    "slack_url": "..."
  }
},

3) Unable to generate a string inside of a custom function with newlines

I've tried to create a custom function that would generate a custom slack message, set that as it's output and then use this output inside the eas/send_slack_message. Unfortunately I could not get this to work properly. I would get the expected data in my slack channel but was unable to get it formatted correctly with newlines. I tried everything I could think of but had no luck. Using the message: input directly did work without issues so I've gone with this approach for now.

4) Custom builds that do not run - eas/build cost the same amount as a normal build

Due to running into the above mentioned issues I had to create around 60 builds. To make it faster to test my various approaches I disabled the eas/build step and only had the slack integration running. I was surprised to find out that this costs the same amount as actually creating a full build. I'm wondering if in the future there could be a free/discounted rate for this?

Managed or bare?

Managed

Environment

expo-env-info 1.2.0 environment info: System: OS: Windows 11 10.0.22631 Binaries: Node: 20.11.1 - C:\Program Files\nodejs\node.EXE Yarn: 1.22.21 - ~\AppData\Roaming\npm\yarn.CMD npm: 9.8.0 - C:\Program Files\nodejs\npm.CMD Expo Workflow: managed

Error output

No response

Reproducible demo or steps to reproduce from a blank project

My projectId is a5c2db3f-5810-4a9e-8e9a-54a463a29af9. You should be able to see all the builds I've created on there.

szdziedzic commented 8 months ago

Hi @dannyBies,

Thanks for the feedback! We really appreciate it!

1) Unable to conditionally execute a step depending on the platform

We are planning to add this functionality soon. Thanks for the suggestion! Meanwhile (as you probably noticed) it's probably necessary to maintain two separate configs for each platform for now.

2) Unable to pass parameters into the config

You can try to do something like this to make it work for you really similarly

{
  "build": {
    "my-build-profile": {
      "config": "my-config.yml",
      "android": {
        "env": {
          "SLACK_URL": "android-specific-url"
        }
      },
      "ios": {
        "env": {
          "SLACK_URL": "ios-specific-url"
        }
      }
    }
  }
}
build:
  name: My config
  steps:
    ...
    - eas/send_slack_message:
        if: ${ always() }
        name: Send Slack message when the build finishes
        inputs:
          slack_hook_url: ${ eas.env.SLACK_URL }

For iOS the ios env value will be used and for Android the android one will be used.

3) Unable to generate a string inside of a custom function with newlines

Sounds like a real bug, we will try to replicate it and resolve the issue. Thanks for the report!

4) Custom builds that do not run eas/build cost the same amount as a normal build

I will get back to you on this

radoslawkrzemien commented 8 months ago

Hi @dannyBies , thank you for reporting

3) Unable to generate a string inside of a custom function with newlines

I have replicated the issue and can confirm that it is a bug. I will be working on the fix and let you know when it is done

dannyBies commented 8 months ago

Thanks for the quick updates, much appreciated!

Unable to pass parameters into the config

Thanks for the workaround! Ideally I don't want to use env as that would mean it's possible for the value to be accessed by the app itself. In this scenario I would want this value to be only accessible to the build process for security reasons.

radoslawkrzemien commented 8 months ago

Hi @dannyBies , the fix for

3) Unable to generate a string inside of a custom function with newlines

is in review and should be live later today

dannyBies commented 8 months ago

I just finished setting up a slack bot to retrieve eas build info with slash commands. With this fix I'll be able to fully implement all of the slack integration points I was planning to make. Thanks for the hard work!

radoslawkrzemien commented 8 months ago

@dannyBies Messages with newline characters generated as output from other steps should work now