Skip to content
This repository has been archived by the owner on Nov 15, 2022. It is now read-only.

Auto generate Kedge JSON Schema for every merge #548

Merged
merged 1 commit into from
Jan 2, 2018

Conversation

concaf
Copy link
Collaborator

@concaf concaf commented Jan 2, 2018

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


# email assigned
git config user.email "$GIT_EMAIL"
git add --all
Copy link
Member

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

Copy link
Member

Choose a reason for hiding this comment

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

Agreed.

Copy link
Collaborator Author

@concaf concaf Jan 2, 2018

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.

Copy link
Member

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

Copy link
Collaborator Author

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.

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"
Copy link
Member

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?

Copy link
Collaborator Author

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

Copy link
Member

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

Copy link
Collaborator Author

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 -

Copy link
Member

@surajssd surajssd left a 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

kedge/Makefile

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

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
Copy link
Collaborator

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

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

fixed

@concaf concaf force-pushed the update-json-schema-script branch from c401685 to 4629c5c Compare January 2, 2018 08:58
@concaf
Copy link
Collaborator Author

concaf commented Jan 2, 2018

@surajssd the older make target is removed in #550

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
@concaf concaf force-pushed the update-json-schema-script branch from 4629c5c to ef256a3 Compare January 2, 2018 09:15
@kadel
Copy link
Member

kadel commented Jan 2, 2018

have you tested this on your own fork?

@concaf
Copy link
Collaborator Author

concaf commented Jan 2, 2018

@kadel ran this script locally and it worked fine.

@concaf concaf merged commit f2df098 into kedgeproject:master Jan 2, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants