-
Notifications
You must be signed in to change notification settings - Fork 3k
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
[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] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 ❤️ !! |
.github/workflows/testBuild.yml
Outdated
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
echo
likely isn't needed here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why ;
?
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why are we saving a json file here? Can't we just use a bash variable?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure I understand why we need this tmp file?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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! |
.github/workflows/testBuild.yml
Outdated
- name: Create CloudFront distribution for the PR if needed | ||
run: ./.github/scripts/createCloudfrontDistribution.sh "$PULL_REQUEST_NUMBER" | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can also be removed now
.github/workflows/testBuild.yml
Outdated
- 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can also be removed.
.github/workflows/testBuild.yml
Outdated
| ![Android](https://api.qrserver.com/v1/create-qr-code/?size=200x200&data=${{fromJson(steps.set_var.outputs.android_paths).html_path}}) | ![iOS](https://api.qrserver.com/v1/create-qr-code/?size=200x200&data=${{fromJson(steps.set_var.outputs.ios_paths).html_path}}) | ![desktop](https://api.qrserver.com/v1/create-qr-code/?size=200x200&data=https://ad-hoc-expensify-cash.s3.amazonaws.com/desktop/$PULL_REQUEST_NUMBER/NewExpensify.dmg) |" | ||
| 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The URL now is:
https://<PR_NUMBER>.pr-testing.expensify.com
@coleaeason Thanks for the info, I've just applied the changes! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
testBuild
workflowFixed Issues
$ GH_LINK
PROPOSAL: GH_LINK_ISSUE(COMMENT)
Tests
Offline tests
QA Steps
PR Author Checklist
### Fixed Issues
section aboveTests
sectionOffline steps
sectionQA steps
sectiontoggleReport
and notonIconClick
)src/languages/*
files and using the translation methodWaiting for Copy
label for a copy review on the original GH to get the correct copy.STYLE.md
) were followedAvatar
, I verified the components usingAvatar
are working as expected)/** comment above it */
this
properly so there are no scoping issues (i.e. foronClick={this.submit}
the methodthis.submit
should be bound tothis
in the constructor)this
are necessary to be bound (i.e. avoidthis.submit = this.submit.bind(this);
ifthis.submit
is never passed to a component event handler likeonClick
)StyleUtils.getBackgroundAndBorderStyle(themeColors.componentBG
)Avatar
is modified, I verified thatAvatar
is working as expected in all cases)ScrollView
component to make it scrollable when more elements are added to the page.Screenshots/Videos
Web
Mobile Web - Chrome
Mobile Web - Safari
Desktop
iOS
Android