-
Notifications
You must be signed in to change notification settings - Fork 26
Implement exercise T4L2/tags-push #95
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
base: main
Are you sure you want to change the base?
Conversation
|
The tests are implemented entirely through mocking due to the unique nature of the exercise. |
|
Fixes #63 |
woojiahao
left a comment
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.
Left some comments, but overall, the exercise structure makes sense!
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.
Could you add the instructions for students to this README?
tags_push/download.py
Outdated
| TAG_2_MESSAGE = "First stable roster" | ||
|
|
||
| def setup(verbose: bool = False): | ||
| create_start_tag(verbose) |
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 we need this start tag!
tags_push/download.py
Outdated
| create_start_tag(verbose) | ||
| run_command(["git", "remote", "rename", "origin", REMOTE_NAME], verbose) | ||
| tag(TAG_DELETE_NAME, verbose) | ||
| push(REMOTE_NAME, "--tags", verbose) # somewhat hacky, maybe use run_command instead |
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.
Yeap this is a hack, please use run directly! I would avoid undocumented hacks to save future confusion
tags_push/download.py
Outdated
| REMOTE_NAME = "production" | ||
| TAG_1_NAME = "v1.0" | ||
| TAG_2_NAME = "v2.0" | ||
| TAG_DELETE_NAME = "beta" | ||
| TAG_2_MESSAGE = "First stable roster" |
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 would be wary of including so many constants that are only used once. It's easier if you inline these values directly
tags_push/download.py
Outdated
| from exercise_utils.git import tag, push | ||
| from exercise_utils.gitmastery import create_start_tag | ||
|
|
||
| __resources__ = {} |
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.
| __resources__ = {} |
Since we don't need any resources, remove this line!
| username = get_username() | ||
| if username is None: | ||
| raise exercise.wrong_answer([IMPROPER_GH_CLI_SETUP]) |
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.
In all fairness, this should not be necessary because the requires_github check already covers it, but I get the current constraint. Happy to keep this for now.
tags_push/tests/test_verify.py
Outdated
| pytest.raises(GitAutograderWrongAnswerException) as exception, | ||
| ): | ||
| verify(exercise) |
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 believe that you can use pytest.raises(Exception, match='') to match the body of the exception! So you shouldn't need to run a separate assert
| pytest.raises(GitAutograderWrongAnswerException) as exception, | ||
| ): | ||
| verify(exercise) |
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.
See previous comment
tags_push/tests/test_verify.py
Outdated
| pytest.raises(GitAutograderWrongAnswerException) as exception, | ||
| ): | ||
| verify(exercise) | ||
|
|
||
| assert exception.value.message == [IMPROPER_GH_CLI_SETUP] |
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.
See previous comment
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 would be good to include the case where all checks fail so we're verifying against multiple comments.
|
Thanks for the feedback. I should hopefully resolve these issues within the next 1-2 days. |
- Added instructions to README - Removed hacks and cleaned up download.py - Removed GH API call - Cleaned up test_verify.py - Added new test
|
@woojiahao Could you review my changes? |
woojiahao
left a comment
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.
Minor nit for formatting. The change I've suggested might affect the unit tests, so it will be good to verify that.
Could you re-run the ./test-download.sh tags-push script to ensure that all the tags have the right message?
tags_push/download.py
Outdated
| run_command(["git", "tag", TAG_1_NAME, "HEAD~4"], verbose) | ||
| run_command(["git", "tag", "-a", TAG_2_NAME, "HEAD~1", "-m", f"\"{TAG_2_MESSAGE}\""], verbose) | ||
| run_command(["git", "tag", "v1.0", "HEAD~4"], verbose) | ||
| run_command(["git", "tag", "-a", "v2.0", "HEAD~1", "-m", f"\"{"First stable roster"}\""], verbose) |
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.
| run_command(["git", "tag", "-a", "v2.0", "HEAD~1", "-m", f"\"{"First stable roster"}\""], verbose) | |
| run_command(["git", "tag", "-a", "v2.0", "HEAD~1", "-m", "First stable roster"], verbose) |
The quotes in the code from the exercise review were for the -m parameter, it's not necessary when passed this way!
|
I've fixed the formatting issue and done the necessary checks- the unit tests pass and the tags have the correct message. |
jovnc
left a comment
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.
LGTM, just some minor nits on coding standard and abstraction. The verify logic seems right to me.
| ): | ||
| output = verify(exercise) | ||
| assert_output(output, GitAutograderStatus.SUCCESSFUL) | ||
|
|
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.
If I'm not wrong, it seems like coding standard in this repository is 2 new lines between each method. This is based on my observation of other files within this codebase.
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.
You're right, let me fix that.
| TAG_2_MISSING = f"Tag {TAG_2_NAME} is missing, did you push it to the remote?" | ||
| TAG_DELETE_NOT_REMOVED = f"Tag {TAG_DELETE_NAME} is still on the remote!" | ||
|
|
||
| def run_command(command: List[str]) -> Optional[str]: |
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.
There is a run_command and run_command_with_no_exit util under exercise_util, do you think we can reuse those instead? Or is there something specific in this function that makes this function necessary?
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.
There seems to be a convention to not import anything from exercise_utils for the autograding (See fork_repo and clone_repo) and to define the functions in the verify namespace. Thus, I follow a similar convention.
| return None | ||
|
|
||
|
|
||
| def get_username() -> Optional[str]: |
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.
get_username and get_remote_tags seems to be reusable components that can be placed under exercise_utils, do you think we should move it there?
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.
See reply to run_command
Exercise Review
Exercise Discussion
#63
Checklist
Git-Masteryorganization, have you created a request for it?repo-smithto validate the exercise grading scheme?test-download.sh?git-autograder?app?