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

Rewrite bin/init_exercise.py in Rust #660

Merged
merged 80 commits into from
Oct 20, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
80 commits
Select commit Hold shift + click to select a range
c0da7d5
init_exercise: Generated the crate with 'cargo new'
ZapAnton Aug 29, 2018
14520c3
init_exercise: Added command-line arguments via clap
ZapAnton Aug 29, 2018
4d28d69
init_exercise: Added configure command
ZapAnton Aug 30, 2018
311fe16
init_exercise: Replaced the dont-update-config flag with the no-confi…
ZapAnton Aug 30, 2018
8056b7b
init_exercise: Added init_app and process_matches functions
ZapAnton Aug 30, 2018
45449e4
init_exercise: Added cmd module
ZapAnton Aug 30, 2018
bfadb09
init_exercise: Added process_matches to the generate module
ZapAnton Aug 30, 2018
ac3961d
init_exercise: Added exercise template generation
ZapAnton Aug 31, 2018
f6eced6
init_exercise: Added test suite and example.rs generation
ZapAnton Sep 2, 2018
11faf12
init_exercise: Added get_canonical_data function
ZapAnton Sep 5, 2018
9b61818
init_exercise: Added generate_standard_exercise_template function
ZapAnton Sep 5, 2018
bd002b9
init_exercise: Renamed generate_standard_exercise_template to generat…
ZapAnton Sep 9, 2018
907c4b1
init_exercise: Added update_cargo_toml function
ZapAnton Sep 9, 2018
fb4ceaa
init_exercise: Added prepend text to the test suite
ZapAnton Sep 10, 2018
f08f7e2
init_exercise: Added generation of the property functions to the test…
ZapAnton Sep 12, 2018
a97e032
init_exercise: Applied suggestions from clippy
ZapAnton Sep 17, 2018
bc83644
init_exercise: Added test suite functions generation
ZapAnton Sep 17, 2018
c1eba7a
init_exercise: Added generate_readme function
ZapAnton Sep 17, 2018
13f4778
init_exercise: Configured std::process::Command calls to wait until t…
ZapAnton Sep 18, 2018
3812526
init_exercise: Renamed 'init_exercise' crate to 'exercise' crate
ZapAnton Sep 18, 2018
1c25970
exercise: Added shell script for building exercise crate
ZapAnton Sep 18, 2018
e3e39f7
exercise: Updated build_exercise_crate.sh script to look for Windows …
ZapAnton Oct 3, 2018
e531e70
exercise: Removed redundant echos from build_exercise_crate.sh script
ZapAnton Oct 3, 2018
831d4cb
exercise: Removed run_configure argument from the generate_exercise f…
ZapAnton Oct 3, 2018
1400be9
exercise: Added configure_exercise call to the generate subcommand
ZapAnton Oct 3, 2018
fe79622
exercise: Added utils module
ZapAnton Oct 3, 2018
fab6d41
exercise: Implemented the user configuration reading for the configur…
ZapAnton Oct 3, 2018
2a15897
exercise: Implemented the writing of the updated configuration to the…
ZapAnton Oct 3, 2018
da04d25
exercise: Added run_configlate_command to the utils module
ZapAnton Oct 3, 2018
b4cd1cd
exercise: Replaced the configlet call code with the run_configlet_com…
ZapAnton Oct 3, 2018
cb1328c
exercise: Added configlet fmt call to the configure_exercise funtion
ZapAnton Oct 3, 2018
0de9ed6
exercise: Replace 'null' with 'hello-world' as default unlocked_by fi…
ZapAnton Oct 3, 2018
151a1fb
exercise: Added configure_exercise call for the configure subcommand
ZapAnton Oct 3, 2018
4ff5bf3
exercise: Fixed typo: 'run_configlate_command' -> 'run_configlet_comm…
ZapAnton Oct 4, 2018
a9b7b40
exercise: configure subcommand now updates existing exercise config
ZapAnton Oct 12, 2018
5959a3f
exercise: configure subcommand now allows to move the existing exerci…
ZapAnton Oct 12, 2018
7d3dd70
exercise: Replaced the 'None' with 'hello-world' in the unlocked_by f…
ZapAnton Oct 12, 2018
062a7b8
exercise: Moved the processing of ArgMatches to the main module for t…
ZapAnton Oct 12, 2018
5f382b8
exercise: Replaced &Vec<Value> argument type with &[Value]
ZapAnton Oct 12, 2018
755f1bf
exercise: Replaced the 'no-configure' flag with the 'configure' flag …
ZapAnton Oct 12, 2018
9415a3f
exercise: Added update_exercise call to the main module
ZapAnton Oct 12, 2018
910625f
exercise: Added check if exercise exists for the update subcommand
ZapAnton Oct 12, 2018
5c5a61e
exercise: Moved get_canonical_data function to the utils module
ZapAnton Oct 16, 2018
719b680
exercise: Added get_tests_content function to the utils module
ZapAnton Oct 17, 2018
efd92f1
exercise: Added formatting functions for the 'property' and 'descript…
ZapAnton Oct 17, 2018
0ddbdfb
exercise: Implemented apply_diffs function for the update subcommand
ZapAnton Oct 17, 2018
fba82ad
exercise: Replaced apply_diffs function get_diffs function
ZapAnton Oct 18, 2018
16956b1
exercise: Implemented the update of the tests file
ZapAnton Oct 18, 2018
ece5f5e
exercise: Added use_maplit flag for the update subcommand
ZapAnton Oct 18, 2018
668ce12
README: Replaced the 'init_exercise.py' script description with the '…
ZapAnton Oct 18, 2018
78c31da
README: Fixed typo - realease -> release
ZapAnton Oct 18, 2018
3d582f6
build_exercise_crate: Fixed the Windows release path check
ZapAnton Oct 18, 2018
052d81e
exercise: Removed the authors field from the Cargo.toml and the '--he…
ZapAnton Oct 18, 2018
88792da
exercise: Added space to the user difficulty input prompt
ZapAnton Oct 18, 2018
7d0dad3
exercise: Added the newline at the end of the default generated '.met…
ZapAnton Oct 18, 2018
036fbdb
exercise: Moved exercise_exists function to the utils module
ZapAnton Oct 19, 2018
7de3f34
exercise: Replaced the panic in the exercise exists checks with print…
ZapAnton Oct 19, 2018
3830e3c
exercise: Made the [utility] link to point at the exercise crate url …
ZapAnton Oct 19, 2018
4106b94
exercise: Removed the blank line in the generated test case if no com…
ZapAnton Oct 19, 2018
06c783b
exercise: 'update' subcommand now updates the version of the exercise…
ZapAnton Oct 19, 2018
623f0e7
exercise: Moved the update_cargo_toml_version function to the utils m…
ZapAnton Oct 19, 2018
6feba5d
exercise: Made 'configure' subcommand to retain the existing values a…
ZapAnton Oct 19, 2018
ce5e2c8
exercise: Made 'configure' subcommand accept difficulties equal to or…
ZapAnton Oct 19, 2018
b497fbe
exercise: Added an option to restart the positioning binary search
ZapAnton Oct 19, 2018
88f87b0
exercise: Moved the crate into the 'util' directory
ZapAnton Oct 19, 2018
c9e30d2
travis: Added a script to check if the 'exercise' crate compiles if i…
ZapAnton Oct 19, 2018
7113651
check-exercise-crate: Replaced the 'cargo build --release' command wi…
ZapAnton Oct 19, 2018
f23c5e8
exercise: Replaced the locating of the 'rustfmt' utility via 'which' …
ZapAnton Oct 19, 2018
18131cb
exercise: Simplified the exercise_exists function
ZapAnton Oct 19, 2018
01f3de2
exercise: Fixed typo in the 'exercise does not exist' message
ZapAnton Oct 19, 2018
048d369
exercise: Specified the exercise difficulty prompt
ZapAnton Oct 19, 2018
fab2229
exercise: Specified that the new exercise is generated via 'exercise'…
ZapAnton Oct 19, 2018
9850f9b
exercise: Fixed comment typo
ZapAnton Oct 19, 2018
967bc98
exercise: Inlined the urls in the generated tests suite template
ZapAnton Oct 19, 2018
cf3d151
exercise: Replaced the get_track_root function with lazy_static TRACK…
ZapAnton Oct 19, 2018
dab2ebf
README: Updated the 'exercise' crate section to mention the openssl d…
ZapAnton Oct 19, 2018
6f73c97
exercise: Updated the crate's version to '1.0.0'
ZapAnton Oct 19, 2018
d8d464b
init_exercise.py: Removed the script from the track
ZapAnton Oct 19, 2018
e0778ee
Revert "init_exercise.py: Removed the script from the track"
coriolinus Oct 20, 2018
34ff773
fix readme possessive typo
coriolinus Oct 20, 2018
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,6 @@
tmp
bin/configlet
bin/configlet.exe
exercises/*/Cargo.lock
bin/exercise
bin/exercise.exe
exercises/*/Cargo.lock
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ script:
- "./bin/configlet lint ."
- "./_test/verify-exercise-difficulties.sh"
- "./_test/check-exercises-for-authors.sh"
- "sh ./_test/check-exercise-crate.sh"
sudo: false
rust:
- stable
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ Please see the documentation about [adding new exercises](https://github.com/exe

Note that:

- The simplest way to generate a project template is to run `bin/init_exercise.py`. You'll need a Python installation >= 3.5 in order to run this script, but it will automate most of the following points for you.
- The simplest way to generate, update or configure an exercise is to use the [exercise](https://github.com/exercism/rust/tree/master/util/exercise) utility provided in this repository. To compile the utility you can use the [bin/build_exercise_crate.sh](https://github.com/exercism/rust/tree/master/bin/build_exercise_crate.sh) script or, if the script does not work for you, use the `cargo build --release` command in the `util/exercise/` directory and then copy the `exercise` binary from the `util/exercise/target/release/` directory into the `bin/` directory. Use `bin/exercise --help` to learn about the existing commands and their possible usage. Please note that this utility depends on the `reqwest` crate and therefore you may need to install its [required libraries](https://github.com/seanmonstar/reqwest#requirements) (namely `openssl`) in your system.

- Each exercise must stand on its own. Do not reference files outside the exercise directory. They will not be included when the user fetches the exercise.

Expand Down
34 changes: 34 additions & 0 deletions _test/check-exercise-crate.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#!/usr/bin/env sh

# A script to ensure that the util/exercise crate builds after it was modified.

EXERCISE_CRATE_PATH="util/exercise"

CURRENT_BRANCH_NAME=$(git rev-parse --abbrev-ref HEAD)

if [ "$CURRENT_BRANCH_NAME" != "master" ]; then
# Check the changes on the current branch against master branch
git diff --name-only master | grep "$EXERCISE_CRATE_PATH"
else
# Check the commits on the master branch made during the week
# This is because Travis cron is set to test the master branch weekly.
git diff --name-only "@{7 days ago}" | grep "$EXERCISE_CRATE_PATH"
fi

if [ $? != 0 ]; then
echo "exercise crate was not modified. The script is aborted."

exit 0
fi

TRACK_ROOT="$(git rev-parse --show-toplevel)"

if !(cd "$TRACK_ROOT/$EXERCISE_CRATE_PATH" && cargo check); then
echo "\nAn error has occurred while building the exercise crate.\nPlease make it compile."

exit 1
else
echo "\nexercise crate has been successfully built."

exit 0
fi
26 changes: 26 additions & 0 deletions bin/build_exercise_crate.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/bin/bash
# Compile the 'exercise' crate and put it in the 'bin/' folder

TRACK_ROOT="$(git rev-parse --show-toplevel)"

EXERCISE_CRATE_PATH="$TRACK_ROOT/util/exercise"

BIN_DIR_PATH="$TRACK_ROOT/bin"

(
cd "$EXERCISE_CRATE_PATH"

echo "Building exercise crate"

cargo build --release

RELEASE_PATH="$EXERCISE_CRATE_PATH/target/release/exercise"

if [ -f "$RELEASE_PATH.exe" ]; then
RELEASE_PATH="$RELEASE_PATH.exe"
fi

echo "Copying exercise crate from $RELEASE_PATH into $BIN_DIR_PATH"

cp "$RELEASE_PATH" "$BIN_DIR_PATH"
)
Loading