-
-
Notifications
You must be signed in to change notification settings - Fork 14
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
sync: handle docs, metadata, and filepaths #366
Conversation
79ac448
to
c7c95c9
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for working on this! I've not done any testing yet, as I think you are still working on this a bit. Let me know when you want me to test.
@ErikSchierboom If an exercise lacks a
For the (Similar to exercism/docs#155 (comment)) |
I think that would be nice yeah. It's not a hard requirement, but it would make sense to me. For the non-update ones, maybe output an error? |
136fbc9
to
1f4a39e
Compare
I'll update this PR with the latest changes from |
I think this is clearer - it's more obvious that we only use the `testCases` or `testsPath` variable when syncing tests.
The first implementation of metadata syncing produced no output when an exercise in `problem-specifications` lacked a `metadata.toml` file, and our tests were using a `problem-specifications` commit where the only metadata files are YAML. This commit bumps the `problem-specifications` hash so that our integration tests have access to `metadata.toml` files. For the commit that added `metadata.toml` files, see: exercism/problem-specifications@df6420b279d1
Previously, a user might think that `-u` does not respect the options that restrict the data kinds to sync.
We can add this when we test the upcoming `configlet fmt` command.
Let's add this in the commit that implements `configlet fmt`.
This commit guarantees that we don't accidentally call `pretty` in "format mode" somewhere. Let's add this code back in the commit that adds `configlet fmt` instead. The removed code also had a minor bug, which will be fixed in that upcoming commit: `fmt` shouldn't write the `editor` key when its value is the empty array.
This doesn't really matter - it's just that we want to explicitly initialize `result`, and the previous number could give a misleading impression of the typical `.meta/config.json` file size. Across every Exercism track, the mean formatted `config.json` length is about 430 characters. The biggest ones are under 1000 characters, so this commit means we'll (currently) never grow the string, rather than growing it typically 3 times and at most 4 times. This (very marginally) improves performance when writing `.meta/config.json` files. The number itself optimizes for the largest config files, not the average ones.
This makes the assertion slightly stronger, by adding the directory at the start. It also removes the string allocations due to `lastPathPart`.
This just improves the error message for something that should never occur, and removes some configlet source file/line number information from the release executable. Before this commit: $ nimble build -d:danger && strings configlet | grep '.nim(' @sync_docs.nim(121, 14) `path.endsWith(instrSuffix) or path.endsWith(introSuffix)` @sync_filepaths.nim(138, 14) `path.endsWith(&".meta{DirSep}config.json")` @sync_metadata.nim(96, 14) `path.endsWith(&".meta{DirSep}config.json")`
We don't need this assertion in the release build. This commit also finishes removing configlet source file information from the binary. Before this commit: $ nimble build -d:release && strings configlet | grep 'sync_' @sync_common.nim(67, 10) `truncateLen <= s.len and s[truncateLen - 1] == DirSep`
This is more readable and explicit.
🥳 Awesome work! |
To-do:
--docs
,--filepaths
,--metadata
,--tests
,-y
check.nim
tosync.nim
, andupdate.nim
toupdate_tests.nim
update_tests.nim
main
) test--exercise
main
) test--update
withy
,n
, and something else from stdinConsider a separate PR for ff19da4 to help git track the renames. Currently if we squash this PR, git probably doesn't know thatEdit: Let's not bother.sync.nim
comes fromcheck.nim
.--exercise
--yes
to clarify that it only affects docs, metadata, and filepaths--update
-y
sync -uy
andsync -uy --tests
produce an errorconfig.json
doesn't exist, lacks afiles
key, etc.jsony
for parsing JSONstd/json
userSaysYes
: handle unrecognised entrySlug
is kebab-case.instructions.md
when it doesn't existjoinPath
allocations.meta/config.json
file on a track the same asparseJson.toPretty()
with some keys removed--mode choose|include|exclude
into--tests choose|include|exclude
pkg/parsetoml
for metadata parsing--filepaths
,--metadata
: support exercise config containingcustom
key with the value of any valid JSON object--tests --foo
"custom": {}
configlet sync --filepaths -u
andconfiglet sync --metadata -u
preserve key orderfmt
codeFinal pass:
README.md
is up-to-date with the actualconfiglet -h
README.md
to describe the newsync
behaviornimpretty
proc
tofunc
where possibleconfiglet sync
on every trackFixes: #31
Closes: #298
After merging:
configlet fmt
?configlet fmt
configlet --help
message (I have an unpushed commit that adds a description to every command in the help message).exercism/problem-specifications
README.md
exercism/docs
Then things like:
--update --docs
--update --filepaths
--update --metadata
--tests -uy
message/interaction further?Option[foo]
- do we want to have an actual JSON parsing error for things likecontributors: null
, or e.g. silently replace it on updating?--update --exercise foo
: improve message consistency--update --yes
: put updated summary at the end?--filepaths
: warn for invalid placeholderswrite
procconfiglet sync --metadata -e lasagna
(can't sync docs/filepaths/tests for a Concept Exercise)--tests
usejsony
onlyvar
parameterstests.toml
in Nim track repo and bumping the Nim commit ref