We maintain several hero sample GitHub repositories. These samples serve both as an easy example for folks to get started with the Azure Communication Services UI library and as a blueprint to integrate the library into their applications.
The hero samples are closely based on the sample applications in this repository:
Hero sample | monorepo sample |
---|---|
Chat | samples/Chat |
Callling | samples/Calling |
We refer to the samples in this monorepository as upstream of the hero samples.
While the hero samples are based on the samples in this repository, there are some differences:
- The samples in this repository use the tooling required to work in a monorepository (
rush
etc.) whereas the hero samples use vanillanpm
. - The samples in this repository are intended to aid development of the library. Thus, they often use
beta
features of@azure/communication-react
that are still under active development. In contrast, the hero samples only usestable
features.- As a corollary, the samples here use conditional compilation to manage the the use of
beta
features. Conditional compilation is unnecessary, and not available, in the hero samples.
- As a corollary, the samples here use conditional compilation to manage the the use of
You should typically update hero samples for two distinct reasons:
- To address any critical bugs in the hero sample.
- The most common example of this are security issues discovered by depandabot filed as GitHub issues on the hero sample repositories.
- To update the hero samples from the corresponding upstream samples.
- Hero samples showcase the latest stable release of
@azure/communication-react
. - You should update the hero samples from upstream every time we release a new stable version for
@azure/communication-react
, to showcase new features being shipped.
- Hero samples showcase the latest stable release of
To fix any critical issues in the hero samples, including depandabot alerts in the hero sample repositories:
- First, fix the issue in the upstream sample.
- Then, port over just the fix to the hero sample.
- Porting over the fix is a manual process. In most cases, this simply involves updating the version of a package.json
dependencies
entry. - The GitHub PR template for hero samples includes a section to add upstream PR references. Link to the upstream PR in this section.
- Porting over the fix is a manual process. In most cases, this simply involves updating the version of a package.json
Updating hero samples from upstream samples is a manual process. You can minimize the toil by following the process recommended in this section.
This section uses an update to the chat hero sample as an example. Follow similar steps when updating the other hero samples.
-
Pick the git commit in this monorepository to update from.
- Pick the git tag for the latest stable release. This ensures that the upstream sample is consistent with the released
@azure/communication-react
version.
- Pick the git tag for the latest stable release. This ensures that the upstream sample is consistent with the released
-
Generate a new source directory from the upstream sample.
- In this monorepository,
cd samples/Chat rushx port-sample
- In this monorepository,
-
This will generate a
samples/Chat/sample-dist
directory which contains the updates to src, Media, public directories insamples/Chat/
, but conditionally compiled for thestable
build flavor and prettified. -
Replace the hero sample sources.
- Create a new branch in the chat hero sample repo.
- Replace
Chat/src
with the generatedsamples/Chat/sample-dist/src
from the directory we generated in the previous step. - Replace
Chat/Media
with the generatedsamples/Chat/sample-dist/Media
from the directory we generated in the previous step. - Replace
Chat/public
with the generatedsamples/Chat/sample-dist/public
from the directory we generated in the previous step. - Create a draft Pull Request against
main
.- Link to the source git commit in upstream that you generated the sources from. Example PR description.
-
Manually fix the generated source.
- Use the draft Pull Request created in the last step to scan over the diff introduced by copying the sources from upstream. Review the draft PR yourself to point out all issues at once.
- See the comments in the example PR for inspiration.
- Some issues you discover should be fixed both in the hero sample and upstream to prevent the problems from arising in the next sync.
- For example, I discovered and fixed some missing conditional compilation directives and some references to
@internal/*
packlets while reviewing the example PR.
- For example, I discovered and fixed some missing conditional compilation directives and some references to
- There are a small set of manual fixes that are unavoidable and must be done each time you update the hero sample from upstream. A later section lists these fixes for each hero sample. Keep that section up to date for future reference.
- Use the draft Pull Request created in the last step to scan over the diff introduced by copying the sources from upstream. Review the draft PR yourself to point out all issues at once.
-
Reconcile
Chat/package.json
. This step is also manual and somewhat non-obvius.- The
dependencies
should mostly match between upstream and hero samples. A recommended approach to updatedependencies
is:- Add all
dependencies
from upstream to the hero sample, under the exisingdependencies
. - Sort alphabetically. This will bring identical keys together.
- Pick the more recent version of the matching keys.
- Exception: for
@azure/communication-react
and its peer dependencies@azure/communication-chat
and@azure/communication-calling
, pick the stable versions.
- Exception: for
- Remove all references to
@internal/*
packlets.
- Add all
devDependencies
should stay mostly unchanged. Upstream has a lot more entries here to support the monorepository tooling that are unnecessary in the hero sample. Check if any unit-testing related depenedencies should be updated.- Run
npm run setup
and commit the updated NPM lockfiles.
- The
-
Test the hero sample.
- Populate appsettings,
npm run start
and smoke test the application. cd Chat && npm run lint
- Populate appsettings,
- Remove webpack injected globals and their use. Exmple commit.
- Remove webpack injected globals and their use. Example commit
Whenever you update a hero sample, consider creating a new "release". The release bundles up the sample application and makes it available for the one-click deploy off of the sample README. As this one-click deploy is likely to be the first experience folks have with Azure Communication Services, it is important that it works smoothly and shows off the best features we have to offer!