Skip to content

Commit

Permalink
Make platforms optional for publishing links
Browse files Browse the repository at this point in the history
  • Loading branch information
jnowakow committed Nov 29, 2024
1 parent bc599be commit 7ad51a8
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 45 deletions.
53 changes: 32 additions & 21 deletions .github/actions/javascript/postTestBuildComment/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11502,31 +11502,42 @@ 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) {
return {
...acc,
[platform]: { link: 'N/A', qrCode: 'N/A' },
};
}
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`;
return {
...acc,
[platform]: {
link,
qrCode,
},
};
}, {});
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
Expand Up @@ -4,34 +4,48 @@ 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) => {

Check failure on line 15 in .github/actions/javascript/postTestBuildComment/postTestBuildComment.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Avoid a use of spread (`...`) operator on accumulators in reduce callback. Mutate them directly instead

Check failure on line 15 in .github/actions/javascript/postTestBuildComment/postTestBuildComment.ts

View workflow job for this annotation

GitHub Actions / ESLint check

Avoid a use of spread (`...`) operator on accumulators in reduce callback. Mutate them directly instead
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) {
return {
...acc,
[platform]: {link: 'N/A', qrCode: 'N/A'},
};
}

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`;

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

Check failure on line 39 in .github/actions/javascript/postTestBuildComment/postTestBuildComment.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Prefer using `TupleToUnion` from `type-fest` for converting tuple types to union types

Check failure on line 39 in .github/actions/javascript/postTestBuildComment/postTestBuildComment.ts

View workflow job for this annotation

GitHub Actions / ESLint check

Prefer using `TupleToUnion` from `type-fest` for converting tuple types to union types

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} |

Check failure on line 44 in .github/actions/javascript/postTestBuildComment/postTestBuildComment.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

["ANDROID"] is better written in dot notation

Check failure on line 44 in .github/actions/javascript/postTestBuildComment/postTestBuildComment.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

["IOS"] is better written in dot notation

Check failure on line 44 in .github/actions/javascript/postTestBuildComment/postTestBuildComment.ts

View workflow job for this annotation

GitHub Actions / ESLint check

["ANDROID"] is better written in dot notation

Check failure on line 44 in .github/actions/javascript/postTestBuildComment/postTestBuildComment.ts

View workflow job for this annotation

GitHub Actions / ESLint check

["IOS"] is better written in dot notation
| ${result['ANDROID'].qrCode} | ${result['IOS'].qrCode} |

Check failure on line 45 in .github/actions/javascript/postTestBuildComment/postTestBuildComment.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

["ANDROID"] is better written in dot notation

Check failure on line 45 in .github/actions/javascript/postTestBuildComment/postTestBuildComment.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

["IOS"] is better written in dot notation

Check failure on line 45 in .github/actions/javascript/postTestBuildComment/postTestBuildComment.ts

View workflow job for this annotation

GitHub Actions / ESLint check

["ANDROID"] is better written in dot notation

Check failure on line 45 in .github/actions/javascript/postTestBuildComment/postTestBuildComment.ts

View workflow job for this annotation

GitHub Actions / ESLint check

["IOS"] is better written in dot notation
| Desktop :computer: | Web :spider_web: |
| ${desktopLink} | ${webLink} |
| ${desktopQRCode} | ${webQRCode} |
| ${result['DESKTOP'].link} | ${result['WEB'].link} |

Check failure on line 47 in .github/actions/javascript/postTestBuildComment/postTestBuildComment.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

["DESKTOP"] is better written in dot notation

Check failure on line 47 in .github/actions/javascript/postTestBuildComment/postTestBuildComment.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

["WEB"] is better written in dot notation

Check failure on line 47 in .github/actions/javascript/postTestBuildComment/postTestBuildComment.ts

View workflow job for this annotation

GitHub Actions / ESLint check

["DESKTOP"] is better written in dot notation

Check failure on line 47 in .github/actions/javascript/postTestBuildComment/postTestBuildComment.ts

View workflow job for this annotation

GitHub Actions / ESLint check

["WEB"] is better written in dot notation
| ${result['DESKTOP'].qrCode} | ${result['WEB'].qrCode} |

Check failure on line 48 in .github/actions/javascript/postTestBuildComment/postTestBuildComment.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

["DESKTOP"] is better written in dot notation

Check failure on line 48 in .github/actions/javascript/postTestBuildComment/postTestBuildComment.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

["WEB"] is better written in dot notation

Check failure on line 48 in .github/actions/javascript/postTestBuildComment/postTestBuildComment.ts

View workflow job for this annotation

GitHub Actions / ESLint check

["DESKTOP"] is better written in dot notation

Check failure on line 48 in .github/actions/javascript/postTestBuildComment/postTestBuildComment.ts

View workflow job for this annotation

GitHub Actions / ESLint check

["WEB"] is better written in dot notation
---
Expand Down
3 changes: 0 additions & 3 deletions .github/workflows/testBuildHybrid.yml
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,4 @@ jobs:
PR_NUMBER: ${{ env.PULL_REQUEST_NUMBER }}
GITHUB_TOKEN: ${{ github.token }}
ANDROID: ${{ needs.uploadAndroid.result }}
DESKTOP: failed
IOS: failed
WEB: failed
ANDROID_LINK: ${{ needs.uploadAndroid.outputs.S3_APK_PATH }}

0 comments on commit 7ad51a8

Please sign in to comment.