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 vendor-check script, Makefile target and CI step #581

Merged
merged 8 commits into from
Feb 1, 2018
Merged

Add vendor-check script, Makefile target and CI step #581

merged 8 commits into from
Feb 1, 2018

Conversation

azer
Copy link
Contributor

@azer azer commented Jan 30, 2018

It adds vendor-check target, copying the validation script in dep repository.

Closes #556

CC @mandrigin

Copy link
Contributor

@mandrigin mandrigin left a comment

Choose a reason for hiding this comment

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

Looks good! A few changes are necessary.

Also, it would be nice to validate that the script actually returns a non-zero answer if contents of vendor are changed. Now it shows warning: no common commits because it checks against the wrong repo.

echo
} >&2
false
else
Copy link
Contributor

Choose a reason for hiding this comment

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

Seems like indentation went funky in this file, let's fix that.

set -e -o pipefail

if [ -z "$VALIDATE_UPSTREAM" ]; then
VALIDATE_REPO='https://github.com/golang/dep.git'
Copy link
Contributor

Choose a reason for hiding this comment

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

It should be the status-go repo, right?


if [ -z "$VALIDATE_UPSTREAM" ]; then
VALIDATE_REPO='https://github.com/golang/dep.git'
VALIDATE_BRANCH='master'
Copy link
Contributor

Choose a reason for hiding this comment

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

We use develop as a target branch.

@mandrigin
Copy link
Contributor

@azer looks good now!
One last point. It fails on Travis now due to dep not being installed. Let's add dep-install as a Makefile target and add it to the install: phase of .travis.yml.

@azer
Copy link
Contributor Author

azer commented Jan 31, 2018

@mandrigin Thanks for the feedback, I've made the fixes requested, also tested it on a branch with additions into vendor/ folder. Here is what the failure exit looks like;

The contents of vendor differ after "dep ensure":

 D vendor/github.com/azer/logger/README.md
 D vendor/github.com/azer/logger/examples/attrs.go
 D vendor/github.com/azer/logger/examples/multiple.go
 D vendor/github.com/azer/logger/examples/programmatical.go
 D vendor/github.com/azer/logger/examples/simple.go
 D vendor/github.com/azer/logger/examples/timer-performance.go
 D vendor/github.com/azer/logger/format.go
 D vendor/github.com/azer/logger/log.go
 D vendor/github.com/azer/logger/logger.go
 D vendor/github.com/azer/logger/runtime.go
 D vendor/github.com/azer/logger/standard-output.go

Make sure these commands have been run before committing.

@mandrigin
Copy link
Contributor

@azer Looks good! I'll ask one peer of mine to review it too.

Copy link
Contributor

@themue themue left a comment

Choose a reason for hiding this comment

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

Only one question, rest LGTM.

# for our repo and makes sure that it was done in a valid way.
#
# This file is a slightly modified copy of https://github.com/golang/dep/blob/master/hack/validate-vendor.bash
# The only change made was checking if `dep` was available and installing it if necessary.
Copy link
Contributor

Choose a reason for hiding this comment

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

Isn't this check done with dep-install in Makefile?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yup, just deleted it


if [ -z "$VALIDATE_UPSTREAM" ]; then
VALIDATE_REPO='https://github.com/status-im/status-go'
VALIDATE_BRANCH='develop'
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't branch be taken from env and only default to develop? We merge almost every branch to develop but it should change soon.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

👍

fi

IFS=$'\n'
files=( $(validate_diff --diff-filter=ACMR --name-only -- 'Gopkg.toml' 'Gopkg.lock' 'vendor/' || true) )
Copy link
Contributor

Choose a reason for hiding this comment

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

If the if statement above won't be executed, validate_diff won't be defined, right?

Copy link
Contributor Author

@azer azer Feb 1, 2018

Choose a reason for hiding this comment

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

Yes, if statement will always be executed unless we define VALIDATE_UPSTREAM before calling this script.


set -e -o pipefail

if [ -z "$VALIDATE_UPSTREAM" ]; then
Copy link
Contributor

Choose a reason for hiding this comment

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

I hate bash for their super hard to remember expression. Can you please add a comment // if $VALIDATE_UPSTREAM is null or empty string do bla bla bla...?

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've added some more comments

Copy link
Contributor

Choose a reason for hiding this comment

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

Hmm, do we even need this option?

files=( $(validate_diff --diff-filter=ACMR --name-only -- 'Gopkg.toml' 'Gopkg.lock' 'vendor/' || true) )
unset IFS

if [ ${#files[@]} -gt 0 ]; then
Copy link
Contributor

Choose a reason for hiding this comment

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

I have no idea what ${#files[@]} does (getting a number of files?). Can you please add a comment?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Splits the content of files variable by whitespaces and gets the number of the lines. Just added a comment for it.

echo
} >&2
false
else
Copy link
Contributor

Choose a reason for hiding this comment

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

Formatting? Shouldn't this else be aligned with if [ "$diffs" ]; then?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed 👍

@adambabik
Copy link
Contributor

I know it's copied from dep repo but it would be great to add a general comment what this bash script actually does in 2-3 sentences.

@azer
Copy link
Contributor Author

azer commented Feb 1, 2018

@adambabik defaulted branch to "develop", added some comments & fixed tabbing 👍

Copy link
Contributor

@adambabik adambabik left a comment

Choose a reason for hiding this comment

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

Thanks @azer. LGTM

@mandrigin mandrigin merged commit 8b56060 into status-im:develop Feb 1, 2018
@mandrigin
Copy link
Contributor

@azer thanks for your contribution 🎉

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.

4 participants