-
Notifications
You must be signed in to change notification settings - Fork 40
Auto generate Kedge JSON Schema for every merge #548
Conversation
scripts/update-json-schema.sh
Outdated
|
||
# email assigned | ||
git config user.email "$GIT_EMAIL" | ||
git add --all |
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 don't think it is safe to have --all
here. It should be explicit and add just files with json schema
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.
Agreed.
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.
@kadel @pradeepto this is happening inside the kedge-json-schema/master directory, and everything generated there is an output of json-schema-generator. The output files vary so it's difficult to keep track of which exact files, but since this is happening inside the repo, I think it's safe to commit and push all of the generated files.
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.
all generated files are in schema
directory, is that right? If not then we should have all generated files in some directory and not spread them across the repo. Than we can add just that directory
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.
@kadel ack, changed this to only add the master/
directory in JSON Schema repo where the output will be spit to.
scripts/update-json-schema.sh
Outdated
git clone "$GENERATOR_REPO" "$KEDGE_REPO_NAME" | ||
mkdir -p "$KEDGE_REPO_NAME"/"$OUTPUT_DIR" | ||
cd "$KEDGE_REPO_NAME"/"$OUTPUT_DIR" | ||
docker run --rm -v `pwd`:/data:Z "$KEDGE_JSON_SCHEMA_IMAGE" |
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.
can we have a -u
flag so that the output is not root generated?
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.
git does not preserve file permissions, so this is not required
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 is just safer and nicer to have it under one user
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.
@kadel we will need to add a user to https://github.com/kedgeproject/json-schema-generator/blob/master/scripts/Dockerfile in that case and then switch to it here.
None of our other scripts are switching to a user -
- https://github.com/kedgeproject/kedge/search?l=Shell&q=docker+run&type=&utf8=%E2%9C%93
- https://github.com/kedgeproject/kedge/search?l=Makefile&q=docker+run&type=&utf8=%E2%9C%93
We need to fix that in general then.
Since git does not preserve file permissions, we can let this pass for this PR so we can move forward with this!?
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.
also please see this code either remove it or modify it
Lines 126 to 129 in 71f58ac
# Test if the changed types.go is valid and JSONSchema can be generated out of it | |
.PHONY: test-jsonschema-generation | |
test-jsonschema-generation: | |
docker run -v `pwd`/pkg/spec/types.go:/data/types.go:ro,Z surajd/kedgeschema |
scripts/update-json-schema.sh
Outdated
git add --all | ||
|
||
# Check if anything changed, and if it's the case, push to origin/master. | ||
if git commit -m 'Update JSON Schema' -m "Commit: https://github.com/kedgeproject/kedge/commit/$TRAVIS_COMMIT" ; 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.
add PR number to description for the reference
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.
fixed
c401685
to
4629c5c
Compare
This commit configures Travis to run a script on every merge to Kedge master branch which updates the JSON Schema residing in https://github.com/kedgeproject/json-schema Significantly improves kedgeproject#280
4629c5c
to
ef256a3
Compare
have you tested this on your own fork? |
@kadel ran this script locally and it worked fine. |
This commit configures Travis to run a script on every merge to
Kedge master branch which updates the JSON Schema residing in
https://github.com/kedgeproject/json-schema
Significantly improves #280