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

Development Tooling #377

Merged
merged 104 commits into from
Apr 30, 2019
Merged

Development Tooling #377

merged 104 commits into from
Apr 30, 2019

Conversation

htdvisser
Copy link
Contributor

@htdvisser htdvisser commented Mar 28, 2019

Summary:

This PR migrates our development tooling to Mage.

Closes #3
Closes #11
Closes #66
Closes #34

Changes:

  • Rewrote Git hooks to Mage
  • Rewrote headers check to Mage (and removed problematic fix/delete)
  • Rewrote Go tooling to Mage
  • Rewrote JS tooling to Mage
  • Rewrote most of the proto tooling to Mage
  • Updated Babel and some related fixes

Notes for Reviewers:

There are a lot of fixup commits in here (although they aren't indicated with !fixup), but unfortunately rebasing all of this isn't feasible.

The fix-grpc-gateway-names.sh script is still TODO. @rvolosatovs promised to solve that in a future PR

Release Notes

  • Updated the development tooling. If you are a developer, make sure to check the changes in CONTRIBUTING.md and DEVELOPMENT.md.

@htdvisser htdvisser added the in progress We're working on it label Mar 28, 2019
@htdvisser htdvisser added this to the Next Up milestone Mar 28, 2019
@htdvisser htdvisser self-assigned this Mar 28, 2019
@htdvisser htdvisser requested a review from johanstokking March 28, 2019 09:56
johanstokking
johanstokking previously approved these changes Mar 28, 2019
@htdvisser htdvisser force-pushed the feature/11-mage-dev-tooling branch from c0f6bb9 to bda911c Compare April 1, 2019 09:04
@htdvisser htdvisser force-pushed the feature/11-mage-dev-tooling branch 8 times, most recently from 160e1ec to bae1616 Compare April 3, 2019 15:30
@htdvisser htdvisser requested a review from a team as a code owner April 3, 2019 15:50
@johanstokking johanstokking dismissed their stale review April 3, 2019 17:22

Too many changes since last review

@johanstokking johanstokking removed the request for review from a team April 3, 2019 17:49
@kschiffer kschiffer force-pushed the feature/11-mage-dev-tooling branch from 12ef488 to 29c7467 Compare April 4, 2019 12:19
@kschiffer
Copy link
Contributor

This now also closes #34.

Copy link
Contributor

@bafonins bafonins left a comment

Choose a reason for hiding this comment

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

@kschiffer please review the list of babel plugins you added, lets try to add less stage 0 proposals. Also, what about the .babelrc file?

$ make js.clean
make: *** No rule to make target `js.clean'.  Stop.

package.json Outdated
}
],
"@babel/plugin-proposal-nullish-coalescing-operator",
"@babel/plugin-proposal-do-expressions",
Copy link
Contributor

Choose a reason for hiding this comment

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

do we need this?

package.json Outdated
],
"@babel/plugin-proposal-nullish-coalescing-operator",
"@babel/plugin-proposal-do-expressions",
"@babel/plugin-proposal-function-bind"
Copy link
Contributor

Choose a reason for hiding this comment

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

do we really want to import stage 0 features?

Copy link
Contributor

Choose a reason for hiding this comment

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

We had them enabled before, that's why they're added now individually. I can also remove some, as it's true that we actually don't use most of them.


return {
ids: {
device_id: faker.lorem.slug(),
application_ids: {
application_id: app.ids.application_id,
application_id: '',
Copy link
Contributor

Choose a reason for hiding this comment

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

how is this related to this PR?

Copy link
Contributor

Choose a reason for hiding this comment

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

After the babel 7 upgrade, this line resulted in an error. Didn't want to bother a lot about it, as it is dead code anyway.

return eslint("./pkg/webui/**/*.snap", "--no-ignore", "--color")
}

func (js Js) LintAll() {
Copy link
Contributor

Choose a reason for hiding this comment

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

missing comment

@kschiffer kschiffer force-pushed the feature/11-mage-dev-tooling branch 2 times, most recently from 4a7b47f to f6c0e73 Compare April 5, 2019 08:31
@kschiffer
Copy link
Contributor

This now also closes #66.

@kschiffer kschiffer requested a review from bafonins April 5, 2019 11:22
@htdvisser htdvisser force-pushed the feature/11-mage-dev-tooling branch from f6c0e73 to 3204db7 Compare April 5, 2019 13:57
@kschiffer kschiffer force-pushed the feature/11-mage-dev-tooling branch from 046524a to 1d6c019 Compare April 28, 2019 16:05
.mage/proto.go Outdated

// All generates protos.
func (p Proto) All(ctx context.Context) {
mg.CtxDeps(ctx, Proto.Image)
Copy link
Contributor

Choose a reason for hiding this comment

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

Remove this.

  1. It's redundant, since docker run will automatically pull the image if not available.
  2. It breaks proto:all in offline scenarios in cases where the image is already available and in cases where image is available locally, but not in the repository.
  3. This target generates protos. Updating the image is an unexpected side-effect.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

When I ran this proto:all without pulling the image first, it started pulling the image concurrently for all the jobs below. We don't want that. Feel free to suggest an alternative.

Copy link
Member

Choose a reason for hiding this comment

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

I favor offline support over concurrent pulling images. If we can have (explicit) offline support, I'm fine with that too, but we need offline support.

Copy link
Contributor

Choose a reason for hiding this comment

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

Fixed that in 82c670f

CONTRIBUTING.md Outdated
@@ -245,7 +245,7 @@ In the API, the enum descriptions, error messages and event descriptions availab
These messages are then collected in the `config/messages.json` file, which will be processed in the frontend build process, but may also be used by other (native) user interfaces. When you define new enums, errors or events or when you change them, the messages need to be updated into the `config/messages.json` file.

```sh
make messages
make go.messages
Copy link
Contributor

Choose a reason for hiding this comment

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

Why not go:messages?

DEVELOPMENT.md Outdated
@@ -142,7 +143,7 @@ From the `.proto` files, we generate code using the `protoc` compiler. As we pla
The actual commands for compilation are handled by our Makefile, so the only thing you have to execute, is:

```sh
make protos.clean protos
make proto.clean proto.all
Copy link
Contributor

Choose a reason for hiding this comment

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

Why not proto:clean and proto:all ?

Makefile Outdated
$(err) "Previous operations have created changes that were not recorded in the repository. Please make those changes on your local machine before pushing them to the repository:"; \
git diff; \
exit 1; \
fi
Copy link
Contributor

Choose a reason for hiding this comment

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

Why did you remove the passthrough target to mage?

.mage/rules.make Outdated
@@ -0,0 +1,257 @@
# Copyright © 2019 The Things Network Foundation, The Things Industries B.V.
Copy link
Contributor

Choose a reason for hiding this comment

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

I thought we're migrating to Mage in this PR? Why do we need these?

Makefile Outdated
@echo " run \"make build-all\""

.PHONY: build-all
build-all:
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is this still here?

@@ -12,30 +12,49 @@
# See the License for the specific language governing permissions and
# limitations under the License.

Copy link
Contributor

Choose a reason for hiding this comment

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

Why do we still have targets here? Aren't we migrating to mage?

@bafonins bafonins self-requested a review April 29, 2019 08:43
@bafonins
Copy link
Contributor

bafonins commented Apr 29, 2019

in fresh repo

export NODE_ENV=production
make init deps
mage js:build

gives:

Error: Couldn't find preset "ttn" relative to directory "$GOPATH/src/go.thethings.network/lorawan-stack/sdk/js"
    at /usr/local/lib/node_modules/babel-cli/node_modules/babel-core/lib/transformation/file/options/option-manager.js:293:19
    at Array.map (<anonymous>)
    at OptionManager.resolvePresets (/usr/local/lib/node_modules/babel-cli/node_modules/babel-core/lib/transformation/file/options/option-manager.js:275:20)
    at OptionManager.mergePresets (/usr/local/lib/node_modules/babel-cli/node_modules/babel-core/lib/transformation/file/options/option-manager.js:264:10)
    at OptionManager.mergeOptions (/usr/local/lib/node_modules/babel-cli/node_modules/babel-core/lib/transformation/file/options/option-manager.js:249:14)
    at OptionManager.init (/usr/local/lib/node_modules/babel-cli/node_modules/babel-core/lib/transformation/file/options/option-manager.js:368:12)
    at File.initOptions (/usr/local/lib/node_modules/babel-cli/node_modules/babel-core/lib/transformation/file/index.js:212:65)
    at new File (/usr/local/lib/node_modules/babel-cli/node_modules/babel-core/lib/transformation/file/index.js:135:24)
    at Pipeline.transform (/usr/local/lib/node_modules/babel-cli/node_modules/babel-core/lib/transformation/pipeline.js:46:16)
    at transform (/usr/local/lib/node_modules/babel-cli/lib/babel/util.js:50:22)
error Command failed with exit code 1.                                                           
Error: running "node_modules/.bin/yarn --cwd=sdk/js run build" failed with exit code 1

@@ -202,7 +202,7 @@ const readMessages = async function () {
}

/**
* Read and parse (and marshal) the backend messages, coming from `make go.messages`
* Read and parse (and marshal) the backend messages, coming from `./mage go.messages`
Copy link
Member

Choose a reason for hiding this comment

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

colon

Copy link
Contributor Author

Choose a reason for hiding this comment

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

😭

@htdvisser htdvisser force-pushed the feature/11-mage-dev-tooling branch from 0585342 to 61eac7d Compare April 30, 2019 10:48
@htdvisser htdvisser requested a review from rvolosatovs April 30, 2019 10:56
@htdvisser
Copy link
Contributor Author

@rvolosatovs we got rid of the proxy, now we run make init to set up Mage, after which we run ./mage <rules...>.

@htdvisser
Copy link
Contributor Author

Notes to all:

  • .make/dev.make will be rewritten to Mage in a later PR
  • .mage/scripts/fix-grpc-gateway-names.sh will be rewritten to Mage in a later PR

@htdvisser htdvisser merged commit 9a7f7ca into master Apr 30, 2019
@htdvisser htdvisser deleted the feature/11-mage-dev-tooling branch April 30, 2019 11:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in progress We're working on it
Projects
None yet
5 participants