-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 37035cf
Showing
17 changed files
with
916 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
blank_issues_enabled: true | ||
contact_links: | ||
- name: Advent of CodSpeed Homepage | ||
url: 'https://codspeed.io/advent' | ||
about: Learn more about Advent of CodSpeed and how to participate | ||
- name: Support and questions | ||
url: 'https://discord.gg/p4jTaunHwA' | ||
about: Get help and discuss about Advent of CodSpeed on the CodSpeed Discord server |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
name: Add repository | ||
description: Add a new repository to the leaderboard | ||
title: "Add <repo_name> " | ||
labels: ["repo"] | ||
body: | ||
- type: markdown | ||
attributes: | ||
value: | | ||
Let's add your repository to the leaderboard! Please fill out the following information: | ||
- type: input | ||
id: repository_url | ||
attributes: | ||
label: Repository URL | ||
description: The url of the repository you want to add. Only public github repositories are supported at this time. You can only add your own repository. | ||
placeholder: https://github.com/<user>/<repo> | ||
validations: | ||
required: true | ||
- type: input | ||
id: crate | ||
attributes: | ||
label: Crate name | ||
description: If your repository is a workspace, please specify the crate you want to add. If your repository is not a workspace, please leave this blank. | ||
placeholder: "my_aoc_2024_crate" | ||
validations: | ||
required: false | ||
- type: input | ||
id: toolchain | ||
attributes: | ||
label: Toolchain version | ||
description: Which rust toolchain are you using? Will default to `stable`. This should comply with the [rust-toolchain](https://rust-lang.github.io/rustup/concepts/toolchains.html) format. | ||
placeholder: "stable" | ||
validations: | ||
required: false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
name: Add repository | ||
on: | ||
issues: | ||
types: | ||
- labeled | ||
concurrency: | ||
group: "repo-data" | ||
|
||
permissions: | ||
issues: write | ||
contents: write | ||
|
||
jobs: | ||
main: | ||
runs-on: ubuntu-latest | ||
if: ${{ github.event.label.name == 'repo' }} | ||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
ref: main | ||
fetch-depth: 0 | ||
- uses: astral-sh/setup-uv@v4 | ||
with: | ||
enable-cache: true | ||
cache-dependency-glob: "manager/uv.lock" | ||
- uses: actions/setup-python@v5 | ||
id: setup-python | ||
with: | ||
python-version: 3.13 | ||
|
||
- working-directory: manager | ||
run: uv sync | ||
|
||
- name: Handle the new repository | ||
working-directory: manager | ||
run: uv run python src/manager/handlers/add_repo.py ${{ github.event.issue.number }} | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,162 @@ | ||
# Byte-compiled / optimized / DLL files | ||
__pycache__/ | ||
*.py[cod] | ||
*$py.class | ||
|
||
# C extensions | ||
*.so | ||
|
||
# Distribution / packaging | ||
.Python | ||
build/ | ||
develop-eggs/ | ||
dist/ | ||
downloads/ | ||
eggs/ | ||
.eggs/ | ||
lib/ | ||
lib64/ | ||
parts/ | ||
sdist/ | ||
var/ | ||
wheels/ | ||
share/python-wheels/ | ||
*.egg-info/ | ||
.installed.cfg | ||
*.egg | ||
MANIFEST | ||
|
||
# PyInstaller | ||
# Usually these files are written by a python script from a template | ||
# before PyInstaller builds the exe, so as to inject date/other infos into it. | ||
*.manifest | ||
*.spec | ||
|
||
# Installer logs | ||
pip-log.txt | ||
pip-delete-this-directory.txt | ||
|
||
# Unit test / coverage reports | ||
htmlcov/ | ||
.tox/ | ||
.nox/ | ||
.coverage | ||
.coverage.* | ||
.cache | ||
nosetests.xml | ||
coverage.xml | ||
*.cover | ||
*.py,cover | ||
.hypothesis/ | ||
.pytest_cache/ | ||
cover/ | ||
|
||
# Translations | ||
*.mo | ||
*.pot | ||
|
||
# Django stuff: | ||
*.log | ||
local_settings.py | ||
db.sqlite3 | ||
db.sqlite3-journal | ||
|
||
# Flask stuff: | ||
instance/ | ||
.webassets-cache | ||
|
||
# Scrapy stuff: | ||
.scrapy | ||
|
||
# Sphinx documentation | ||
docs/_build/ | ||
|
||
# PyBuilder | ||
.pybuilder/ | ||
target/ | ||
|
||
# Jupyter Notebook | ||
.ipynb_checkpoints | ||
|
||
# IPython | ||
profile_default/ | ||
ipython_config.py | ||
|
||
# pyenv | ||
# For a library or package, you might want to ignore these files since the code is | ||
# intended to run in multiple environments; otherwise, check them in: | ||
# .python-version | ||
|
||
# pipenv | ||
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. | ||
# However, in case of collaboration, if having platform-specific dependencies or dependencies | ||
# having no cross-platform support, pipenv may install dependencies that don't work, or not | ||
# install all needed dependencies. | ||
#Pipfile.lock | ||
|
||
# poetry | ||
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control. | ||
# This is especially recommended for binary packages to ensure reproducibility, and is more | ||
# commonly ignored for libraries. | ||
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control | ||
#poetry.lock | ||
|
||
# pdm | ||
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control. | ||
#pdm.lock | ||
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it | ||
# in version control. | ||
# https://pdm.fming.dev/#use-with-ide | ||
.pdm.toml | ||
|
||
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm | ||
__pypackages__/ | ||
|
||
# Celery stuff | ||
celerybeat-schedule | ||
celerybeat.pid | ||
|
||
# SageMath parsed files | ||
*.sage.py | ||
|
||
# Environments | ||
.env | ||
.venv | ||
env/ | ||
venv/ | ||
ENV/ | ||
env.bak/ | ||
venv.bak/ | ||
|
||
# Spyder project settings | ||
.spyderproject | ||
.spyproject | ||
|
||
# Rope project settings | ||
.ropeproject | ||
|
||
# mkdocs documentation | ||
/site | ||
|
||
# mypy | ||
.mypy_cache/ | ||
.dmypy.json | ||
dmypy.json | ||
|
||
# Pyre type checker | ||
.pyre/ | ||
|
||
# pytype static type analyzer | ||
.pytype/ | ||
|
||
# Cython debug symbols | ||
cython_debug/ | ||
|
||
# PyCharm | ||
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can | ||
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore | ||
# and can be added to the global gitignore or merged into this file. For a more nuclear | ||
# option (not recommended) you can uncomment the following to ignore the entire idea folder. | ||
#.idea/ | ||
|
||
.python-version |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2024 CodSpeed Technology SAS | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<div align="center"> | ||
<img alt="Cover Image" src="./cover.png" width="100%"> | ||
<sub>A performance challenge based on the Advent of Code problems</sub> | ||
</div> | ||
|
||
<br /> | ||
|
||
Learn more about Advent of CodSpeed and how to participate on the [Advent of CodSpeed page](https://codspeed.io/advent/). | ||
|
||
> [!IMPORTANT] | ||
> Only Rust solutions are supported for now. Python and Node.js are planned in the future since it's already supported by [CodSpeed](https://codspeed.io). | ||
## Repository setup | ||
|
||
You need to expose a library that exposes a module for each day. In each module, you need to expose a `part1` and a `part2` function that takes a `&str` and returns an `impl Display`. | ||
|
||
More specifically, the following return types are allowed: | ||
|
||
- Integer types (`i32`, `i64`, `u32`, `u64`, `usize`, `isize`, etc.) | ||
- Floating-point types (`f32`, `f64`) | ||
- Single character (`char`) | ||
- String slice (`&str`) or `String` | ||
|
||
For example, to solve part 2 of day 5, we'll call: `crate::day5::part2(input)`. | ||
|
||
> [!NOTE] | ||
> Day numbers are not zero-padded. | ||
We follow the standard defined in [`cargo-aoc`](https://github.com/gobanos/cargo-aoc) for the project structure. See this [example repository](https://github.com/gobanos/advent-of-code-2015) for a reference. | ||
|
||
## Adding your solutions to the leaderboard | ||
|
||
Add your repository [here](https://github.com/CodSpeedHQ/Advent/issues/new?assignees=&labels=repo%2Cadd&projects=&template=new.yml&title=Add+%3Crepo_name%3E+). | ||
|
||
## Support | ||
|
||
Join us on [Discord](https://discord.gg/p4jTaunHwA) if you need help or want to contribute. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
[] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
[project] | ||
name = "manager" | ||
version = "0.0.0" | ||
requires-python = ">=3.13" | ||
dependencies = ["pydantic~=2.10.2", "GitPython~=3.1.43", "PyGithub~=2.5.0"] | ||
|
||
[project.optional-dependencies] | ||
dev = ["pytest~=8.3.3", "ruff~=0.8.1"] | ||
|
||
[build-system] | ||
requires = ["hatchling"] | ||
build-backend = "hatchling.build" |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
from github import Auth, Github | ||
import os | ||
|
||
auth = Auth.Token(os.environ["GITHUB_TOKEN"]) | ||
github_client = Github(auth=auth) | ||
REPO_NAME = "CodSpeedHQ/Advent" | ||
GITHUB_ADVENT_REPO = github_client.get_repo(REPO_NAME) |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import sys | ||
from manager.models import RepositoryModel | ||
from manager.repository_repository import RepositoryRepository | ||
from manager.github import GITHUB_ADVENT_REPO, github_client | ||
|
||
|
||
def main(issue_number: int): | ||
issue = GITHUB_ADVENT_REPO.get_issue(issue_number) | ||
issue_author = issue.user.login | ||
issue_body = issue.body | ||
repo = RepositoryModel.from_issue_body(issue_body) | ||
assert repo.owner == issue_author, "Repository must be owned by the issue author" | ||
if r := github_client.get_repo(f"{repo.owner}/{repo.name}").full_name is None: | ||
issue.create_comment(f"Failed to add repository: {r}") | ||
raise Exception(f"Failed to add repository {repo.owner}/{repo.name}: {r}") | ||
|
||
RepositoryRepository.save(repo) | ||
issue.create_comment("Repository added successfully! :tada:") | ||
issue.edit(state="closed") | ||
print(f"Repository added: {repo.owner}/{repo.name}") | ||
|
||
|
||
if __name__ == "__main__": | ||
issue_number = int(sys.argv[1]) | ||
main(issue_number) |
Oops, something went wrong.