175 lines
4.9 KiB
Markdown
175 lines
4.9 KiB
Markdown
# 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.
|
|
|
|
## Features
|
|
|
|
- **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
|
|
|
|
## Requirements
|
|
|
|
- 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
|
|
```
|
|
|
|
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.
|
|
|
|
## 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]
|
|
```
|
|
|
|
## Usage
|
|
|
|
### Run Once
|
|
|
|
To sync repositories and generate a report once:
|
|
|
|
```bash
|
|
python aocsync.py --once
|
|
```
|
|
|
|
### 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]
|