-
Notifications
You must be signed in to change notification settings - Fork 2
Developer docs #11
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
Merged
Merged
Developer docs #11
Changes from all commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
85ba15a
improve developer docs in readme
TheRealOwenRees 96c8cb7
add fork and clone info
TheRealOwenRees 466957d
add feedback, copied form ocaml track
TheRealOwenRees 54c5e4d
add relevant exercism doc links
TheRealOwenRees aa24d84
remove repo fork info
TheRealOwenRees f2d91a4
update configlet fmt typo
TheRealOwenRees 365ff5d
update installation / prerequisites section
TheRealOwenRees 3a5f68e
add submodule explanation
TheRealOwenRees ed8bbe4
moved coding style, deleted docker commented out instructions
TheRealOwenRees ab91145
remove in directly embeded links in preference of references
TheRealOwenRees e69d005
replace reason with rescript in wording
TheRealOwenRees 77bb0de
Merge branch 'main' into developer-docs
TheRealOwenRees 9b48f6e
Merge branch 'main' into developer-docs
TheRealOwenRees d167c03
sync metadata
TheRealOwenRees c28c02d
update problem specification from latest commit
TheRealOwenRees 8b1a75d
PR related wording fixes
TheRealOwenRees 7dfbea8
update adding exercises workflow
TheRealOwenRees dd40be4
rewrite test workflow, move dev env workflow
TheRealOwenRees 3d04901
fix configlet lint link in Markdown
BNAndras File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,69 +1,141 @@ | ||
| # Exercism ReScript Track | ||
|
|
||
| [](https://github.com/exercism/rescript/actions/workflows/configlet.yml) [](https://github.com/exercism/rescript/actions/workflows/test.yml) | ||
| [](https://github.com/exercism/rescript/actions/workflows/configlet.yml) | ||
| [](https://github.com/exercism/rescript/actions/workflows/test.yml) | ||
|
|
||
| Exercism exercises in ReScript. | ||
|
|
||
| ## Testing | ||
| ## Installation | ||
|
|
||
| Track exercises target [ReScript] 12.2.0 using the [ReScript Test][ReScriptTest] testing framework on [Node.js] 22+. If you're contributing to the track, you will also need [make]. | ||
|
|
||
| ### Setting up the development environment | ||
|
|
||
| Run the following commands from inside the project root directory to install the required tools: | ||
|
|
||
| ```shell | ||
| npm install | ||
| git submodule update --init --recursive # add/update a local copy of the problem-specification submodule | ||
| ``` | ||
|
|
||
| To test all exercises, run `./bin/verify-exercises`. | ||
| This command will iterate over all exercises and check to see if their exemplar/example implementation passes all the tests. | ||
| To automate the creation of practice exercise tests, our track tooling consumes data from the the [problem specifications][exercism-problem-specifications-link] submodule. Because these specifications serve as the canonical source for all Exercism tracks, any upstream updates ensure our test cases remain consistent with the global exercise standard. | ||
|
|
||
| To test a single exercise, run `./bin/verify-exercises <exercise-slug>`. | ||
| If you have format on save enabled for JSON files, it is recommended to disable this feature. Alternatively save JSON files with `Ctrl+K s` to save without applying formatting rules. | ||
|
|
||
| ### Using Docker | ||
| ## Running the development environment | ||
|
|
||
| If your track has a working [test runner](https://exercism.org/docs/building/tooling/test-runners), the `./bin/verify-exercises-in-docker` script can also be used to test all exercises. | ||
| This script pulls (_downloads_) the test runner's [Docker image](https://exercism.org/docs/building/tooling/test-runners/docker) and then uses Docker to run that image to test an exercise. | ||
| Open up two terminals. By running the commands below, files will compile on save and re-run the test suite. | ||
|
|
||
| ```exercism/note | ||
| The main benefit of this approach is that it best mimics how exercises are tested in production (on the website). | ||
| Another benefit is that you don't have to install track-specific dependencies (e.g. an SDK) locally, you just need Docker installed. | ||
| ```shell | ||
| # Terminal 1 | ||
| npm run res:start | ||
|
|
||
| # Terminal 2 | ||
| npm run test | ||
| ``` | ||
|
|
||
| To test a single exercise, run `./bin/verify-exercises-in-docker <exercise-slug>`. | ||
| ## Adding Exercises | ||
|
|
||
| ### Linting | ||
| Documentation on contributing to Exercism can be found [here][exercism-contributing-docs-link]. | ||
|
|
||
| [`configlet`](https://exercism.org/docs/building/configlet) is an Exercism-wide tool for working with tracks. You can download it by running: | ||
| New practice exercises can be added via: | ||
|
|
||
| ```shell | ||
| $ ./bin/fetch-configlet | ||
| bin/add-practice-exercise <exercise-slug> | ||
|
|
||
| # Optionally, you can also specify the exercise's difficulty (via `-d`) and/or author's GitHub username (via `-a`): | ||
| bin/add-practice-exercise -a foobar -d 3 <exercise-slug> | ||
| ``` | ||
|
|
||
| Run its [`lint` command](https://exercism.org/docs/building/configlet/lint) to verify if exercises have the required files and if config files are correct: | ||
| Now complete the following steps: | ||
|
|
||
| - Ensure that the new exercise data is correctly placed in order of difficulty and then alphabetically within that difficulty rating - `config.json` | ||
| - Implement exercise test cases, detailed in the [testing](#testing) section below - `templates/Test_template.res` | ||
| - Write an example of code here that will pass all test cases. This does not need to be the finest example of how to complete this exercise, but it must pass all the test cases - `exercises/practice/<exercise-slug>/.meta/<exercise-name>.res` | ||
| - Update the example solution's interface file with the function signatures - `exercises/practice/<exercise-slug>/.meta/<exercise-name>.reso` | ||
| - Create an exercise stub which returns `panic("'<function-name>' has not been implemented")` - `exercises/practice/<exercise-slug>/src/<exercise-name>.res` | ||
| - Update the exercise stub's interface file with the exposed function signatures so that the student has a reference to what names and types are used - `exercises/practice/<exercise-slug>/src/<exercise-name>.resi` | ||
|
|
||
| ## Testing | ||
|
|
||
| Tests are written using [rescript-test][ReScriptTest]. There is a test templating system in place to reduce the amount of work needed by a developer. Follow these steps when writing tests: | ||
|
|
||
| - `exercises/practice/<exercise-slug>/.meta/tests.toml` - if any of these test cases are not relevant to the language, add `ignore = true` on a newline below the description | ||
|
TheRealOwenRees marked this conversation as resolved.
|
||
| - `test_templates/<Exercise>_template.res` - edit this file to allow the test generator to automatically create test files. If this file does not exist, copy `templates/Test_template.res` and rename to match the aforementioned filename. | ||
| - you must write your comparator functions - https://bloodyowl.github.io/rescript-test/assertions. | ||
| - common assertions with comparator functions are located at `test_generator/Assertions.res`. Add the ones you'd like to use to the `generateTests` function's last argument, eg `TestGenerator.generateTests(slug, template, [DictEqual])`. | ||
| - edit the `template` function so that it will generate the test cases. The `case` parameter refers to a test case in `problem-specifications/exercises/<exercise-slug>/canonical-data.json`. Refer to other exercise test templates for inspiration. | ||
|
|
||
| Run all exercise tests: | ||
|
|
||
| ```shell | ||
| $ ./bin/configlet lint | ||
|
|
||
| The lint command is under development. | ||
| Please re-run this command regularly to see if your track passes the latest linting rules. | ||
|
|
||
| Basic linting finished successfully: | ||
| - config.json exists and is valid JSON | ||
| - config.json has these valid fields: | ||
| language, slug, active, blurb, version, status, online_editor, key_features, tags | ||
| - Every concept has the required .md files | ||
| - Every concept has a valid links.json file | ||
| - Every concept has a valid .meta/config.json file | ||
| - Every concept exercise has the required .md files | ||
| - Every concept exercise has a valid .meta/config.json file | ||
| - Every practice exercise has the required .md files | ||
| - Every practice exercise has a valid .meta/config.json file | ||
| - Required track docs are present | ||
| - Required shared exercise docs are present | ||
| make test | ||
| ``` | ||
|
|
||
| ## Adding exercises | ||
| This command will iterate over all exercises and check to see if their example implementation passes all the tests. | ||
|
|
||
| New (practice) exercises can be added via: | ||
| To test that all exercises will pass in the CI/CD environment, run: | ||
|
|
||
| ```shell | ||
| bin/add-practice-exercise <exercise-slug> | ||
| ./bin/verify-exercises | ||
|
|
||
| # test a single exercise: | ||
| ./bin/verify-exercises <exercise-slug> | ||
| ``` | ||
|
|
||
| Optionally, you can also specify the exercise's difficulty (via `-d`) and/or author's GitHub username (via `-a`): | ||
| ## Coding Style | ||
|
|
||
| Use `PascalCase.res` for ReScript implementation file names. | ||
| A ReScript interface file (`.resi`) should be included with every exercise to help the user get started. | ||
|
|
||
| Run `make format` on your code before pushing. | ||
|
|
||
| If you are using VS Code, install the official [ReScript VS Code extension][rescript-vs-code-extension] for syntax highlighting and code formatting. | ||
|
|
||
| ## Linting & Formatting | ||
|
|
||
| [`configlet`][configlet] is an Exercism-wide tool for working with tracks. You can download it by running: | ||
|
|
||
| ```shell | ||
| bin/add-practice-exercise -a foobar -d 3 <exercise-slug> | ||
| ./bin/fetch-configlet | ||
| ``` | ||
|
|
||
| Run the [`lint` command][configlet-lint-link] to verify if exercises have the required files and if config files are correct. Address any issues before pushing your changes: | ||
|
|
||
| ```shell | ||
| ./bin/configlet lint | ||
| ``` | ||
|
|
||
| Run the [`fmt` command][configlet-fmt-link] to verify if the configuration files are formatted correctly. Address any issues before pushing your changes: | ||
|
|
||
| ```shell | ||
| ./bin/configlet fmt | ||
|
|
||
| # check a single exercise | ||
| ./bin/configlet fmt -e <exercise-slug> | ||
|
|
||
| # auto format files | ||
|
TheRealOwenRees marked this conversation as resolved.
|
||
| ./bin/configlet fmt -uy | ||
| ``` | ||
|
|
||
| If you are auto formatting files, only commit the files relevant to your pull request. | ||
|
|
||
| ## Feedback | ||
|
|
||
| If you find this documentation is inaccurate or incomplete, or can be improved in any way, please don't hesitate to create a new topic on the [Exercism Forum][exercism-forum] | ||
|
|
||
| [ReScript]: https://rescript-lang.org/ | ||
| [ReScriptTest]: https://bloodyowl.github.io/rescript-test/ | ||
| [Node.js]: https://nodejs.org/ | ||
| [repository]: https://github.com/exercism/rescript | ||
| [issue-link]: https://github.com/exercism/rescript/issues | ||
| [configlet-lint-link]: https://exercism.org/docs/building/configlet/lint | ||
| [configlet-fmt-link]: https://exercism.org/docs/building/configlet/fmt | ||
| [github-fork-pr-link]: https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/creating-a-pull-request-from-a-fork | ||
| [exercism-pr-docs-link]: https://exercism.org/docs/building/github/contributors-pull-request-guide | ||
| [exercism-contributing-docs-link]: https://exercism.org/docs/building | ||
| [exercism-problem-specifications-link]: https://github.com/exercism/problem-specifications | ||
| [configlet]: https://exercism.org/docs/building/configlet | ||
| [make]: https://www.gnu.org/software/make/ | ||
| [rescript-vs-code-extension]: https://marketplace.visualstudio.com/items?itemName=chenglou92.rescript-vscode | ||
| [exercism-forum]: https://forum.exercism.org/ | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Submodule problem-specifications
updated
3 files
| +1 −1 | exercises/anagram/metadata.toml | |
| +96 −87 | exercises/bob/canonical-data.json | |
| +1 −1 | exercises/isogram/metadata.toml |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.