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

[NO QA] Update build.gradle for hybrid app adhoc builds #53214

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions .github/actions/javascript/postTestBuildComment/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,22 @@ description: "Mark pull requests as deployed on production or staging"
inputs:
PR_NUMBER:
description: "Pull request number"
required: true
required: false
GITHUB_TOKEN:
description: "Github token for authentication"
default: "${{ github.token }}"
ANDROID:
description: "Android job result ('success', 'failure', 'cancelled', or 'skipped')"
required: true
required: false
DESKTOP:
description: "Desktop job result ('success', 'failure', 'cancelled', or 'skipped')"
required: true
required: false
IOS:
description: "iOS job result ('success', 'failure', 'cancelled', or 'skipped')"
required: true
required: false
WEB:
description: "Web job result ('success', 'failure', 'cancelled', or 'skipped')"
required: true
required: false
Comment on lines -6 to +21
Copy link
Contributor

Choose a reason for hiding this comment

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

Won't this change will affect our existing builds?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't think so. This action is only used in testBuild.yml where all four platforms are passed. I modified the script so it checks if given platform is included so there shouldn't be any problems

Copy link
Contributor

Choose a reason for hiding this comment

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

Okay thanks. Once last question: If we are now checking for the script elsewhere, why was this change necessary? It seems to me that requiring at the action level is a bit safer than a check deeper within a script.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

action.yml is file with metadata and specifies input. I modified the script so not all platforms are required. If input for given platform is not specified there will be N/A in table with statuses and links.

It's probably not ideal but I wanted to reuse already written action

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah okay. So We are reusing action logic, but need to account for platforms not being provided. It sounds reasonable.

ANDROID_LINK:
description: "Link for the Android build"
required: false
Expand Down
49 changes: 28 additions & 21 deletions .github/actions/javascript/postTestBuildComment/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11502,31 +11502,38 @@ const github_1 = __nccwpck_require__(5438);
const CONST_1 = __importDefault(__nccwpck_require__(9873));
const GithubUtils_1 = __importDefault(__nccwpck_require__(9296));
function getTestBuildMessage() {
console.log('Input for android', core.getInput('ANDROID', { required: true }));
const androidSuccess = core.getInput('ANDROID', { required: true }) === 'success';
const desktopSuccess = core.getInput('DESKTOP', { required: true }) === 'success';
const iOSSuccess = core.getInput('IOS', { required: true }) === 'success';
const webSuccess = core.getInput('WEB', { required: true }) === 'success';
const androidLink = androidSuccess ? core.getInput('ANDROID_LINK') : '❌ FAILED ❌';
const desktopLink = desktopSuccess ? core.getInput('DESKTOP_LINK') : '❌ FAILED ❌';
const iOSLink = iOSSuccess ? core.getInput('IOS_LINK') : '❌ FAILED ❌';
const webLink = webSuccess ? core.getInput('WEB_LINK') : '❌ FAILED ❌';
const androidQRCode = androidSuccess
? `![Android](https://api.qrserver.com/v1/create-qr-code/?size=120x120&data=${androidLink})`
: "The QR code can't be generated, because the android build failed";
const desktopQRCode = desktopSuccess
? `![Desktop](https://api.qrserver.com/v1/create-qr-code/?size=120x120&data=${desktopLink})`
: "The QR code can't be generated, because the Desktop build failed";
const iOSQRCode = iOSSuccess ? `![iOS](https://api.qrserver.com/v1/create-qr-code/?size=120x120&data=${iOSLink})` : "The QR code can't be generated, because the iOS build failed";
const webQRCode = webSuccess ? `![Web](https://api.qrserver.com/v1/create-qr-code/?size=120x120&data=${webLink})` : "The QR code can't be generated, because the web build failed";
const inputs = ['ANDROID', 'DESKTOP', 'IOS', 'WEB'];
const names = {
[inputs[0]]: 'Android',
[inputs[1]]: 'Desktop',
[inputs[2]]: 'iOS',
[inputs[3]]: 'Web',
};
const result = inputs.reduce((acc, platform) => {
const input = core.getInput(platform, { required: false });
if (!input) {
acc[platform] = { link: 'N/A', qrCode: 'N/A' };
return acc;
}
const isSuccess = input === 'success';
const link = isSuccess ? core.getInput(`${platform}_LINK`) : '❌ FAILED ❌';
const qrCode = isSuccess
? `![${names[platform]}](https://api.qrserver.com/v1/create-qr-code/?size=120x120&data=${link})`
: `The QR code can't be generated, because the ${names[platform]} build failed`;
acc[platform] = {
link,
qrCode,
};
return acc;
}, {});
const message = `:test_tube::test_tube: Use the links below to test this adhoc build on Android, iOS, Desktop, and Web. Happy testing! :test_tube::test_tube:
| Android :robot: | iOS :apple: |
| ------------- | ------------- |
| ${androidLink} | ${iOSLink} |
| ${androidQRCode} | ${iOSQRCode} |
| ${result.ANDROID.link} | ${result.IOS.link} |
| ${result.ANDROID.qrCode} | ${result.IOS.qrCode} |
| Desktop :computer: | Web :spider_web: |
| ${desktopLink} | ${webLink} |
| ${desktopQRCode} | ${webQRCode} |
| ${result.DESKTOP.link} | ${result.WEB.link} |
| ${result.DESKTOP.qrCode} | ${result.WEB.qrCode} |

---

Expand Down
Original file line number Diff line number Diff line change
@@ -1,37 +1,48 @@
import * as core from '@actions/core';
import {context} from '@actions/github';
import type {TupleToUnion} from 'type-fest';
import CONST from '@github/libs/CONST';
import GithubUtils from '@github/libs/GithubUtils';

function getTestBuildMessage(): string {
console.log('Input for android', core.getInput('ANDROID', {required: true}));
const androidSuccess = core.getInput('ANDROID', {required: true}) === 'success';
const desktopSuccess = core.getInput('DESKTOP', {required: true}) === 'success';
const iOSSuccess = core.getInput('IOS', {required: true}) === 'success';
const webSuccess = core.getInput('WEB', {required: true}) === 'success';
const inputs = ['ANDROID', 'DESKTOP', 'IOS', 'WEB'] as const;
const names = {
[inputs[0]]: 'Android',
[inputs[1]]: 'Desktop',
[inputs[2]]: 'iOS',
[inputs[3]]: 'Web',
};

const androidLink = androidSuccess ? core.getInput('ANDROID_LINK') : '❌ FAILED ❌';
const desktopLink = desktopSuccess ? core.getInput('DESKTOP_LINK') : '❌ FAILED ❌';
const iOSLink = iOSSuccess ? core.getInput('IOS_LINK') : '❌ FAILED ❌';
const webLink = webSuccess ? core.getInput('WEB_LINK') : '❌ FAILED ❌';
const result = inputs.reduce((acc, platform) => {
const input = core.getInput(platform, {required: false});

const androidQRCode = androidSuccess
? `![Android](https://api.qrserver.com/v1/create-qr-code/?size=120x120&data=${androidLink})`
: "The QR code can't be generated, because the android build failed";
const desktopQRCode = desktopSuccess
? `![Desktop](https://api.qrserver.com/v1/create-qr-code/?size=120x120&data=${desktopLink})`
: "The QR code can't be generated, because the Desktop build failed";
const iOSQRCode = iOSSuccess ? `![iOS](https://api.qrserver.com/v1/create-qr-code/?size=120x120&data=${iOSLink})` : "The QR code can't be generated, because the iOS build failed";
const webQRCode = webSuccess ? `![Web](https://api.qrserver.com/v1/create-qr-code/?size=120x120&data=${webLink})` : "The QR code can't be generated, because the web build failed";
if (!input) {
acc[platform] = {link: 'N/A', qrCode: 'N/A'};
return acc;
}

const isSuccess = input === 'success';

const link = isSuccess ? core.getInput(`${platform}_LINK`) : '❌ FAILED ❌';
const qrCode = isSuccess
? `![${names[platform]}](https://api.qrserver.com/v1/create-qr-code/?size=120x120&data=${link})`
: `The QR code can't be generated, because the ${names[platform]} build failed`;

acc[platform] = {
link,
qrCode,
};
return acc;
}, {} as Record<TupleToUnion<typeof inputs>, {link: string; qrCode: string}>);

const message = `:test_tube::test_tube: Use the links below to test this adhoc build on Android, iOS, Desktop, and Web. Happy testing! :test_tube::test_tube:
| Android :robot: | iOS :apple: |
| ------------- | ------------- |
| ${androidLink} | ${iOSLink} |
| ${androidQRCode} | ${iOSQRCode} |
| ${result.ANDROID.link} | ${result.IOS.link} |
| ${result.ANDROID.qrCode} | ${result.IOS.qrCode} |
| Desktop :computer: | Web :spider_web: |
| ${desktopLink} | ${webLink} |
| ${desktopQRCode} | ${webQRCode} |
| ${result.DESKTOP.link} | ${result.WEB.link} |
| ${result.DESKTOP.qrCode} | ${result.WEB.qrCode} |

---

Expand Down
Loading
Loading