From c35ac8b611416dde253209b79c28f61639e21af7 Mon Sep 17 00:00:00 2001 From: lemoncurry Date: Sat, 7 Sep 2019 13:22:13 +0200 Subject: [PATCH 1/4] [WIP] Create script to check for unimplemented exercises --- scripts/create_issues_new_exercise.sh | 89 +++++++++++++++++++++++++++ 1 file changed, 89 insertions(+) create mode 100755 scripts/create_issues_new_exercise.sh diff --git a/scripts/create_issues_new_exercise.sh b/scripts/create_issues_new_exercise.sh new file mode 100755 index 000000000..65da3b229 --- /dev/null +++ b/scripts/create_issues_new_exercise.sh @@ -0,0 +1,89 @@ +#!/bin/bash + +print_usage() { + echo ">>>>> Usage: scripts/create_issues_new_exercise.sh -t path/to/track -s path/to/problem/specifications" +} + +command -v jq >/dev/null 2>&1 || { + echo >&2 ">>>>> This script requires jq but it's not installed. Aborting." + exit 1 +} + +num_args=$# + +if [[ $num_args = 0 ]]; then + print_usage + exit 0 +fi + +path_to_track= +path_to_problem_specifications= + +while getopts ":t:s:" option; do + case "$option" in + "t") + path_to_track="$OPTARG" + ;; + "s") + path_to_problem_specifications="$OPTARG" + ;; + *) + echo ">>>>> Unrecognized option. Aborting." + print_usage + exit 1 + ;; + esac +done + +if [[ -z "$path_to_track" ]]; then + echo ">>>>> Path to track missing." + print_usage + exit 1 +fi + +if [[ -z "$path_to_problem_specifications" ]]; then + echo ">>>>> Path to problem specifications missing." + print_usage + exit 1 +fi + +config_file_path="$path_to_track/config.json" + +if ! [[ -f "$config_file_path" ]]; then + echo ">>>>> Config file not found at ${config_file_path}." + exit 1 +fi + +problem_spec_exercises= +exercise_name= +track_foregone_exercises=$(jq '.foregone[]' "$config_file_path" | tr -d "\"") +track_deprecated_exercises=$(jq '.exercises[] | select(has("deprecated")) | .slug' "$config_file_path" | tr -d "\"") + +for path_to_exercise in ${path_to_problem_specifications}/exercises/*; do + if [[ -d "$path_to_exercise" ]]; then + if [[ -f "$path_to_exercise"/.deprecated ]]; then + continue + fi + exercise_name=$(echo "$path_to_exercise" | sed "s/.*\///") + problem_spec_exercises="$problem_spec_exercises $exercise_name" + fi +done + +track_exercise_slugs=$(jq '.exercises[] | select(has("deprecated") | not) | .slug' "$config_file_path" | tr -d "\"" | sort) + +COUNT=0 +for exercise in $problem_spec_exercises; do + if echo "$track_exercise_slugs" | grep -q "$exercise" ; then + continue + elif echo "$track_deprecated_exercises" | grep -q "$exercise"; then + continue + elif echo "$track_foregone_exercises" | grep -q "$exercise"; then + continue + fi + echo "Exercise $exercise is not implemented in the Java track." + (( COUNT+=1 )) +done + +echo "Total: $COUNT exercises" + +exit 0 From 58fb8305697ca807bae4ba77dfb1dd1b9740d67d Mon Sep 17 00:00:00 2001 From: lemoncurry Date: Mon, 30 Sep 2019 14:21:51 +0200 Subject: [PATCH 2/4] implement new exercise add issue submission --- scripts/create_issues_new_exercise.sh | 74 +++++++++++++++++++++++++-- 1 file changed, 69 insertions(+), 5 deletions(-) diff --git a/scripts/create_issues_new_exercise.sh b/scripts/create_issues_new_exercise.sh index 65da3b229..326cd41c2 100755 --- a/scripts/create_issues_new_exercise.sh +++ b/scripts/create_issues_new_exercise.sh @@ -56,6 +56,7 @@ fi problem_spec_exercises= exercise_name= +track_exercise_slugs=$(jq '.exercises[] | select(has("deprecated") | not) | .slug' "$config_file_path" | tr -d "\"" | sort) track_foregone_exercises=$(jq '.foregone[]' "$config_file_path" | tr -d "\"") track_deprecated_exercises=$(jq '.exercises[] | select(has("deprecated")) | .slug' "$config_file_path" | tr -d "\"") @@ -69,9 +70,39 @@ for path_to_exercise in ${path_to_problem_specifications}/exercises/*; do fi done -track_exercise_slugs=$(jq '.exercises[] | select(has("deprecated") | not) | .slug' "$config_file_path" | tr -d "\"" | sort) +# Create a file named ".exercism-version-update-issue-script-settings.sh" +# with the following variables and put in in your home directory +# +# TOKEN="your_token" +# OWNER="your_username" +# REPO="repo_name" + +if ! [[ -f "$HOME/.exercism-version-update-issue-script-settings.sh" ]]; then + echo "Create a file named \".exercism-version-update-issue-script-settings.sh\"" + echo "with the following variables and put in in your home directory" + echo "TOKEN=\"your_token\"" + echo "OWNER=\"repo_owner\"" + echo "REPO=\"repo_name\"" +fi + +. "$HOME/.exercism-version-update-issue-script-settings.sh" -COUNT=0 +if [[ -z "$TOKEN" ]]; then + echo "Please insert your personal token into \".exercism-version-update-issue-script-settings.sh\"." + exit 1 +elif [[ -z "$OWNER" ]]; then + echo "Please insert the repo owner into \".exercism-version-update-issue-script-settings.sh\"." + exit 1 +elif [[ -z "$REPO" ]]; then + echo "Please insert the name of the repo into \".exercism-version-update-issue-script-settings.sh\"." + exit 1 +fi + + +# Fetch issues opened by us to avoid duplicate issues +open_issues=$(curl --silent -HAuthorization:token\ ${TOKEN} https://api.github.com/repos/${OWNER}/${REPO}/issues\?state=open\&labels=implement+exercise | jq -r '.[] |(.title | split(":")[0]) + " Issue Title: " + .title + " (" + (.comments|tostring) +" comments)" + ", URL: " + .html_url') + +count=0 for exercise in $problem_spec_exercises; do if echo "$track_exercise_slugs" | grep -q "$exercise" ; then continue @@ -80,10 +111,43 @@ for exercise in $problem_spec_exercises; do elif echo "$track_foregone_exercises" | grep -q "$exercise"; then continue fi - echo "Exercise $exercise is not implemented in the Java track." - (( COUNT+=1 )) + (( count+=1 )) + if echo "$open_issues" | grep --quiet "^$exercise "; then + echo ">>>>> $exercise: implement exercise" + echo "The following issue(s) are currently open for exercise $exercise in ${REPO} with label :" + echo "$open_issues" | grep "^$exercise " | cut -d' ' -f2- + echo "Please check manually if a new issue may be opened." + read -p "Press enter to continue." + echo + continue + else + printf ">>>>> Exercise $exercise is not yet implemented in the Java track.\n" + title="$exercise: implement exercise" + body="The exercise **$exercise** has not been implemented yet for the Java track. \nThe description of the exercise can be found in the [problem specification repository](https://github.com/exercism/problem-specifications/tree/master/exercises/$exercise). \n\nHow to implement a new exercise for the Java track is described in detail in [CONTRIBUTING.md](https://github.com/exercism/java/blob/master/CONTRIBUTING.md#adding-a-new-exercise). Please have a look there first before starting working on the exercise. \nAlso please make sure it is clear that you are currently working on this issue, either by asking to be assigned to it, or by opening an empty PR. \n\nWhen opening an PR, please reference this issue using any of the [closing keywords](https://help.github.com/en/articles/closing-issues-using-keywords). \n\nIf you had a look at the exercise description and you concluded that the exercise might not be possible to implement in the Java language, please leave a comment and describe the problem. \n\nIn case you have any further questions, feel free to ask here. \n" + labels='"help wanted", "implement exercise", "enhancement"' + + response="" + while [[ $response != "y" && $response != "n" ]]; do + read -r -p "Do you want to publish this new issue for exercise $exercise with title: $title? [y/n] " response + done + echo + if [[ $response == "y" ]]; then + printf ">>>>> Generating new issue for exercise $exercise with title: ${title}\n" + + curl --fail --silent -H 'Content-Type: application/json' -H 'Authorization: token '"$TOKEN"'' -X POST -d '{"title": "'"$title"'", "body": "'"$body"'", "labels": ['"$labels"']}' https://api.github.com/repos/${OWNER}/${REPO}/issues | jq -r '"New issue created at: " + .html_url' + read -p "Press enter to continue." + echo + + if [[ "$?" != "0" ]]; then + echo ">>>>> Issue submission failed. Exit 1" + exit 1 + fi + fi + fi + done -echo "Total: $COUNT exercises" +echo "Total: $count exercises unimplemented." +echo "All exercises checked." exit 0 From 3b53ed973bee49b90d58cd2494bd051880b4e075 Mon Sep 17 00:00:00 2001 From: lemoncurry Date: Mon, 30 Sep 2019 14:22:22 +0200 Subject: [PATCH 3/4] add description for script in CONTRIBUTING.md --- CONTRIBUTING.md | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index b0138dfa6..219b6358c 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -222,3 +222,29 @@ To run this script: 4. Run `./scripts/create_issues_versionchange_canonical.sh -t . -s --spec-path path_to_problem_specifications` from the root of this repository and follow the directions. 5. If you submitted new issues, please check these submissions on the [issues page](https://github.com/exercism/java/issues). + +## Checking exercises are implemented and submit new issues + +There is [a script which allows you to submit new issues](https://github.com/exercism/java/blob/master/scripts/create_issues_new_exercise.sh) to this repo with generic title, description and labels if am unimplemented exercise is detected. + +Before you may submit a new issue, the script + 1. Checks whether the exercise exists in the Java track (compared to exercism/problem-specifications) + 2. Checks whether an open issue exists for this exercise concerning the implementation of the exercise; + 3. If a new issue may be opened for an exercise, the script will ask you if you want to submit the issue. Entering `y` will create the new issue. + +To run this script: + + 1. Clone [the problem-specifications repository](https://github.com/exercism/problem-specifications). + + 2. Create a file `.exercism-version-update-issue-script-settings.sh` in your home directory. + + 3. In this file, you have to put the following variables: + - `TOKEN="your_token"` + - `OWNER="repo_owner"` # -> `"exercism"` + - `REPO="repo_name"` # -> `"java"` + + For authentication, you need to create a personal token, see [this GitHub page](https://help.github.com/en/articles/creating-a-personal-access-token-for-the-command-line) for more information. + + 4. Run `./scripts/create_issues_new_exercise.sh -t . -s --spec-path path_to_problem_specifications` from the root of this repository and follow the directions. + + 5. If you submitted new issues, please check these submissions on the [issues page](https://github.com/exercism/java/issues). From 939b1df8d33796372ee75595393d953c599f5748 Mon Sep 17 00:00:00 2001 From: lemoncurry Date: Mon, 30 Sep 2019 17:53:30 +0200 Subject: [PATCH 4/4] improve wording --- CONTRIBUTING.md | 16 ++++++++-------- scripts/create_issues_new_exercise.sh | 2 +- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 219b6358c..7d732a43c 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -198,7 +198,7 @@ To run this script: There is [a script which allows you to submit new issues](https://github.com/exercism/java/blob/master/scripts/create_issues_versionchange_canonical.sh) to this repo with generic title, description and labels if a change in version was detected. -Example generic new isse: +Example generic new issue: image Before you may submit a new issue, the script @@ -214,8 +214,8 @@ To run this script: 3. In this file, you have to put the following variables: - `TOKEN="your_token"` - - `OWNER="repo_owner"` # -> `"exercism"` - - `REPO="repo_name"` # -> `"java"` + - `OWNER="exercism"` + - `REPO="java"` For authentication, you need to create a personal token, see [this GitHub page](https://help.github.com/en/articles/creating-a-personal-access-token-for-the-command-line) for more information. @@ -225,7 +225,7 @@ To run this script: ## Checking exercises are implemented and submit new issues -There is [a script which allows you to submit new issues](https://github.com/exercism/java/blob/master/scripts/create_issues_new_exercise.sh) to this repo with generic title, description and labels if am unimplemented exercise is detected. +There is [a script](https://github.com/exercism/java/blob/master/scripts/create_issues_new_exercise.sh) which allows you to easily check if there are any exercism exercises which haven't been implemented in the Java track, and create issues for those exercises if there are any. Before you may submit a new issue, the script 1. Checks whether the exercise exists in the Java track (compared to exercism/problem-specifications) @@ -240,11 +240,11 @@ To run this script: 3. In this file, you have to put the following variables: - `TOKEN="your_token"` - - `OWNER="repo_owner"` # -> `"exercism"` - - `REPO="repo_name"` # -> `"java"` + - `OWNER="exercism"` + - `REPO="java"` - For authentication, you need to create a personal token, see [this GitHub page](https://help.github.com/en/articles/creating-a-personal-access-token-for-the-command-line) for more information. + For authentication, you need to create a personal token, see [this GitHub page](https://help.github.com/en/articles/creating-a-personal-access-token-for-the-command-line) for more information. 4. Run `./scripts/create_issues_new_exercise.sh -t . -s --spec-path path_to_problem_specifications` from the root of this repository and follow the directions. - 5. If you submitted new issues, please check these submissions on the [issues page](https://github.com/exercism/java/issues). + 5. If you decide to submit a new issue you can find the opened issue on the [issues page](https://github.com/exercism/java/issues). diff --git a/scripts/create_issues_new_exercise.sh b/scripts/create_issues_new_exercise.sh index 326cd41c2..b9a31e251 100755 --- a/scripts/create_issues_new_exercise.sh +++ b/scripts/create_issues_new_exercise.sh @@ -123,7 +123,7 @@ for exercise in $problem_spec_exercises; do else printf ">>>>> Exercise $exercise is not yet implemented in the Java track.\n" title="$exercise: implement exercise" - body="The exercise **$exercise** has not been implemented yet for the Java track. \nThe description of the exercise can be found in the [problem specification repository](https://github.com/exercism/problem-specifications/tree/master/exercises/$exercise). \n\nHow to implement a new exercise for the Java track is described in detail in [CONTRIBUTING.md](https://github.com/exercism/java/blob/master/CONTRIBUTING.md#adding-a-new-exercise). Please have a look there first before starting working on the exercise. \nAlso please make sure it is clear that you are currently working on this issue, either by asking to be assigned to it, or by opening an empty PR. \n\nWhen opening an PR, please reference this issue using any of the [closing keywords](https://help.github.com/en/articles/closing-issues-using-keywords). \n\nIf you had a look at the exercise description and you concluded that the exercise might not be possible to implement in the Java language, please leave a comment and describe the problem. \n\nIn case you have any further questions, feel free to ask here. \n" + body="The exercise **$exercise** has not been implemented yet for the Java track. \nThe description of the exercise can be found in the [problem specification repository](https://github.com/exercism/problem-specifications/tree/master/exercises/$exercise). \n\nHow to implement a new exercise for the Java track is described in detail in [CONTRIBUTING.md](https://github.com/exercism/java/blob/master/CONTRIBUTING.md#adding-a-new-exercise). Please have a look there first before starting working on the exercise. \nAlso please make sure it is clear that you are currently working on this issue, either by asking to be assigned to it, or by opening an empty PR. \n\nWhen opening an PR, please reference this issue using any of the [closing keywords](https://help.github.com/en/articles/closing-issues-using-keywords). \n\nIf you have had a look at the exercise description and you concluded that the exercise might not be possible to implement in the Java language, please leave a comment and describe the problem. \n\nIn case you have any further questions, feel free to ask here. \n" labels='"help wanted", "implement exercise", "enhancement"' response=""