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

[Recurring] Keep practice exercises up-to-date with problem specifications #2388

Open
sanderploegsma opened this issue Sep 22, 2023 · 4 comments
Labels
good first issue Good for newcomers help wanted Extra attention is needed x:action/sync Sync content with its latest version x:knowledge/elementary Little Exercism knowledge required x:module/practice-exercise Work on Practice Exercises x:size/medium Medium amount of work x:type/content Work on content (e.g. exercises, concepts)

Comments

@sanderploegsma
Copy link
Contributor

sanderploegsma commented Sep 22, 2023

This is a recurring task that has to be done from time to time.
Do not reference this issue by writing resolves/fixes #XXX in your PR because that will close it.

We want to keep the track up to date with problem specifications, which means regularly checking if anything changes and needs updating.

How to do this task:

Step 1: fetch configlet

Run:

./bin/fetch-configlet

Step 2: check which exercises need updating and in which way

Run:

./bin/configlet sync 

The output will list all Java exercises that are out of sync in some way. Example output:

[warn] docs: instructions unsynced: affine-cipher
[warn] docs: instructions unsynced: all-your-base

[warn] metadata: unsynced: acronym
[warn] metadata: unsynced: armstrong-numbers

[warn] collatz-conjecture: missing 2 test cases
       - zero is an error (2187673d-77d6-4543-975e-66df6c50e2da)
       - negative value is an error (ec11f479-56bc-47fd-a434-bcd7a31a7a2e)

Choose one or more problems and attempt to fix it.
Metadata and doc updates can be all done together for many exercises in a single PR, but please create separate PRs per exercise when changing tests.

Step 3.1: Sync all docs

Run this command to update all exercise docs (introductions):

 ./bin/configlet sync --docs --update

Press y when asked sync the above docs ([y]es/[n]o)?.

Step 3.2: Sync all metadata

Run this command to update all exercise metadata:

 ./bin/configlet sync --metadata --update

Press y when asked sync the above metadata ([y]es/[n]o)?.

Step 3.3: Update tests for an exercise

The general goal is that all Java practice exercises follow problem specifications, except for when it doesn't make any sense in Java.

Important:

Get familiar with the problem specifications repository and the canonical-data.json format it uses for describing tests cases.
Read CONTRIBUTING.md for the general rules of this repository.
Please create separate a PR per exercise when changing tests.

Step 3.3.1 Update tests.toml

Update tests.toml by running this command for a chosen exercise:

./bin/configlet sync --exercise <exercise-slug> --tests --update

This command assumes that we want to implement all the new tests, and that is our default approach, but it still needs verifying on a test-by-test base.

Step 3.3.2 Analyze the new test cases and update the Java tests files accordingly

Find all the test cases affected by the previous step in the exercise's canonical-data.json file in the problem specifications repository. Analyze what the changes actually are.

You might need to delete a test. You might need to add a new test. You might also need to replace an existing test with a new one (you'll see in tests.toml that it "reimplements" another).

Some exercises don't even have a tests.toml file yet. In this case, carefully check which tests from the canonical-data.json are already implemented and make sure the generated tests.toml file reflects this.

If you believe a new test case shouldn't be implemented, mark it as such in tests.toml. For example:

[1e22cceb-c5e4-4562-9afe-aef07ad1eaf4]
description = "some test that will not be implemented for this track"
include = false
comment = "Not included because <reason>"

When editing the Java tests, make sure to:

Follow the coding style used in the existing test file.
Use the test description from the tests.toml file as name of the test method (unless that would invalidate the first rule).
Keep the order of the tests in the Java test file the same as they are in the tests.toml file (unless that would invalidate the first rule).

Step 3.3.3 Check that the example solution works with new test cases

After modifying the Java tests, run this command from the exercises directory to run them:

./gradlew practice:<exercise-slug>:test

If it fails, double-check if the new tests are correct. If they are, that means our example solution for this exercise is no longer valid for the new tests and needs to be updated!

When adding a completely new function that students need to implement, or when changing the return types of an existing one, make sure to also update the stub file.

Step 3.4 Remove deprecated files

Previously the version of each practice exercise was tracked through a .meta/version file. This is no longer being used, so please delete it after syncing an exercise with the problem-specifications.

Resources

Need help?

Configlet docs
General track docs
Don't hesitate to ask here in case you can't find answers to your questions!

@sanderploegsma sanderploegsma added good first issue Good for newcomers x:action/sync Sync content with its latest version x:knowledge/elementary Little Exercism knowledge required x:module/practice-exercise Work on Practice Exercises x:type/content Work on content (e.g. exercises, concepts) x:size/medium Medium amount of work labels Sep 22, 2023
@howdyAnkit
Copy link

Hi @sanderploegsma can you suggest me any initial level issue from above so that I can contribute. like what is expected and how to verify the code meet's the requirement. would like to connect on discord can you please send request @howdyAnkit on discord

@sanderploegsma
Copy link
Contributor Author

sanderploegsma commented Sep 24, 2023

@howdyAnkit sure thing!

First things first, make sure you have the Configlet set up on your machine. The easiest way to do so is to fork and clone this repository and run the bin/fetch-configlet.sh script from the repository root. This will download the latest version and put it as an executable script in the bin directory.

You can then use the Configlet to see the number of missing tests for each exercise by running:

bin/configlet sync --tests

This will print the full list of all tests missing, grouped by exercise. I suggest picking an exercise for which only a one or two tests are missing to start with. Tackling this will teach you how to work with the tooling and how to contribute to this Exercism track.

Once you have picked an exercise to update, use the following command to update its auto-generated .meta/tests.toml:

bin/configlet sync --tests --update --exercise <exercise-slug>

This will interactively prompt you for each missing test case whether it should be included or not (the answer should probably be yes), as well as a description of the test case, its input and expected output.

When this script is finished, all that remains is to update the exercise's Java test suite to include the newly added test case(s).


I'll add you on Discord, in case you want to ask any further questions. I posted this guide here because it may also help others getting started.

@sanderploegsma sanderploegsma added hacktoberfest help wanted Extra attention is needed labels Oct 4, 2023
@sanderploegsma sanderploegsma changed the title Sync test cases for practice exercises [Recurring] Keep practice exercises up-to-date with problem specifications Oct 22, 2023
@sanderploegsma sanderploegsma pinned this issue Oct 22, 2023
@sanderploegsma
Copy link
Contributor Author

Repurposed this issue as syncing practice exercises is an ongoing activity.

@manumafe98
Copy link
Contributor

Hi @sanderploegsma as we talked i'm going to take onto Step 3.4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers help wanted Extra attention is needed x:action/sync Sync content with its latest version x:knowledge/elementary Little Exercism knowledge required x:module/practice-exercise Work on Practice Exercises x:size/medium Medium amount of work x:type/content Work on content (e.g. exercises, concepts)
Projects
None yet
Development

No branches or pull requests

3 participants