Skip to content

Commit b598da5

Browse files
committed
Setup for 2025
1 parent 268baca commit b598da5

File tree

4 files changed

+41
-22
lines changed

4 files changed

+41
-22
lines changed

.github/workflows/action-aoc-badges.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,14 @@ jobs:
77
steps:
88
- uses: actions/checkout@v2 # clones your repo
99

10+
- uses: joblo2213/aoc-badges-action@v3
11+
with:
12+
userid: ${{ secrets.AOC_USER_ID }} # your user id, see setup on how to obtain
13+
session: ${{ secrets.AOC_SESSION }} # secret containing session code, see setup on how to obtain
14+
year: 2024
15+
starsRegex: '(?<=https:\/\/img\.shields\.io\/badge\/2024%20stars%20⭐-)[0-9]+(?=-yellow)' # Regular expression that finds the content of the stars badge in your file.
16+
daysCompletedRegex: '(?<=https:\/\/img\.shields\.io\/badge\/2024%20days%20completed-)[0-9]+(?=-red)' # Regular expression that finds the content of the days completed badge iun your file.
17+
1018
- uses: joblo2213/aoc-badges-action@v3
1119
with:
1220
userid: ${{ secrets.AOC_USER_ID }} # your user id, see setup on how to obtain

.github/workflows/action-aoc-badges-2024.yml renamed to .github/workflows/action-aoc-badges_2025.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Update AoC Badges 2024
1+
name: Update AoC Badges 2025
22
on:
33
schedule: # run workflow based on schedule
44
- cron: '6 5 1-25 12 *' # from the 1. December till 25. December every day at 5:06am (avoid load at full hours)
@@ -18,7 +18,7 @@ jobs:
1818
with:
1919
userid: ${{ secrets.AOC_USER_ID }} # your user id, see setup on how to obtain
2020
session: ${{ secrets.AOC_SESSION }} # secret containing session code, see setup on how to obtain
21-
year: 2024
21+
year: 2025
2222

2323
# Optional inputs:
2424
#

README.md

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,19 @@
11
[Advent of Code](https://adventofcode.com)
22

3+
## 2025
4+
5+
![](https://img.shields.io/badge/stars%20⭐-0-yellow)
6+
![](https://img.shields.io/badge/days%20completed-0-red)
7+
8+
<!-- @BEGIN:ImplementationsTable:2025@ -->
9+
| | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 |
10+
| ---| --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- |
11+
<!-- @END:ImplementationsTable:2025@ -->
12+
313
## 2024
414

5-
![](https://img.shields.io/badge/stars%20⭐-50-yellow)
6-
![](https://img.shields.io/badge/days%20completed-25-red)
15+
![](https://img.shields.io/badge/2024%20stars%20⭐-50-yellow)
16+
![](https://img.shields.io/badge/2024%20days%20completed-25-red)
717

818
![2024 Calendar](doc/aoc2024.jpg "2024 Calendar")
919

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
#! /usr/bin/env python3
22

33
import logging
4-
import os
54
import sys
65
from datetime import datetime
6+
from pathlib import Path
77
from typing import IO
88

99
if __name__ == "__main__":
@@ -14,31 +14,33 @@
1414
from aoc.implementation_tables.config import config
1515

1616
log = logging.getLogger(__name__)
17+
logging.basicConfig(format="%(message)s", level=logging.INFO)
1718

1819

1920
def _build_link(base_dir: str, pattern: str, year: int, day: int) -> str:
20-
path = base_dir + "/" + pattern.format(year=year, day=day)
21-
return f"[✓]({path})" if os.path.exists(path) else ""
21+
path = Path(base_dir) / pattern.format(year=year, day=day)
22+
return f"[✓]({path})" if path.exists() else ""
2223

2324

2425
def _build_row(days: list[str]) -> str:
2526
return "| " + " | ".join(days) + " |"
2627

2728

2829
def _print_year(year: int, rows: list[Row], f: IO[str]) -> None:
29-
log.debug(f"Adding {year}")
30-
print("| " + _build_row([str(day) for day in range(1, 26)]), file=f)
31-
print("| ---" + _build_row(["---" for day in range(1, 26)]), file=f)
30+
log.debug("Adding %s", year)
31+
days = 12 if year >= 2025 else 25
32+
print("| " + _build_row([str(day) for day in range(1, days + 1)]), file=f)
33+
print("| ---" + _build_row(["---" for day in range(1, days + 1)]), file=f)
3234
for row in rows:
33-
log.debug(f"Adding {row.language}")
34-
days = [
35+
log.debug("Adding %s", row.language)
36+
day_links = [
3537
_build_link(row.base_dir, row.pattern + row.ext, year, day)
36-
for day in range(1, 26)
38+
for day in range(1, days + 1)
3739
]
38-
if len("".join(days)) == 0:
40+
if len("".join(day_links)) == 0:
3941
continue
4042
print(
41-
"| " + row.language + " " + _build_row(days),
43+
"| " + row.language + " " + _build_row(day_links),
4244
file=f,
4345
)
4446

@@ -50,11 +52,11 @@ def _get_rows() -> list[Row]:
5052

5153

5254
def main(file_name: str) -> None:
53-
log.debug(f"file: {file_name}")
55+
log.debug("file: %s", file_name)
5456
rows = _get_rows()
55-
with open(file_name, "r", encoding="utf-8") as f:
57+
with Path(file_name).open("r", encoding="utf-8") as f:
5658
tmp = f.read()
57-
with open(file_name, "w", encoding="utf-8") as f:
59+
with Path(file_name).open("w", encoding="utf-8") as f:
5860
in_table = False
5961
for line in tmp.splitlines():
6062
if line.startswith("<!-- @BEGIN:ImplementationsTable"):
@@ -65,13 +67,12 @@ def main(file_name: str) -> None:
6567
elif line.startswith("<!-- @END:ImplementationsTable"):
6668
print(line, file=f)
6769
in_table = False
68-
else:
69-
if not in_table:
70-
print(line, file=f)
70+
elif not in_table:
71+
print(line, file=f)
7172

7273

7374
if __name__ == "__main__":
74-
now = datetime.now()
75+
now = datetime.now() # noqa:DTZ005
7576
for year in range(2015, now.year + int(now.month == 12)):
7677
_print_year(year, _get_rows(), sys.stdout)
7778
main("README.md")

0 commit comments

Comments
 (0)