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

Multi-year support? #22

Open
slyons opened this issue Dec 6, 2022 · 7 comments
Open

Multi-year support? #22

slyons opened this issue Dec 6, 2022 · 7 comments
Labels
enhancement New feature or request

Comments

@slyons
Copy link

slyons commented Dec 6, 2022

I see that year can be specified at the command line, but it doesn't seem like the code/inputs themselves are organized in any particular way to support different years.

Is there a way to accomplish catching up over a few years of missed AoC?

@fspoettel
Copy link
Owner

fspoettel commented Dec 6, 2022

There currently is no good way to do this from within a single repository created with this template. My approach has been to use one repo per year. The only thing that has to be set up again for the second repo is github action secrets for the star tracker. One advantage - for me - is that I can change the lib code between years w/o having to touch my older solutions. I concede that this approach is awkward if you want to cherry-pick problems from different years and not go through a single year in a linear fashion.

The reason this is difficult to implement is that we are using ./src/bin to skirt around having to deal with either a cargo workspace or the module system (more context here if interested) and src/bin does not allow nesting folders currently. Another problem is getting the star tracking to work in a multi-year context.

I'm leaving this issue open as it would be nice to support this, also to gauge interest. We may eventually get there if we end up switching to a different code layout for the template.

@fspoettel
Copy link
Owner

As part of #19, the manual --year flag will be replaced by an env flag in .cargo/config.toml:

[env]
AOC_YEAR = "2022"

this should make it a bit more convenient to use the template for solving past years.

@fspoettel fspoettel added the enhancement New feature or request label Oct 21, 2023
@AnthonyMichaelTDM
Copy link

One thing I did was rethink how solutions are organized entirely, basically treating each solution as its own separate project, this has the downside of making accurate benchmarks practically impossible (since "running a solution" involved executing the solution executable with a cli argument specifying what part to run (part one or two), any benchmarks will include all the overhead of executing the process through the languages build system), but allows us to use the same cli and repo for multiple languages (currently support rust, python, and zig) and years.

@AnthonyMichaelTDM
Copy link

Though now that I think about it, if the goal is just multi-year support you could just change the naming conventions of the solutions to include the year, and making some obvious adjustments to how inputs/puzzles/examples are handles in the data directory (put in folders by year)

the star tracker is a more complicated issue though.

@cozyGalvinism
Copy link

cozyGalvinism commented Dec 2, 2023

I pretty much created the repo from the template and then immediately set up a branch for 2023. You can make the GitHub stars action run on the specific year branch and that will only update that one branch. So far no downsides for me ^^ The only thing you need to adjust for is the Actions secret, but that could be easily factored out as well.

@asasine
Copy link

asasine commented May 17, 2024

I'd be interested in multi-year support, as I like to reuse and continually improve tools year over year. The module approach seems reasonable to me and I didn't find it too difficult to pick up when starting Rust. Modules can also map one-to-one to separate files, so for [Rust] beginners, it will feel quite similar to the current model in this template of one file to implement per day.

I think the approach also opens the door to separating the tooling in this repo into a separate crate such that people solving puzzles continue having two functions to implement in a file, just like it is now, but their repository instead pulls a dependency on this crate with a "magic" main.rs with a macro:

advent_of_code::main!()

It can then be integrated into any other crate if the developer so chooses, perhaps as a new binary or their crate's main binary. All of the tooling and well-crafted CLI of this crate is available, but still a ton of flexibility for how the rest of their personal AOC crate is structured.

@fspoettel
Copy link
Owner

the approach also opens the door to separating the tooling in this repo into a separate crate

FWIW there is cargo-aoc already which kinda works like this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

5 participants