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

Tooling and CI set up + 1st four exercises #25

Merged
merged 24 commits into from
Sep 2, 2024
Merged

Conversation

gvrooyen
Copy link
Contributor

This PR sets up the basic foundation for the Odin track so that contributors can focus on creating new exercises:

  • test.yml now runs configlet lint and tests for all exercises. Any new .odin files are automatically formatted according to the specification in odinfmt.json. The CI workflow was tested as I created new exercises.
  • The tooling (bin/{runtest.sh,verify_exercises}) has been fixed to work together correctly.
  • The bin/format_all.sh script was added to automatically format all .odin files (individual files can be formatted by invoking odinfmt directly).
  • The "hello-world", "leap", "difference-of-squares", and "grains" exercises were added to validate the changes listed above. I used the test cases from the Gleam track to cover a broad range of inputs.
  • The README was updated to give more detailed instructions to new contributors.

Completed the hello-world and leap exercises.
Updated configuration.
Completed the difference-of-squares practice exercise, and added the
`bin/format-all.sh` script that recursively searches for .odin files and
runs `odinfmt` on them.
All source files have been reformatted with the `odinfmt.json` spec.
`bin/format-all.sh` is now run automatically on commit.
The `test.yml` GitHub workflow now pushes any changes that it makes, so
that they persist in the repo.
`test.yml` now only attempts a commit and push if the automated
formatting actually changed any files.
The verify-exercises script now runs the individual test for both
concept and practice exercises, and is the default in the GitHub
workflow.
Tests were lifted from the Gleam track.
- The README now contains more thorough instructions on how to add a new
  exercise.
- Fixed a variable name in the test runner that caused the "test all
  solutions" loop to run multiple times when verifying solutions.
@ErikSchierboom
Copy link
Member

I'll review this on Tuesday

.github/workflows/test.yml Outdated Show resolved Hide resolved
.github/workflows/test.yml Outdated Show resolved Hide resolved
exercises/practice/difference-of-squares/.meta/config.json Outdated Show resolved Hide resolved
@@ -0,0 +1,14 @@
package difference_of_squares

square_of_sum :: proc(n: int) -> int {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be the student stub. It looks like this is the example solution.

Copy link
Contributor Author

@gvrooyen gvrooyen Aug 25, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😳 Oops, yes I think this got overwritten by the test script and I missed it – that needs a fix too

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The test script had a bug where it clobbered student stubs if the test failed. This has been fixed.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file still needs to revert to an actual stub :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh man, this has tripped me up too many times now 🙈. I'll fix this, and add a check to bin/run-test.sh that fails the test if the stub solution passes.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added a test that fails if the stub turns out to be a valid solution

exercises/practice/grains/grains.odin Outdated Show resolved Hide resolved
exercises/practice/hello-world/hello_world.odin Outdated Show resolved Hide resolved
exercises/practice/leap/leap.odin Outdated Show resolved Hide resolved
Copy link
Member

@BNAndras BNAndras left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some more comments now that I'm at a computer.

README.md Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
README.md Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
config.json Outdated Show resolved Hide resolved
- Fixed bin/run-test.sh so that it doesn't delete the stub solution when
  a test fails.
- Restored exercises, and added a NotImplemented error condition for the
  stubs.
- Ran the code formatter on source files.
- Rehaul of the README to follow Python's example.
The workflow now uses a fixed commit hash to pull a specific release of
Odin. We now use Ubuntu 22.04 which has the libffi8 dependency, and add
clang as the only other dependency.
README.md Outdated Show resolved Hide resolved
@@ -0,0 +1,14 @@
package difference_of_squares

square_of_sum :: proc(n: int) -> int {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file still needs to revert to an actual stub :)

exercises/practice/hello-world/hello_world.odin Outdated Show resolved Hide resolved
exercises/practice/leap/leap.odin Outdated Show resolved Hide resolved
Added a check to bin/run-test.sh so that verifies that the stub solution
does *not* pass any tests. Fixed hello-world.odin to actually be a stub.
- Improved bin/run-test.sh to add more visible color coding to the
  output.
- Replaced NotImplemented error codes with a compile-time panic for
  procedures that have not yet been implemented.
- Fixed stubs that were actually complete examples.
- Exercises' unit tests were modified so that only a minimal subset of
  tests are initially enabled; the rest are skipped.
- The test runner was modified to automatically unskip all test cases
  before running the tests.
@gvrooyen
Copy link
Contributor Author

@BNAndras @Nezteb I think all of the outstanding issues have been resolved, or is there something I can still do to wrap up the PR? I'm happily working on the exercises themselves in another branch, so there's no rush from my side 🙂

Copy link
Member

@BNAndras BNAndras left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is good as a start. We can always iterate over anything that needs polishing before launch.

README.md Outdated
This is what users will start with when solving the exercise.
- Add tests to `<slug>_test.odin`.
Verify that the slug solution would fail _all_ tests.
Consider adding an error return enumeration such as `NotImplemented` to ensure that the stub solution's return values are invalid for all test cases.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't believe this still applies.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch! I fixed that, and left a comment about how we should check the stub solution in the test runner

Copy link
Contributor

@Nezteb Nezteb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work! 😄

@ErikSchierboom
Copy link
Member

Feel free to merge!

@gvrooyen
Copy link
Contributor Author

gvrooyen commented Sep 2, 2024

I think you're the one who has to press the big "merge" button, @Nezteb 😁

@Nezteb Nezteb merged commit 44aa486 into exercism:main Sep 2, 2024
2 checks passed
gvrooyen added a commit to gvrooyen/odin that referenced this pull request Sep 2, 2024
Tooling and CI set up + 1st four exercises (exercism#25)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants