Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EAS Custom Build issues #2261

Open
dannyBies opened this issue Mar 4, 2024 · 6 comments
Open

EAS Custom Build issues #2261

dannyBies opened this issue Mar 4, 2024 · 6 comments
Labels
needs review Issue is ready to be reviewed by a maintainer

Comments

@dannyBies
Copy link

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.

@dannyBies dannyBies added the needs review Issue is ready to be reviewed by a maintainer label Mar 4, 2024
@szdziedzic
Copy link
Member

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.

  1. 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.

  1. 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!

  1. 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
Copy link
Contributor

Hi @dannyBies , thank you for reporting

  1. 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
Copy link
Author

dannyBies commented Mar 6, 2024

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
Copy link
Contributor

Hi @dannyBies , the fix for

  1. Unable to generate a string inside of a custom function with newlines

is in review and should be live later today

@dannyBies
Copy link
Author

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 added a commit to expo/eas-build that referenced this issue Mar 11, 2024
Added escape character fix to value getter in BuildStepInput.ts

See: expo/eas-cli#2261
radoslawkrzemien added a commit to expo/eas-build that referenced this issue Mar 11, 2024
Added tests for global fix for new line escape characters

See: expo/eas-cli#2261
radoslawkrzemien added a commit to expo/eas-build that referenced this issue Mar 12, 2024
* [build-tools] Fix text messages

Added test to check if the multiline message gets sent properly

See: https://linear.app/expo/issue/ENG-11196/create-custom-build-example-slacking-team-members

* [build-tools] Fix text messages

Replacing all occurrences of `\\n` with `\n` after `JSON.stringify()`

See: https://linear.app/expo/issue/ENG-11196/create-custom-build-example-slacking-team-members

* [build-tools] Fix text messages

Extracted the logic to a separate function and added tests for the case that came up during testing

See: https://linear.app/expo/issue/ENG-11196/create-custom-build-example-slacking-team-members

* [build-tools] Revert change

Removed fixing escape characters from sendSlackMessage.ts to make it more global

See: https://linear.app/expo/issue/ENG-11196/create-custom-build-example-slacking-team-members

* [steps] Globally fix escape characters

Added escape character fix to value getter in BuildStepInput.ts

See: expo/eas-cli#2261

* [steps] Add tests

Added tests for global fix for new line escape characters

See: expo/eas-cli#2261
@radoslawkrzemien
Copy link
Contributor

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs review Issue is ready to be reviewed by a maintainer
Projects
None yet
Development

No branches or pull requests

3 participants