Compare commits

...

23 Commits

Author SHA1 Message Date
7c4cf65996 Add akramer 2025 2025-12-14 20:50:35 -08:00
0c7e1e0ba4 Record part 1 even if part 2 panics 2025-12-12 10:42:33 -08:00
3b8db3e80f Add nightly toolchain for glenng 2025-12-12 10:34:48 -08:00
fe6716b468 Use glenng's cargo-aoc with bench --quick 2025-12-08 14:31:40 -08:00
24b343d3f8 Add check now button 2025-12-06 17:22:19 -08:00
266558bb15 Add status webapp 2025-12-06 10:45:42 -08:00
c25f1daf76 Add missing dockerfile for cargo-aoc runtime env 2025-12-06 10:45:28 -08:00
496c403ec1 Add link to puzzle on adventofcode.com 2025-12-06 10:36:40 -08:00
5cc1460a3e Hide unnecessary text in summary table 2025-12-04 18:47:21 -08:00
c604da12c7 Show completed parts 2025-12-04 18:46:44 -08:00
dde52bb9db Collapse bytes output table 2025-12-04 18:44:28 -08:00
171fdb4329 Show bytes output counters 2025-12-04 17:23:44 -08:00
c851648166 Fix crate building under podman 2025-12-04 17:09:48 -08:00
4ac729fd82 Set cargo env vars to use configured build and repo paths 2025-12-04 17:00:04 -08:00
cdc2ecb195 Automatically build custom image w/ cargo-aoc and allow networking 2025-12-04 16:55:48 -08:00
cb0dc0d879 Use custom image w/ cargo-aoc 2025-12-04 16:52:06 -08:00
91d5db6453 Use podman instead of docker 2025-12-04 16:51:02 -08:00
492d06b0d6 Add ability to run cargo aoc under docker 2025-12-04 16:49:51 -08:00
88ec3631ab Only rerun for years that have changed 2025-12-04 16:43:47 -08:00
8b229237c9 Make sure history graph fits in modal 2025-12-04 16:39:55 -08:00
cb62961be0 Remove colors from log capture, and reset log every run 2025-12-04 10:45:36 -08:00
e800d681ae Capture logs 2025-12-04 10:21:29 -08:00
09dabcab66 Auto refresh page 2025-12-04 10:18:08 -08:00
5 changed files with 1217 additions and 231 deletions

11
Dockerfile Normal file
View File

@@ -0,0 +1,11 @@
FROM rust:latest
# Install Rust nightly toolchain
RUN rustup toolchain install nightly && \
rustup default nightly
# Install cargo-aoc from specific GitHub repository
RUN cargo install --git https://github.com/ggriffiniii/cargo-aoc cargo-aoc
# Set working directory
WORKDIR /workspace

173
README.md
View File

@@ -1,174 +1,33 @@
# AOC Sync
A Python script that polls multiple git repositories containing Advent of Code implementations written in Rust using `cargo-aoc` format. It automatically updates repositories when changes are detected, runs benchmarks, and generates a beautiful HTML comparison page showing performance metrics across users, years, and days.
A tool to poll multiple git repositories containing Advent of Code implementations and generate performance comparison reports.
## Features
## Building the Podman Image
- **Automatic Git Polling**: Monitors multiple repositories for changes
- **Flexible Repository Structure**: Supports both single-repo (all years) and multi-repo (one per year) configurations
- **Automatic Runtime Measurement**: Runs `cargo aoc` for all implemented days and parses runtime information
- **Performance Parsing**: Extracts timing data from cargo-aoc output
- **Data Storage**: SQLite database for historical performance data
- **HTML Reports**: Beautiful, responsive HTML comparison pages
- **Gap Handling**: Gracefully handles missing years, days, and parts
- **Configurable Comparisons**: Filter by specific years and days
The default configuration uses a custom Podman image (`aocsync:latest`) that has `cargo-aoc` pre-installed for faster execution.
## Requirements
To build the image:
- Python 3.7+
- Git
- Rust and Cargo
- `cargo-aoc` installed (install with `cargo install cargo-aoc`)
## Installation
1. Clone this repository:
```bash
git clone <repository-url>
cd aocsync
podman build -t aocsync:latest -f Dockerfile .
```
2. Install Python dependencies:
```bash
pip install -r requirements.txt
```
3. Ensure `cargo-aoc` is installed:
```bash
cargo install cargo-aoc
```
Note: The script runs `cargo aoc` (not `cargo aoc bench`) and parses runtime information from the output.
Alternatively, you can use the `rust:latest` image, but it will install `cargo-aoc` on each run (slower).
## Configuration
Edit `config.yaml` to configure repositories to monitor:
```yaml
# Poll interval in seconds
poll_interval: 300
# Output directory for generated HTML
output_dir: "output"
# Data storage directory
data_dir: "data"
# Repositories to monitor
repositories:
# Single repository with all years
- name: "user1"
url: "https://github.com/user1/advent-of-code"
type: "single"
local_path: "repos/user1"
# Multiple repositories, one per year
- name: "user2"
type: "multi-year"
years:
- year: 2023
url: "https://github.com/user2/aoc-2023"
local_path: "repos/user2-2023"
- year: 2024
url: "https://github.com/user2/aoc-2024"
local_path: "repos/user2-2024"
# Optional: Filter specific years to compare
compare_years: [2023, 2024]
# Optional: Filter specific days to compare
# compare_days: [1, 2, 3, 4, 5]
```
See `config.yaml` for configuration options, including:
- Repository URLs and paths
- Docker/Podman container settings
- Build and registry cache directories
- Resource limits
## Usage
### Run Once
To sync repositories and generate a report once:
```bash
python aocsync.py --once
# Run sync (only processes changed repositories)
python3 aocsync.py
# Force rerun all benchmarks
python3 aocsync.py --force
```
### Force Rerun All Days
To force rerun all days even if repositories haven't changed:
```bash
python aocsync.py --once --force
```
or
```bash
python aocsync.py --once --rerun-all
```
This is useful for refreshing all data or testing changes to the script.
### Continuous Polling
To continuously poll repositories (default):
```bash
python aocsync.py
```
Or with a custom config file:
```bash
python aocsync.py --config myconfig.yaml
```
## Output
- **Database**: Performance data is stored in `data/results.db` (SQLite)
- **HTML Report**: Generated at `output/index.html` (configurable via `output_dir`)
The HTML report includes:
- Performance comparison tables for each year/day/part
- Visual highlighting of fastest and slowest implementations
- Relative speed comparisons (X times faster/slower)
- Responsive design for viewing on any device
## How It Works
1. **Git Polling**: Checks each configured repository for changes by comparing local and remote commits
2. **Repository Update**: Clones new repositories or updates existing ones when changes are detected
3. **Day Detection**: Automatically finds implemented days by scanning for `day*.rs` files and Cargo.toml entries
4. **Runtime Measurement**: Runs `cargo aoc --day X` for each implemented day
5. **Parsing**: Extracts timing data from cargo-aoc output (handles nanoseconds, microseconds, milliseconds, seconds)
6. **Storage**: Stores results in SQLite database with timestamps
7. **Report Generation**: Generates HTML comparison page showing latest results
## Repository Structure Detection
The script automatically detects:
- **Year**: From repository path, name, or Cargo.toml
- **Days**: From `src/bin/day*.rs`, `src/day*.rs`, or Cargo.toml entries
- **Parts**: From cargo-aoc benchmark output (Part 1, Part 2)
## Troubleshooting
### Cargo-aoc not found
Ensure `cargo-aoc` is installed and in your PATH:
```bash
cargo install cargo-aoc
```
### Git authentication issues
For private repositories, ensure your git credentials are configured or use SSH URLs.
### Benchmark timeouts
If benchmarks take too long, the script has a 5-minute timeout per day. Adjust in the code if needed.
### Missing performance data
If some users/days/parts don't show up:
- Check that `cargo aoc --day X` runs successfully in the repository
- Verify the repository structure matches cargo-aoc conventions
- Ensure `cargo aoc` outputs timing information (check if it's configured to show runtime)
- Check logs for parsing errors
## License
[Your License Here]

1238
aocsync.py

File diff suppressed because it is too large Load Diff

View File

@@ -13,6 +13,25 @@ rsync:
enabled: true
destination: "xinu.tv:/var/www/static/aoc/"
# Podman container configuration for running cargo aoc
docker:
# Persistent directory for cargo build artifacts (speeds up rebuilds)
# If not specified, uses temporary directory that's cleaned up after each run
build_cache_dir: "/tmp/aocsync/build_cache_dir"
# Persistent directory for cargo registry cache (downloaded dependencies)
# If not specified, uses tmpfs that's cleared after each run
registry_cache_dir: "/tmp/aocsync/registry_cache_dir"
# Container resource limits
memory: "2g" # Memory limit
cpus: "2" # CPU limit
# Podman image to use (should have cargo-aoc installed)
# Default: "aocsync:latest" (build with: podman build -t aocsync:latest -f Dockerfile .)
# Alternative: "rust:latest" (will install cargo-aoc on first run, slower)
image: "aocsync:latest"
# Repositories to monitor
repositories:
# Example: Single repository with all years
@@ -42,6 +61,12 @@ repositories:
#- year: 2024
# url: "https://github.com/user2/aoc-2024"
# local_path: "repos/user2-2024"
- name: "akramer"
type: "multi-year" # one repo per year
years:
- year: 2025
url: "https://github.com/akramer/aoc2025"
local_path: "repos/akramer-2025"
# Didn't use cargo aoc
# - name: "akramer"

View File

@@ -1 +1,2 @@
PyYAML>=6.0
Flask>=2.0.0