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

Add Magefile for easy testing #37

Merged
merged 7 commits into from
Mar 8, 2021
Merged

Add Magefile for easy testing #37

merged 7 commits into from
Mar 8, 2021

Conversation

cosmic-chichu
Copy link
Contributor

Resolves #35

fmt run gofmt linter
lint run golint linter https://github.com/golang/lint
testCoverHTML generates test coverage report
testRace run tests with race detector
Copy link
Collaborator

@vigith vigith Feb 25, 2021

Choose a reason for hiding this comment

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

let's name testRace as test

Copy link
Contributor

Choose a reason for hiding this comment

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

original had both: https://github.com/gohugoio/hugo/blob/master/magefile.go#L188
If we keep all of this, why not keeping both ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

would we ever need to run without race?

Copy link
Collaborator

Choose a reason for hiding this comment

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

let's keep both but default target should call testRace

Shrivardhan Rao added 2 commits February 25, 2021 07:10
- Add vet to default target
- Add alias for test with race
Magefile.go Outdated
mg.Deps(Fmt, Vet)
// TODO: Enable once errors are fixed
mg.Deps(TestRace)
mg.Deps(Build)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why do we have Build in Check? it is counter intuitive 😄 . Rename Check to Build?

Copy link
Contributor

@jbguerraz jbguerraz left a comment

Choose a reason for hiding this comment

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

This magefile comes from Hugo (the CMS: https://github.com/gohugoio/hugo/blob/master/magefile.go) which is a great one but still is not totally aligned with our usecase. Here we're working on a library which is not buildable, nor installable.
I believe we have to refine what we expect from this tool.
I would probably expect it to make sure the library code is well formatted / linted, then to run the tests, and at the end, maybe run some example.
I would also be happy if it would start a dev env (running druid, and builder) mostly like does the magefile on its grafana counterpart: https://github.com/grafadruid/druid-grafana/blob/master/Magefile.go
That would also allow to run tests that does interacts with Druid.
WDYT?

Magefile.go Outdated
if err := sh.Run("go", "mod", "download"); err != nil {
return err
}
return sh.Run("go", "install", "./...")
Copy link
Contributor

Choose a reason for hiding this comment

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

wondering what it'll build, install and run in our case ? examples ? what one(s) ?
this is a library, only what use it can be installed. We could eventually want to build "examples" but then we would have to make those examples a bit more "unified"

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@jbguerraz I agree, I'm working on issue #36 where I will introduce a Dockerfile and run the examples as a part of integration tests. I can exclude install from this PR. This PR is only aimed at resolving #35.

Copy link
Collaborator

Choose a reason for hiding this comment

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

let's keep it simple as @jbguerraz suggested and keep the scope of the PR w.r.t what we have now. i.e perhaps just call test and vet, i believe i saw some errors when i ran lint which we can tackle in a different PR.

Copy link
Collaborator

@vigith vigith left a comment

Choose a reason for hiding this comment

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

Let's keep both testRace and test as @jbguerraz mentioned but default should call testRace https://github.com/gohugoio/hugo/blob/master/magefile.go#L163

@vigith vigith requested a review from jbguerraz March 7, 2021 02:08
@jbguerraz
Copy link
Contributor

Let's move ahead with it :) thank you @cosmic-chichu !

@jbguerraz jbguerraz merged commit e1ad4f9 into grafadruid:master Mar 8, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow tests be to run locally - Mage
3 participants