Skip to content

Commit

Permalink
Add pipeline for pull requests (#67)
Browse files Browse the repository at this point in the history
* Add pipeline for pull requests

* Add pipeline for pull requests

* Add pipeline for pull requests

* Add assertion

* Fix type
  • Loading branch information
Kludex authored Jul 29, 2024
1 parent 4c7e2c5 commit d3101d8
Show file tree
Hide file tree
Showing 7 changed files with 41 additions and 31 deletions.
3 changes: 2 additions & 1 deletion .github/actions/awesome/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ runs:
using: composite
steps:
- name: Install requirements
run: python -m pip install -r ${{ github.action_path }}/requirements.txt
run: python -m pip install -r requirements.txt
shell: bash

- name: Load environment
Expand All @@ -37,6 +37,7 @@ runs:
shell: bash

- name: Commit README
if: github.ref == 'refs/heads/main'
run: |
git config --global user.name 'Github Actions'
git config --global user.email '41898282+github-actions[bot]@users.noreply.github.com'
Expand Down
27 changes: 14 additions & 13 deletions .github/actions/awesome/main.py
Original file line number Diff line number Diff line change
@@ -1,36 +1,36 @@
from __future__ import annotations

from itertools import groupby
import os
from typing import List, Optional
from typing import Any, List, Optional

import requests
import yaml
from github import Github
from jinja2.environment import Template
from pydantic import BaseModel, BaseSettings, HttpUrl
from pydantic import BaseModel, HttpUrl
from pydantic_settings import BaseSettings, SettingsConfigDict


class Settings(BaseSettings):
model_config = SettingsConfigDict(case_sensitive=False, env_file=".env")

template_path: str
output_path: str
data_path: str

github_token: str
gitlab_token: str

class Config:
case_sensitive = False
env_file = ".env"


settings = Settings()
settings = Settings() # type: ignore
g = Github(settings.github_token)


class Repository(BaseModel):
name: Optional[str]
name: str | None = None
repo: HttpUrl
description: Optional[str]
stars: Optional[int]
description: str | None = None
stars: int | None = None
category: str


Expand All @@ -44,7 +44,7 @@ def read_awesome() -> RepositoriesData:
return repos


def render_readme(data: dict) -> str:
def render_readme(data: dict[str, Any]) -> str:
with open(settings.template_path, "r") as readme_template:
template = Template(readme_template.read())
return template.render({"data": data})
Expand All @@ -68,6 +68,7 @@ def load_repo_data(data: RepositoriesData):
name = repository.repo.path.strip("/").replace("/", "%2F")
url = f"https://gitlab.com/api/v4/projects/{name}"
res = requests.get(url, params={"access_token": settings.gitlab_token})
assert "star_count" in res.json(), "Invalid GitLab repository"
star_count = res.json()["star_count"]
repository.stars = star_count
if not repository.name:
Expand All @@ -80,7 +81,7 @@ def load_repo_data(data: RepositoriesData):
def run():
awesome = read_awesome()
load_repo_data(awesome)
repos = awesome.dict()["repositories"]
repos = awesome.model_dump()["repositories"]
repos.sort(key=lambda x: x["category"])
data = {
category: sorted(repo, key=lambda x: -x["stars"])
Expand Down
4 changes: 0 additions & 4 deletions .github/actions/awesome/requirements.txt

This file was deleted.

6 changes: 6 additions & 0 deletions .github/workflows/render.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ on:
paths:
- ".github/actions"
- "awesome.yaml"
pull_request:
branches:
- "main"
paths:
- ".github/actions"
- "awesome.yaml"
workflow_dispatch:
schedule:
- cron: "0 0 * * FRI"
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.venv
.env
22 changes: 9 additions & 13 deletions awesome.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ repositories:

- name: Esmerald
repo: https://github.com/dymmond/esmerald
description: Full suite python web framework with results and design in mind based on Python type hints and pydantic.
description: Full suite python web framework with results and design in mind based on Python type hints and pydantic.
category: Web

- name: Django Ninja
Expand Down Expand Up @@ -125,7 +125,7 @@ repositories:
category: Utilities

- name: Quart-Schema
repo: https://gitlab.com/pgjones/quart-schema
repo: https://github.com/pgjones/quart-schema
description: Quart-Schema is a Quart extension that provides schema validation and auto-generated API documentation.
category: Web

Expand Down Expand Up @@ -183,12 +183,12 @@ repositories:
repo: https://github.com/surenkov/django-pydantic-field
description: Django JSONField with Pydantic models as a Schema. DRF supported.
category: Object Mapping

- name: pydantic-sqs
repo: https://github.com/andrewthetechie/pydantic-sqs
description: Send and receive pydantic models via AWS SQS
category: Object Mapping

- name: pydantic-enhanced-serializer
repo: https://github.com/adamsussman/pydantic-enhanced-serializer
description: Better pydantic object output for apis including selectable fields and smart object expansions.
Expand Down Expand Up @@ -224,10 +224,9 @@ repositories:
description: FastStream simplifies the process of writing producers and consumers for message queues, handling all the parsing, networking and documentation generation automatically.
category: Web


- name: DocArray
repo: https://github.com/docarray/docarray
description: Represent, send, store and search multimodal data based on Pydantic. Compatible with Multiple Vector Databases
description: Represent, send, store and search multimodal data based on Pydantic. Compatible with Multiple Vector Databases
category: Machine Learning

- name: BlackSheep
Expand All @@ -237,22 +236,19 @@ repositories:

- repo: https://github.com/jxnl/instructor
category: Machine Learning
# optional
name: Instructor
description: Controlling OpenAI Function Calling via Pydantic Models

- repo: https://github.com/opencubes-ai/laktory
category: Data Engineering
# optional
name: Laktory
description: A DataOps framework for building Databricks lakehouse.

- repo: https://github.com/okube-ai/settus
category: Utilities
# optional
name: Settus
description: Settings management using Pydantic Settings and extended to secrets from Azure Keyvault, Databricks secrets, AWS Secrets Manager and GCP Secrets Manager

- repo: https://github.com/allmonday/pydantic-resolve
category: Utilities
name: Pydantic-resolve
Expand All @@ -271,7 +267,7 @@ repositories:
- repo: https://github.com/Viicos/flake8-pydantic
category: Utilities
name: Flake8 Pydantic
description: A Flake8 plugin to check Pydantic related code.
description: A Flake8 plugin to check Pydantic related code.

- repo: https://github.com/Mirascope/mirascope
category: Machine Learning
Expand All @@ -284,6 +280,6 @@ repositories:
description: Pydantic-based HTTP forms

- repo: https://github.com//ManiMozaffar/aioclock
cateogry: Utilities
category: Utilities
name: AioClock
description: Scheduler framework asyncio-based designed for execution of periodic task with dependency injection
8 changes: 8 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
PyYAML==5.3.1
pydantic
pydantic-settings
Jinja2
PyGithub==1.55

# Lint
ruff

0 comments on commit d3101d8

Please sign in to comment.