Compare commits
20 Commits
cb62961be0
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
| 7c4cf65996 | |||
| 0c7e1e0ba4 | |||
| 3b8db3e80f | |||
| fe6716b468 | |||
| 24b343d3f8 | |||
| 266558bb15 | |||
| c25f1daf76 | |||
| 496c403ec1 | |||
| 5cc1460a3e | |||
| c604da12c7 | |||
| dde52bb9db | |||
| 171fdb4329 | |||
| c851648166 | |||
| 4ac729fd82 | |||
| cdc2ecb195 | |||
| cb0dc0d879 | |||
| 91d5db6453 | |||
| 492d06b0d6 | |||
| 88ec3631ab | |||
| 8b229237c9 |
11
Dockerfile
Normal file
11
Dockerfile
Normal 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
173
README.md
@@ -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]
|
||||
|
||||
1158
aocsync.py
1158
aocsync.py
File diff suppressed because it is too large
Load Diff
25
config.yaml
25
config.yaml
@@ -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"
|
||||
|
||||
@@ -1 +1,2 @@
|
||||
PyYAML>=6.0
|
||||
Flask>=2.0.0
|
||||
|
||||
Reference in New Issue
Block a user