Skip to content

feat(cat-voices): build time env and runtime config #2135

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

Draft
wants to merge 48 commits into
base: main
Choose a base branch
from

Conversation

damian-molinski
Copy link
Contributor

@damian-molinski damian-molinski commented Apr 1, 2025

Description

This PR allows frontend environment to be configured in build-time. It leads other configuration to be fetched in run-time.

Related Issue(s)

Refers to #178
Part of #2120
Closes #2121
Closes #1328
Closes #1348
Closes #2511

Description of Changes

Note. All of env vars / configs fields are optional and falling back to relative on web and dev in other cases.

You can set --dart-define=ENV_NAME / --flavor or non:

Notes

  • env types dev|preprod|prod|relative
  • if env is not specified relative is used for web or dev otherwise

Relative env type.

This env is ment to be used when building app for deployment. Doing it this way allows us to have single build which can be deployed anywhere together with gateway and get config this way.

Using dart-define

Use this method if you want to point always to main.dart and just change dart-define. Useful when building an app using cli tools or from IDE

flutter run --target apps/voices/lib/configs/main.dart --dart-define=ENV_NAME=prod

Using flavor

Works the same as dart-define just lower priority.

Using entry point

Probably preferred way in development setting. If you point to main_prod.dart|main_preprod.dart|main_dev.dart|
it will just use appropriate env and ignore any --flavour / --dart-define vars

flutter run --target apps/voices/lib/configs/main_prod.dart

Using main_qa.dart or main.dart will attempt to find env --dart-define or --flavor

Using bootstrap()

If you're starting app in tests you can override all of above using optional environment param.

Future<BootstrapArgs> bootstrap({
  GoRouter? router,
  AppEnvironment? environment,
})

Env source priority

1.bootstrap() overrides everything
2. "Entry Point" -> main_prod.dart|main_dev.dart etc
4. --dart-define -> ENV_NAME
5. --flavor
6. Fallback to relative on web and dev in other cases

Please confirm the following checks

  • My code follows the style guidelines of this project
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream module

@damian-molinski damian-molinski added dart Pull requests that update Dart code F14 labels Apr 1, 2025
@damian-molinski damian-molinski self-assigned this Apr 1, 2025
Copy link
Contributor

github-actions bot commented Apr 2, 2025

Test Report | ${\color{lightgreen}Pass: 744/748}$ | ${\color{red}Fail: 0/748}$ |

@damian-molinski damian-molinski moved this from New to 🏗 In progress in Catalyst Apr 3, 2025
@minikin minikin added the do not merge yet PR is not ready to be merged yet label Apr 10, 2025
@damian-molinski damian-molinski added the review me PR is ready for review label Apr 29, 2025
dtscalac
dtscalac previously approved these changes May 5, 2025
Copy link
Contributor

@dtscalac dtscalac left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dart Pull requests that update Dart code do not merge yet PR is not ready to be merged yet F14 review me PR is ready for review
Projects
Status: 🛑 Blocked
4 participants