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 Suppport via Workspaces #78

Open
wants to merge 8 commits into
base: main
Choose a base branch
from

Conversation

PaulTreitel
Copy link

I wanted to put my solutions from 2022 into the same repository as this year so I adapted the repository to be able to include both. It's clear by #22 and #77 that I'm not alone. I was surprised to come back over here and see #77 so recently added but I think this is a much more elegant and general solution. If you want to see it in action, take a look at my AOC repo.

Each year lives in its own ./<year>/ subdirectory. They're different packages specified in ./Cargo.toml as members in a workspace since was how I could get cargo to not freak out about the code structure. Running things within the ./<year>/ directory is the same as before since it's a separate package. For running things in the repository root directory, I've reworked the ,/src/template/ code use the AOC_YEAR environment variable to determine what year to run commands as. To that end I've added new cargo aliases for get-year and set-year which check and set this variable.

Most of the "new" stuff in the PR is actually just a slightly modified version of the existing repository. In order to set up a new year, there's a directory ./year_template/ which just contains the repository files with the year numbers shaved off. To that end, I also added a cargo alias new-year for use in the repository root directory. This command (1) copies the contents of ./year_template/ into a folder for the new year, (2) swaps the year numbers, (3) runs the set-year command, and (4) adds the new year as a workspace member to ./Cargo.toml.

Testing code with this new framework got annoying so I also added a cargo alias try specifically for that.

The Downsides:

  • Continuous Integration breaks because the solution code is no longer in the cargo project located at the repository root (nor is it necessarily even in a single project).
  • Switching years changes ./.cargo/config.toml. I have no idea how this interacts with the repository secrets, star tracker, benchmarking table, etc if at all since I don't use those features.

I don't know if this is the direction we might want to go with this repository but if nothing else there are some pieces of this like the try command that could be useful.

@FXCourel FXCourel mentioned this pull request Dec 16, 2024
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.

1 participant