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

Feature/multiple deployment #23

Merged
Show file tree
Hide file tree
Changes from 5 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
5 changes: 5 additions & 0 deletions .firebaserc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"projects": {
"default": "env-aware"
}
}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

# dependencies
/builds
/node_modules
/.pnp
.pnp.js
Expand Down
97 changes: 97 additions & 0 deletions build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
#!/bin/bash
multipleBuildsPath="../functions/builds/"
individualBuildAllFiles="build/*"

craBatteryConsiderateLoading="cra-battery-considerate-loading"
craDeviceClassAwareLoading="cra-device-class-aware-loading"
craMemoryConsiderateLoading="cra-memory-considerate-loading"
craMemoryConsiderateLoadingSketchfab="cra-memory-considerate-loading-sketchfab"
craNetworkAwareCodeSplitting="cra-network-aware-code-splitting"
craNetworkAwareComponent="cra-network-aware-component"
craNetworkAwareDataFetching="cra-network-aware-data-fetching"
craUaAwareCodeSplitting="cra-ua-aware-code-splitting"
reactMovieNetworkAwareComponents="react-movie-network-aware-components"
reactShrineNetworkAwareCodeSplitting="react-shrine-network-aware-code-splitting"

Copy link
Collaborator

Choose a reason for hiding this comment

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

Nothing to change with respect to this feedback, but leaving here for later:

In a typical review, I would normally say we should figure out how to define the list of subprojects in an array and iterate over the build and deploy steps for them in a loop as the steps are currently quite similar. That said, I actually like the flexibility we get with your current setup in case we need really granular control at some point.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, I totally agree with you.
I was eager to use loop and array of projects because the current version looks not professional and even hardcoded.
But on the other hand I thought I should not spend much time on secondary problems.
So just for now I described this bash script to the meaningful extend because I thought I could get back to this refinement when I get some free or extra time.
TODO is remained here :)

# cd cra-battery-considerate-loading
cd $craBatteryConsiderateLoading
rm -rf node_modules build
npm install
npm run build
# mkdir -p ../functions/builds/cra-battery-considerate-loading
mkdir -p "${multipleBuildsPath}${craBatteryConsiderateLoading}"
# cp -r build/* ../functions/builds/cra-battery-considerate-loading
cp -r $individualBuildAllFiles "${multipleBuildsPath}${craBatteryConsiderateLoading}"
cd ..

cd $craDeviceClassAwareLoading
Copy link
Collaborator

Choose a reason for hiding this comment

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

Am I correct in saying if a build for a particular sub-project fails, we will bail out of building the others?

Copy link
Contributor Author

@anton-karlovskiy anton-karlovskiy Jul 30, 2019

Choose a reason for hiding this comment

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

I'm afraid I have not tried if we can skip the failure and keep going with the rest of builds.
Let me try by deliberately causing an error to one build.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Based on what I've tested, we can skip the failure and keep going with the rest of builds.

rm -rf node_modules build
npm install
npm run build
mkdir -p "${multipleBuildsPath}${craDeviceClassAwareLoading}"
cp -r $individualBuildAllFiles "${multipleBuildsPath}${craDeviceClassAwareLoading}"
cd ..

cd $craMemoryConsiderateLoading
rm -rf node_modules build
npm install
npm run build
mkdir -p "${multipleBuildsPath}${craMemoryConsiderateLoading}"
cp -r $individualBuildAllFiles "${multipleBuildsPath}${craMemoryConsiderateLoading}"
cd ..

cd $craMemoryConsiderateLoadingSketchfab
rm -rf node_modules build
npm install
npm run build
mkdir -p "${multipleBuildsPath}${craMemoryConsiderateLoadingSketchfab}"
cp -r $individualBuildAllFiles "${multipleBuildsPath}${craMemoryConsiderateLoadingSketchfab}"
cd ..

cd $craNetworkAwareCodeSplitting
rm -rf node_modules build
npm install
npm run build
mkdir -p "${multipleBuildsPath}${craNetworkAwareCodeSplitting}"
cp -r $individualBuildAllFiles "${multipleBuildsPath}${craNetworkAwareCodeSplitting}"
cd ..

cd $craNetworkAwareComponent
rm -rf node_modules build
npm install
npm run build
mkdir -p "${multipleBuildsPath}${craNetworkAwareComponent}"
cp -r $individualBuildAllFiles "${multipleBuildsPath}${craNetworkAwareComponent}"
cd ..

cd $craNetworkAwareDataFetching
rm -rf node_modules build
npm install
npm run build
mkdir -p "${multipleBuildsPath}${craNetworkAwareDataFetching}"
cp -r $individualBuildAllFiles "${multipleBuildsPath}${craNetworkAwareDataFetching}"
cd ..

cd $craUaAwareCodeSplitting
rm -rf node_modules build
npm install
npm run build
mkdir -p "${multipleBuildsPath}${craUaAwareCodeSplitting}"
cp -r $individualBuildAllFiles "${multipleBuildsPath}${craUaAwareCodeSplitting}"
cd ..

cd $reactMovieNetworkAwareComponents
rm -rf node_modules build
npm install
npm run build
mkdir -p "${multipleBuildsPath}${reactMovieNetworkAwareComponents}"
cp -r $individualBuildAllFiles "${multipleBuildsPath}${reactMovieNetworkAwareComponents}"
cd ..

cd $reactShrineNetworkAwareCodeSplitting
rm -rf node_modules build
npm install
npm run build
mkdir -p "${multipleBuildsPath}${reactShrineNetworkAwareCodeSplitting}"
cp -r $individualBuildAllFiles "${multipleBuildsPath}${reactShrineNetworkAwareCodeSplitting}"
cd ..
58 changes: 58 additions & 0 deletions clean.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
#!/bin/bash
multipleBuildsPath="../functions/builds/"
individualBuildAllFiles="build/*"

craBatteryConsiderateLoading="cra-battery-considerate-loading"
craDeviceClassAwareLoading="cra-device-class-aware-loading"
craMemoryConsiderateLoading="cra-memory-considerate-loading"
craMemoryConsiderateLoadingSketchfab="cra-memory-considerate-loading-sketchfab"
craNetworkAwareCodeSplitting="cra-network-aware-code-splitting"
craNetworkAwareComponent="cra-network-aware-component"
craNetworkAwareDataFetching="cra-network-aware-data-fetching"
craUaAwareCodeSplitting="cra-ua-aware-code-splitting"
reactMovieNetworkAwareComponents="react-movie-network-aware-components"
reactShrineNetworkAwareCodeSplitting="react-shrine-network-aware-code-splitting"

cd functions
rm -rf node_modules builds
cd ..

cd $craBatteryConsiderateLoading
rm -rf node_modules build
cd ..

cd $craDeviceClassAwareLoading
rm -rf node_modules build
cd ..

cd $craMemoryConsiderateLoading
rm -rf node_modules build
cd ..

cd $craMemoryConsiderateLoadingSketchfab
rm -rf node_modules build
cd ..

cd $craNetworkAwareCodeSplitting
rm -rf node_modules build
cd ..

cd $craNetworkAwareComponent
rm -rf node_modules build
cd ..

cd $craNetworkAwareDataFetching
rm -rf node_modules build
cd ..

cd $craUaAwareCodeSplitting
rm -rf node_modules build
cd ..

cd $reactMovieNetworkAwareComponents
rm -rf node_modules build
cd ..

cd $reactShrineNetworkAwareCodeSplitting
rm -rf node_modules build
cd ..
3 changes: 2 additions & 1 deletion cra-battery-considerate-loading/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"name": "battery-considerate-loading",
"name": "cra-battery-considerate-loading",
"version": "0.1.0",
"homepage": ".",
"private": true,
"dependencies": {
"react": "^16.8.6",
Expand Down
3 changes: 2 additions & 1 deletion cra-device-class-aware-loading/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"name": "device-atlas-based-device-class",
"name": "cra-device-class-aware-loading",
"version": "0.1.0",
"homepage": ".",
"private": true,
"proxy": "http://localhost:5000",
"dependencies": {
Expand Down
3 changes: 2 additions & 1 deletion cra-memory-considerate-loading-sketchfab/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"name": "memory-based-loading",
"name": "cra-memory-considerate-loading-sketchfab",
"version": "0.1.0",
"homepage": ".",
"private": true,
"dependencies": {
"@google/model-viewer": "^0.5.0",
Expand Down
3 changes: 2 additions & 1 deletion cra-memory-considerate-loading/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"name": "memory-based-loading",
"name": "cra-memory-considerate-loading",
Copy link
Collaborator

Choose a reason for hiding this comment

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

These changes all LGTM. Thanks for aligning the naming around a common scheme.

Copy link
Contributor Author

@anton-karlovskiy anton-karlovskiy Jul 30, 2019

Choose a reason for hiding this comment

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

Yes, thanks for your notice.
I like consistency very much. :)
I think I have to be flexible in working for saving time but fixing all minor issues by progressively improving the codebase whenever I notice them.

"version": "0.1.0",
"homepage": ".",
"private": true,
"dependencies": {
"@google/model-viewer": "^0.5.0",
Expand Down
3 changes: 2 additions & 1 deletion cra-network-aware-code-splitting/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"name": "my-other-app",
"name": "cra-network-aware-code-splitting",
"version": "0.1.0",
"homepage": ".",
"private": true,
"dependencies": {
"react": "^16.8.6",
Expand Down
3 changes: 2 additions & 1 deletion cra-network-aware-component/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"name": "my-app",
"name": "cra-network-aware-component",
"version": "0.1.0",
"homepage": ".",
"private": true,
"dependencies": {
"react": "^16.8.6",
Expand Down
1 change: 1 addition & 0 deletions cra-network-aware-data-fetching/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"name": "cra-network-aware-data-fetching",
"version": "0.1.0",
"homepage": ".",
"private": true,
"dependencies": {
"react": "^16.8.6",
Expand Down
3 changes: 2 additions & 1 deletion cra-ua-aware-code-splitting/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"name": "my-other-app",
"name": "cra-ua-aware-code-splitting",
"version": "0.1.0",
"homepage": ".",
"private": true,
"dependencies": {
"react": "^16.8.6",
Expand Down
66 changes: 66 additions & 0 deletions firebase-debug.log
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
[debug] [2019-07-29T20:50:45.874Z] ----------------------------------------------------------------------
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can we add firebase-debug.log to our gitignore?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes I'll do that.

[debug] [2019-07-29T20:50:45.876Z] Command: C:\Program Files\nodejs\node.exe C:\Users\JIN\AppData\Roaming\npm\node_modules\firebase-tools\lib\bin\firebase.js deploy
[debug] [2019-07-29T20:50:45.876Z] CLI Version: 7.2.1
[debug] [2019-07-29T20:50:45.877Z] Platform: win32
[debug] [2019-07-29T20:50:45.877Z] Node Version: v10.15.3
[debug] [2019-07-29T20:50:45.877Z] Time: Mon Jul 29 2019 23:50:45 GMT+0300 (Moscow Standard Time)
[debug] [2019-07-29T20:50:45.877Z] ----------------------------------------------------------------------
[debug]
[debug] [2019-07-29T20:50:45.883Z] > command requires scopes: ["email","openid","https://www.googleapis.com/auth/cloudplatformprojects.readonly","https://www.googleapis.com/auth/firebase","https://www.googleapis.com/auth/cloud-platform"]
[debug] [2019-07-29T20:50:45.883Z] > authorizing via signed-in user
[debug] [2019-07-29T20:50:45.883Z] [iam] checking project env-aware for permissions ["cloudfunctions.functions.create","cloudfunctions.functions.delete","cloudfunctions.functions.get","cloudfunctions.functions.list","cloudfunctions.functions.update","cloudfunctions.operations.get","firebase.projects.get"]
[debug] [2019-07-29T20:50:45.884Z] >>> HTTP REQUEST POST https://cloudresourcemanager.googleapis.com/v1/projects/env-aware:testIamPermissions

[debug] [2019-07-29T20:50:47.084Z] <<< HTTP RESPONSE 200
[info]
[info] === Deploying to 'env-aware'...
[info]
[info] i deploying functions
[debug] [2019-07-29T20:50:51.023Z] > [functions] package.json contents: {
"name": "functions",
"description": "Cloud Functions for Firebase",
"scripts": {
"serve": "firebase serve --only functions",
"shell": "firebase functions:shell",
"start": "npm run shell",
"deploy": "firebase deploy --only functions",
"logs": "firebase functions:log"
},
"engines": {
"node": "8"
},
"dependencies": {
"firebase-admin": "^8.0.0",
"firebase-functions": "^3.1.0",
"cors": "^2.8.5",
"deviceatlas-deviceapi": "file:lib/device-atlas/deviceatlas-enterprise-nodejs-2.1.3/Api/deviceatlas-deviceapi-2.1.3.tgz",
"express": "^4.17.1",
"mkdirp": "^0.5.1",
"string-similarity": "^3.0.0"
},
"devDependencies": {
"firebase-functions-test": "^0.1.6"
},
"private": true
}
[info] i functions: ensuring necessary APIs are enabled...
[debug] [2019-07-29T20:50:51.023Z] >>> HTTP REQUEST GET https://serviceusage.googleapis.com/v1/projects/env-aware/services/cloudfunctions.googleapis.com

[debug] [2019-07-29T20:50:51.024Z] >>> HTTP REQUEST GET https://serviceusage.googleapis.com/v1/projects/env-aware/services/runtimeconfig.googleapis.com

[debug] [2019-07-29T20:50:52.565Z] <<< HTTP RESPONSE 200
[debug] [2019-07-29T20:50:52.586Z] <<< HTTP RESPONSE 200
[info] + functions: all necessary APIs are enabled
[debug] [2019-07-29T20:50:52.587Z] >>> HTTP REQUEST GET https://firebase.googleapis.com/v1beta1/projects/env-aware/adminSdkConfig

[debug] [2019-07-29T20:50:53.403Z] <<< HTTP RESPONSE 200
[info] i functions: preparing functions directory for uploading...
[debug] [2019-07-29T20:50:53.405Z] >>> HTTP REQUEST GET https://runtimeconfig.googleapis.com/v1beta1/projects/env-aware/configs

[debug] [2019-07-29T20:50:53.961Z] <<< HTTP RESPONSE 200
[info] i functions: packaged functions (11.23 MB) for uploading
[debug] [2019-07-29T20:50:56.306Z] >>> HTTP REQUEST POST https://cloudfunctions.googleapis.com/v1/projects/env-aware/locations/us-central1/functions:generateUploadUrl

[debug] [2019-07-29T20:51:30.013Z] <<< HTTP RESPONSE 200
[debug] [2019-07-29T20:51:30.013Z] >>> HTTP REQUEST PUT https://storage.googleapis.com/gcf-upload-us-central1-9687512f-d70b-43eb-94e5-0f81623f4e03/a5529413-47b9-4f07-9851-326a8154adfb.zip?GoogleAccessId=service-1029663082851@gcf-admin-robot.iam.gserviceaccount.com&Expires=1564435290&Signature=fBsqdp8kXti0gNDWzKgEfhc%2BKqn4sIGOU7bG2CIVzDrvhuYpjAUU4uXzxneayiulqEhbve%2BRaZPZrD4Zv3v8r5kFGRE%2FZ34vCR9aBBxS49Zj2PMaCRc8AeFl5B6WXTOaVVepq0MELicaDNCl937ppZTY2XPRkn9TnBvIAyk2pGkcT8tLfu1CprOowwWcXco22r%2FSP0RqVB51AJqF7bk%2BbJc63xj4XKTl59Iwz1IT9k8GBZNbIfeMGD4IktPlXoTzvN0mkpEUzxnaR3PbaRucAqr%2F1FFDqhwOqQpKrXvYaWlTDNr7bLBx1J1Vbh5WQWTL9DfMjut1%2BVrpY2gNY%2Fa2CQ%3D%3D
<request body omitted>
1 change: 1 addition & 0 deletions firebase.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
4 changes: 4 additions & 0 deletions functions/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
builds/
node_modules/
firebase-debug.log
.firebase/
9 changes: 9 additions & 0 deletions functions/firebase.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"hosting": {
"public": "builds",
"rewrites": [ {
"source": "**",
"function": "app"
} ]
}
}
Loading