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

Create script to be used by GitHub actions #2

Open
brendanator opened this issue Jan 1, 2025 · 0 comments
Open

Create script to be used by GitHub actions #2

brendanator opened this issue Jan 1, 2025 · 0 comments

Comments

@brendanator
Copy link
Contributor

  • Create advent_of_code.py script using typer
  • Commands
    • uv run advent_of_code.py download {year} {day}
    • uv run advent_of_code.py read {year} {day}
    • uv run advent_of_code.py submit {year} {day} {part}
    • uv run advent_of_code.py update-results {year}
  • uv run advent_of_code.py download {year} {day}
    • fetches https://adventofcode.com/{year}/day/{day} using httpx
    • Use the AOC_SESSION env var for cookie auth. Headers:
      • Cookie: session={AOC_SESSION}
      • User-Agent: github.com/sourcery-ai/autonomous-advent-of-code
    • uses beautifulsoup and markdownify to extract the question and convert to markdown
    • if the question contains the title "Part Two" it is part 2, otherwise part 1
    • rot13 encodes the question
    • writes files:
      • puzzles/year_2023/day_03/question_part{part}_rot13.md - include both parts in part2
      • puzzles/year_2023/day_03/input.txt
    • print to stdout 2 if part two was found else 1
  • uv run advent_of_code.py read {year} {day} {part}
    • read file puzzles/year_{year}/day_{day}/question_part{part}_rot13.md
    • rot13 decodes the puzzle
    • prints the result
  • uv run advent_of_code.py submit {year} {day} {part}
    • read file puzzles/year_{year}/day_{day}/answer_part{part}.txt
    • submits a solution to - https://adventofcode.com/{year}/day/{day}/answer using httpx and AOC_SESSION auth
    • Parses the response into markdown
    • Writes the markdown to file puzzles/year_{year}/day_{day}/result_part{part}.md
    • Prints the markdown
    • if the markdown contains "That's the right answer"
      • then return exit code 0
      • else return exit code 1
  • uv run advent_of_code.py update-results {year}
    • Calculate the results for each day in the year
      • Reads the answer and results files for each part in puzzles/year_{year}/day_{day}
        if they exist
      • Outputs the state for each day and part:
        • NOT_SUBMITTED
        • INCORRECT
        • CORRECT
    • Updates the results table in README.md
      • The results table will be contained within html comments:
      • Columns: Day, Part 1, Part 2
      • Include all day up to the latest day with results
      • For each part:
        • NOT_SUBMITTED -> blank
        • INCORRECT -> ❌
        • NOT_SUBMITTED -> ✅
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

No branches or pull requests

1 participant