[NoQA] Web job for the testBuild workflow#13354
Conversation
|
@PauloGasparSv Please copy/paste the Reviewer Checklist from here into a new comment on this PR and complete it. If you have the K2 extension, you can simply click: [this button] |
luacmartins
left a comment
There was a problem hiding this comment.
LGTM but I'd definitely like more eyes since these workflows aren't my strength
|
Please do not merge - I need to confirm with the infra team this is how we want to set it up. |
|
Is this P.R. ready for review? I saw some changes earlier today and no GH issue linked so I was waiting for an update to start reviewing. |
|
@coleaeason said he would review the infra side of things, thank you @coleaeason ❤️ !! |
| PULL_REQUEST_NUMBER: ${{ github.event.number }} | ||
|
|
||
| - name: Create CloudFront distribution for the PR if needed | ||
| run: ./.github/scripts/verifyActions.sh "$PULL_REQUEST_NUMBER" |
There was a problem hiding this comment.
It looks like this is calling the wrong script? should this be the new script you added?
| #!/bin/bash | ||
| set -e | ||
|
|
||
| DISTRIBUTION_ID=$(echo aws cloudfront list-distributions --query "DistributionList.Items[?Origins.Items[?OriginPath=='/web/$1']].Id" --output text) |
There was a problem hiding this comment.
echo likely isn't needed here?
There was a problem hiding this comment.
Removed, thank you, I missed this one!
|
|
||
| DISTRIBUTION_ID=$(echo aws cloudfront list-distributions --query "DistributionList.Items[?Origins.Items[?OriginPath=='/web/$1']].Id" --output text) | ||
|
|
||
| if [[ $(aws cloudfront list-distributions --query "DistributionList.Items[0].Id") != null ]] && [[ $DISTRIBUTION_ID ]] ; then |
There was a problem hiding this comment.
is null a string? null doesn't exist in bash; so i think you mean "null"?
Also can you make the second item explicit? i.e. $DISTRIBUTION_ID != ""?
There was a problem hiding this comment.
Actually a string "null" is returned, that's why I was checking it. I've just updated the script by adding the "
| if [[ $(aws cloudfront list-distributions --query "DistributionList.Items[0].Id") != null ]] && [[ $DISTRIBUTION_ID ]] ; then | ||
| echo "Distribution for PR #$1 already exists! Invalidating cache..." | ||
| aws cloudfront create-invalidation --distribution-id $DISTRIBUTION_ID --paths '/' | ||
| exit 0; |
| exit 0; | ||
| else | ||
| echo "A new distribution for PR #$1 is being created" | ||
| echo $(aws cloudfront create-distribution --origin-domain-name ad-hoc-expensify-cash.s3.us-east-1.amazonaws.com --default-root-object index.html) >> cloudfront.config.json |
There was a problem hiding this comment.
the echo and subprocess isn't needed here. Also why are we writing this to a file? why not:
CLOUDFRONT_CONFIG=$(aws cloudfront create-distribution --origin-domain-name ad-hoc-expensify-cash.s3.us-east-1.amazonaws.com --default-root-object index.html)| echo "A new distribution for PR #$1 is being created" | ||
| echo $(aws cloudfront create-distribution --origin-domain-name ad-hoc-expensify-cash.s3.us-east-1.amazonaws.com --default-root-object index.html) >> cloudfront.config.json | ||
|
|
||
| CONFIG=$(cat "./cloudfront.config.json") |
There was a problem hiding this comment.
if you do my above suggestion you can delete this line
| echo $(aws cloudfront create-distribution --origin-domain-name ad-hoc-expensify-cash.s3.us-east-1.amazonaws.com --default-root-object index.html) >> cloudfront.config.json | ||
|
|
||
| CONFIG=$(cat "./cloudfront.config.json") | ||
| DISTRIBUTION_ID=$(echo $CONFIG | jq -r .Distribution.Id) |
There was a problem hiding this comment.
nab, you can do:
jq -r .Distribution.Id <<< $CONFIG|
|
||
| CONFIG=$(cat "./cloudfront.config.json") | ||
| DISTRIBUTION_ID=$(echo $CONFIG | jq -r .Distribution.Id) | ||
| ETAG=$(echo $CONFIG | jq -r .ETag) |
There was a problem hiding this comment.
same here, use a herestring
| DISTRIBUTION_ID=$(echo $CONFIG | jq -r .Distribution.Id) | ||
| ETAG=$(echo $CONFIG | jq -r .ETag) | ||
|
|
||
| echo $CONFIG | jq -r .Distribution.DistributionConfig >> dist.config.json |
There was a problem hiding this comment.
why are we saving a json file here? Can't we just use a bash variable?
There was a problem hiding this comment.
aws cloudfront update-distribution command requires sending a file with the config, that's why I decided to create it
|
|
||
| tmp=$(mktemp /tmp/tmp.XXXXXXX) | ||
| NEW_ORIGIN_PATH=$(echo "/web/$1") | ||
| jq --arg originPath "$NEW_ORIGIN_PATH" '(.Origins.Items[] | select(.OriginPath == "")).OriginPath |= $originPath' dist.config.json > "$tmp" && mv "$tmp" dist.config.json |
There was a problem hiding this comment.
I'm not sure I understand why we need this tmp file?
There was a problem hiding this comment.
As far as I know jq can't edit files, that's why I create a temporary file in order to make a change
|
NAB but I put up a PR here to lint bash scripts in this repo with ShellCheck, and it might be beneficial to make sure that the script you created here is passing ShellCheck using: npx shellcheck -e SC1091 .github/scripts/createCloudfrontDistribution.sh |
|
Apologies, we believe we are going to go a different direction and use Cloudflare workers instead of Cloudfront as mentioned here: https://expensify.slack.com/archives/C04878MDF34/p1671061957278119 @coleaeason will circle back soon with how this is all going to tie together, thank you for your patience! |
| - name: Create CloudFront distribution for the PR if needed | ||
| run: ./.github/scripts/createCloudfrontDistribution.sh "$PULL_REQUEST_NUMBER" | ||
|
|
There was a problem hiding this comment.
As Andrew mentioned, we are going to remove Cloudfront form this setup, so you can remove this step.
| @@ -0,0 +1,24 @@ | |||
| #!/bin/bash | |||
There was a problem hiding this comment.
This can also be removed now
| - name: Get CloudFront URL | ||
| id: get_cloudfront_url | ||
| run: | | ||
| cloudfront_url=$(aws cloudfront list-distributions --query "DistributionList.Items[?Origins.Items[?OriginPath=='/web/$PULL_REQUEST_NUMBER']].DomainName" --output text) | ||
| echo "cloudfront_url=$cloudfront_url" >> "$GITHUB_OUTPUT" | ||
|
|
There was a problem hiding this comment.
This can also be removed.
| | .html_path}}) | .html_path}}) |  |" | ||
| | android :robot: | iOS :apple: | desktop :computer: | web :spider_web: | | ||
| | ------------- | ------------- | ------------- | ------------- | | ||
| | ${{fromJson(steps.set_var.outputs.android_paths).html_path}} | ${{fromJson(steps.set_var.outputs.ios_paths).html_path}} | https://ad-hoc-expensify-cash.s3.amazonaws.com/desktop/$PULL_REQUEST_NUMBER/NewExpensify.dmg | https://${{steps.get_cloudfront_url.outputs.cloudfront_url}} | |
There was a problem hiding this comment.
The URL now is:
https://<PR_NUMBER>.pr-testing.expensify.com
|
@coleaeason Thanks for the info, I've just applied the changes! |
coleaeason
left a comment
There was a problem hiding this comment.
LGTM -- Not sure why checks are failing. @AndrewGable ?
Reviewer Checklist
Screenshots/VideosN/A these changes only affect GH actions. WebMobile Web - ChromeMobile Web - SafariDesktopiOSAndroid |
|
@staszekscp we've updated the author checklist. Could you please update your checklist accordingly? You can find the latest checklist in this template |
|
@luacmartins Done! |
|
✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release. |
|
@AndrewGable @luacmartins @coleaeason The link works, that is cool! Great job guys! https://13354.pr-testing.expensify.com/ I've just noticed something - if the QR code doesn't work, here's the fix: #13673 |
Performance Comparison Report 📊Significant Changes To DurationThere are no entries Meaningless Changes To DurationShow entries
Show details
|
|
Nice! Awesome job @staszekscp! |
|
🧪🧪 Use the links below to test this build in android and iOS. Happy testing! 🧪🧪 |
|
🚀 Deployed to staging by @AndrewGable in version: 1.2.42-0 🚀
|
|
🚀 Deployed to production by @yuwenmemon in version: 1.2.42-2 🚀
|
Details
The PR adds a job to build the web testing app in the
testBuildworkflowFixed Issues
$ GH_LINK
PROPOSAL: GH_LINK_ISSUE(COMMENT)
Tests
Offline tests
QA Steps
PR Author Checklist
### Fixed Issuessection aboveTestssectionOffline stepssectionQA stepssectiontoggleReportand notonIconClick)src/languages/*files and using the translation methodWaiting for Copylabel for a copy review on the original GH to get the correct copy.STYLE.md) were followedAvatar, I verified the components usingAvatarare working as expected)/** comment above it */thisproperly so there are no scoping issues (i.e. foronClick={this.submit}the methodthis.submitshould be bound tothisin the constructor)thisare necessary to be bound (i.e. avoidthis.submit = this.submit.bind(this);ifthis.submitis never passed to a component event handler likeonClick)StyleUtils.getBackgroundAndBorderStyle(themeColors.componentBG)Avataris modified, I verified thatAvataris working as expected in all cases)ScrollViewcomponent to make it scrollable when more elements are added to the page.Screenshots/Videos
Web
Mobile Web - Chrome
Mobile Web - Safari
Desktop
iOS
Android