Skip to content

Implement date-checker #1037

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 2 commits into from
Feb 4, 2021
Merged

Implement date-checker #1037

merged 2 commits into from
Feb 4, 2021

Conversation

camelid
Copy link
Member

@camelid camelid commented Jan 23, 2021

Closes #1018.

This tool looks for HTML comments like <!-- date: 2021-01 --> in each
Markdown source file and compiles a list of dates that are older than
six months. It then opens an issue with that list, with checkboxes for
each file and date. Note that it will only open an issue if there was at
least one date older than six months; it does nothing if the list is
empty.

This tool is automatically run monthly in a GitHub Actions workflow.
I have tested the tool on a private repo and confirmed that it works.

@camelid camelid added the S-waiting-on-review Status: this PR is waiting for a reviewer to verify its content label Jan 23, 2021
@camelid
Copy link
Member Author

camelid commented Jan 23, 2021

Should I add something to Travis CI that runs cargo test on this? It would be nice, but it might add a lot to CI times. Though it could run in parallel to the mdbook check.

@camelid
Copy link
Member Author

camelid commented Jan 23, 2021

Note to reviewers: You probably will want to review ci/date-check first, before reviewing the GitHub Actions workflow, since the workflow is a layer on top of ci/date-check.

@jyn514
Copy link
Member

jyn514 commented Jan 24, 2021

@rylev are you interested in reviewing this?

Copy link
Member

@rylev rylev left a comment

Choose a reason for hiding this comment

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

Looks good. I just have a few nits. Can we run this manually to confirm it works?

#[derive(Debug, Copy, Clone, PartialEq, Eq)]
struct Date {
year: u32,
month: u32,
Copy link
Member

Choose a reason for hiding this comment

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

I think we should limit this to u8 if not a custom enum for the specific twelve months. Incorrectly formatted dates will likely propagate pretty far into this and could be somewhat hard to debug. Might be best to try to catch them as early as possible.

Copy link
Member Author

Choose a reason for hiding this comment

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

I think we should limit this to u8

I tried that at first but it requires using TryInto because chrono uses u32.

if not a custom enum for the specific twelve months

That seems like unnecessary complexity to me. At some point it might be good to have a --validate mode that makes sure all the dates are valid (e.g. not in the future) and put that in CI, but I don't think we should do that here.

}

fn make_date_regex() -> Regex {
Regex::new(
Copy link
Member

Choose a reason for hiding this comment

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

Not sure if lazy_static would be one too many dependencies but it might make sense here.

Copy link
Member

Choose a reason for hiding this comment

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

I'd prefer to use once_cell, since it will soon be upstreamed into the standard library: rust-lang/rfcs#2788

Copy link
Member Author

Choose a reason for hiding this comment

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

Do you think it's okay to leave this as-is for now and we can always change it later? I would like to get this merged :)

@camelid
Copy link
Member Author

camelid commented Jan 26, 2021

Can we run this manually to confirm it works?

I tested this on a private repo and it seems to work. I had to manually trigger
it because it's not the first of the month so I wasn't able to test the cronjob.
However, it seems like it should work.

Copy link
Member

@rylev rylev left a comment

Choose a reason for hiding this comment

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

Awesome!

@LeSeulArtichaut
Copy link
Contributor

Is this ready to merge?

@camelid
Copy link
Member Author

camelid commented Feb 1, 2021

I think it's close, I personally am just waiting to hear back on #1037 (comment) :)

@camelid
Copy link
Member Author

camelid commented Feb 1, 2021

I would also like to manually squash my commits so all the date-checker stuff is in one and all the docs updates for date-check annotations are in another. So: please let me know before you merge and please if possible don't use "Squash and merge" :)

@camelid
Copy link
Member Author

camelid commented Feb 2, 2021

Next steps:

  1. Re-review by @rylev (or someone else)
  2. Squash commits (let me know and I'll do it)
  3. Merge!

Copy link
Member

@rylev rylev left a comment

Choose a reason for hiding this comment

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

Let's merge! We can always work on improvements as we start using this.

@camelid
Copy link
Member Author

camelid commented Feb 3, 2021

Okay, squashing now...

This tool looks for HTML comments like `<!-- date: 2021-01 -->` in each
Markdown source file and compiles a list of dates that are older than
six months. It then opens an issue with that list, with checkboxes for
each file and date. Note that it will only open an issue if there was at
least one date older than six months; it does nothing if the list is
empty.

This tool is automatically run monthly in a GitHub Actions workflow.
I have tested the tool on a private repo and confirmed that it works.
Also added dates for things that previously said "as of now" or "as of
this writing" and cleaned up a couple of things along the way.
@camelid
Copy link
Member Author

camelid commented Feb 3, 2021

@LeSeulArtichaut this should be ready now :)

Copy link
Member

@jyn514 jyn514 left a comment

Choose a reason for hiding this comment

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

I haven't read through this, but approving because I trust @rylev's judgement and we can always revert if we need to.

@jyn514 jyn514 merged commit 5e57035 into rust-lang:master Feb 4, 2021
@camelid camelid deleted the date-check branch February 4, 2021 02:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-review Status: this PR is waiting for a reviewer to verify its content
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add machine-readable dates to keep docs up-to-date
4 participants