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

feat: add config file support #152

Merged
merged 2 commits into from
Jan 15, 2025
Merged

feat: add config file support #152

merged 2 commits into from
Jan 15, 2025

Conversation

camshaft
Copy link
Member

@camshaft camshaft commented Jan 10, 2025

Description of changes:

This change adds support for config files for configuring duvet, rather than CLI arguments. This should standardize how customers set up their repositories/reports and avoid having one-off scripts everywhere:

The config location is .duvet/config.toml. All of the artifacts and toml files are stored alongside in .duvet/. I've included a config file for the duvet repo itself:

'$schema' = "https://awslabs.github.io/duvet/config/v0.4.0.json"

[[source]]
pattern = "duvet/**/*.rs"

[report.html]
enabled = true
issue-link = "https://github.com/awslabs/duvet/issues"
blob-link = "https://github.com/awslabs/duvet/blob/${{ GITHUB_SHA || 'main' }}"

[report.json]
enabled = true

With a config file, generating a report no longer requires any arguments:

$ duvet report

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@camshaft camshaft force-pushed the camshaft/config branch 2 times, most recently from cc8860c to dd82840 Compare January 11, 2025 00:34
@camshaft camshaft force-pushed the camshaft/config branch 2 times, most recently from 1e88799 to a99b203 Compare January 15, 2025 00:32
@camshaft camshaft marked this pull request as ready for review January 15, 2025 00:45
@camshaft camshaft requested a review from a team as a code owner January 15, 2025 00:45
@@ -0,0 +1,12 @@
'$schema' = "https://awslabs.github.io/duvet/config/v0.4.0.json"
Copy link
Contributor

Choose a reason for hiding this comment

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

what's going on with this syntax? '$schema'

Copy link
Member Author

@camshaft camshaft Jan 15, 2025

Choose a reason for hiding this comment

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

There's three reasons for it:

  • I want config files to be versioned so we can make changes to the format over time and preserve support for older ones. I could have gone with version instead but, then that leads to the second point.
  • This syntax is taken from JSON schema, where you can have your editor validate that your schema conforms to what we define. By using $schema, editors automatically download that URL and perform validation (see https://taplo.tamasfe.dev/configuration/using-schemas.html). It's not the nicest thing to look at... But it makes it so we don't have to register the schema anywhere and can just self host.
  • Unfortunately, toml doesn't allow keys to start with a $... So you have to quote it. Which is annoying. But I think the two previous points justify it?

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks for the explanation!

"type": "string"
}
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

should these have a newline at the end?

Copy link
Member Author

Choose a reason for hiding this comment

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

It should be ok without it. These are auto-generated and really only consumed by programs. But I can add one of you feel strongly about it.

Copy link
Contributor

Choose a reason for hiding this comment

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

I dont feel very strongly, its more just the way GitHub highlights it that bothers me :-)

duvet-core/src/artifact.rs Outdated Show resolved Hide resolved
Comment on lines +57 to +59
".duvet/requirements/**/*.toml",
".duvet/todos/**/*.toml",
".duvet/exceptions/**/*.toml",
Copy link
Contributor

Choose a reason for hiding this comment

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

any docs this should be mentioned in so the user knows they don't need to add these?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah I will add that in the guide

@@ -139,17 +193,17 @@ fn extract_section(section: &Section) -> (&Section, Vec<Feature>) {

if KEY_WORDS_SET.is_match(line) {
for (key_word, level) in KEY_WORDS.iter() {
for occurance in key_word.find_iter(line) {
for occurrence in key_word.find_iter(line) {
Copy link
Contributor

Choose a reason for hiding this comment

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

guess we need to add the typo check to CI

Copy link
Member Author

@camshaft camshaft Jan 15, 2025

Choose a reason for hiding this comment

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

Haha yep. I added it to my editor and found a few issues 😁

Co-authored-by: Wesley Rosenblum <[email protected]>
@camshaft camshaft merged commit 5afd2c2 into main Jan 15, 2025
13 checks passed
@camshaft camshaft deleted the camshaft/config branch January 15, 2025 19:26
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.

2 participants