Skip to content

Commit e132b25

Browse files
authored
Add CommitID to logged information at start for sample apps (#4067)
* Add BuildVersionOverlay component to display build version * Add commit SHA as environment variable * Inject env in webpack * Fix environment variable reference in webpack config * Update build version and remove unused code * Add commit ID to build version overlay * Update __COMMITID__ variable to use REACT_APP_COMMIT_SHA environment variable * Update ACS sample apps with commit ID * Fix commit ID variable assignment * Change files * Duplicate change files for beta release * Make messages consistent
1 parent 44946d7 commit e132b25

12 files changed

Lines changed: 39 additions & 52 deletions

File tree

.github/workflows/alpha-release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313
build_and_test:
1414
name: Build and Test
1515
runs-on: ubuntu-latest
16-
permissions:
16+
permissions:
1717
contents: write
1818
steps:
1919
# Check-out repo

.github/workflows/deploy-azure-webapps.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,9 @@ jobs:
4242
- name: Install Rush
4343
run: npm install -g @microsoft/rush@5.112.2
4444

45+
- name: Set commit SHA as environment variable
46+
run: echo "REACT_APP_COMMIT_SHA=${GITHUB_SHA::7}" >> $GITHUB_ENV
47+
4548
- name: Install Dependencies
4649
run: rush install --max-install-attempts 3
4750

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"type": "patch",
3+
"area": "improvement",
4+
"workstream": "",
5+
"comment": "Add commitID to console logged message for azure deployed sample apps.",
6+
"packageName": "@azure/communication-react",
7+
"email": "73612854+palatter@users.noreply.github.com",
8+
"dependentChangeType": "patch"
9+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"type": "patch",
3+
"area": "improvement",
4+
"workstream": "",
5+
"comment": "Add commitID to console logged message for azure deployed sample apps.",
6+
"packageName": "@azure/communication-react",
7+
"email": "73612854+palatter@users.noreply.github.com",
8+
"dependentChangeType": "patch"
9+
}

common/config/webpack/sampleapp.webpack.config.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,8 @@ const webpackConfig = (sampleAppDir, env, babelConfig) => {
6868
__CALLINGVERSION__: JSON.stringify(require(path.resolve(sampleAppDir, 'package.json')).dependencies['@azure/communication-calling']),
6969
__CHATVERSION__: JSON.stringify(require(path.resolve(sampleAppDir, 'package.json')).dependencies['@azure/communication-chat']),
7070
__COMMUNICATIONREACTVERSION__: JSON.stringify(require(path.resolve(sampleAppDir, 'package.json')).dependencies['@azure/communication-react']),
71-
__BUILDTIME__: JSON.stringify(new Date().toLocaleString())
71+
__BUILDTIME__: JSON.stringify(new Date().toLocaleString()),
72+
__COMMITID__: `"${process.env.REACT_APP_COMMIT_SHA || ''}"`,
7273
}),
7374
new BundleAnalyzerPlugin({
7475
analyzerMode: 'json'

samples/CallWithChat/src/app/App.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import {
1111
buildTime,
1212
callingSDKVersion,
1313
chatSDKVersion,
14+
commitID,
1415
communicationReactSDKVersion,
1516
createGroupId,
1617
ensureJoinableCallLocatorPushedToUrl,
@@ -51,7 +52,7 @@ interface CallWithChatArgs {
5152
type AppPages = 'home' | 'call' | 'error';
5253

5354
console.log(
54-
`ACS sample Call with Chat app. Last Updated ${buildTime} Using @azure/communication-calling:${callingSDKVersion}, @azure/communication-chat:${chatSDKVersion}, and @azure/communication-react:${communicationReactSDKVersion}`
55+
`ACS sample Call with Chat app. Last Updated ${buildTime} with CommitID:${commitID} using @azure/communication-calling:${callingSDKVersion}, @azure/communication-chat:${chatSDKVersion}, and @azure/communication-react:${communicationReactSDKVersion}`
5556
);
5657

5758
const App = (): JSX.Element => {

samples/CallWithChat/src/app/utils/AppUtils.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,3 +88,6 @@ export const chatSDKVersion = __CHATVERSION__;
8888

8989
declare let __COMMUNICATIONREACTVERSION__: string; //Injected by webpack
9090
export const communicationReactSDKVersion = __COMMUNICATIONREACTVERSION__;
91+
92+
declare let __COMMITID__: string; //Injected by webpack
93+
export const commitID = __COMMITID__;

samples/CallWithChat/src/app/utils/utils.ts

Lines changed: 0 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,6 @@
11
// Copyright (c) Microsoft Corporation.
22
// Licensed under the MIT License.
33

4-
declare let __BUILDTIME__: string; // Injected by webpack
5-
declare let __CHATVERSION__: string; // Injected by webpack
6-
export const getChatSDKVersion = (): string => __CHATVERSION__;
7-
export const getBuildTime = (): string => __BUILDTIME__;
8-
export const CAT = '🐱';
9-
export const MOUSE = '🐭';
10-
export const KOALA = '🐨';
11-
export const OCTOPUS = '🐙';
12-
export const MONKEY = '🐵';
13-
export const FOX = '🦊';
14-
15-
export const getBackgroundColor = (avatar: string): { backgroundColor: string } => {
16-
switch (avatar) {
17-
case CAT:
18-
return {
19-
backgroundColor: 'rgb(255, 250, 228)'
20-
};
21-
case MOUSE:
22-
return {
23-
backgroundColor: 'rgb(232, 242, 249)'
24-
};
25-
case KOALA:
26-
return {
27-
backgroundColor: 'rgb(237, 232, 230)'
28-
};
29-
case OCTOPUS:
30-
return {
31-
backgroundColor: 'rgb(255, 240, 245)'
32-
};
33-
case MONKEY:
34-
return {
35-
backgroundColor: 'rgb(255, 245, 222)'
36-
};
37-
case FOX:
38-
return {
39-
backgroundColor: 'rgb(255, 231, 205)'
40-
};
41-
default:
42-
return {
43-
backgroundColor: 'rgb(255, 250, 228)'
44-
};
45-
}
46-
};
47-
484
/**
495
* Function to detect iOS devices like IPhones, IPads, and IPods
506
*/

samples/Calling/src/app/App.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import React, { useEffect, useState } from 'react';
1515
import {
1616
buildTime,
1717
callingSDKVersion,
18+
commitID,
1819
communicationReactSDKVersion,
1920
createGroupId,
2021
fetchTokenResponse,
@@ -39,7 +40,7 @@ import { UnsupportedBrowserPage } from './views/UnsupportedBrowserPage';
3940
setLogLevel('error');
4041

4142
console.log(
42-
`ACS sample calling app. Last Updated ${buildTime} Using @azure/communication-calling:${callingSDKVersion} and @azure/communication-react:${communicationReactSDKVersion}`
43+
`ACS sample calling app. Last Updated ${buildTime} with CommitID:${commitID} using @azure/communication-calling:${callingSDKVersion} and @azure/communication-react:${communicationReactSDKVersion}`
4344
);
4445

4546
initializeIcons();

samples/Calling/src/app/utils/AppUtils.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,3 +142,6 @@ export const callingSDKVersion = __CALLINGVERSION__;
142142

143143
declare let __COMMUNICATIONREACTVERSION__: string; //Injected by webpack
144144
export const communicationReactSDKVersion = __COMMUNICATIONREACTVERSION__;
145+
146+
declare let __COMMITID__: string; //Injected by webpack
147+
export const commitID = __COMMITID__;

0 commit comments

Comments
 (0)