-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathconfig.py
More file actions
82 lines (68 loc) · 2.02 KB
/
config.py
File metadata and controls
82 lines (68 loc) · 2.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
from enum import Enum
from pathlib import Path
from typing import Any, Dict, List, Optional
import yaml
from pydantic import BaseModel, BaseSettings, SecretStr
def yaml_config_settings_source(settings: BaseSettings) -> Dict[str, Any]:
"""
A simple settings source that loads variables from a yaml file
"""
config_file: Path = settings.__config__.config.config_file
if config_file:
return yaml.full_load(config_file.read_text())
return {}
class RelabelType(str, Enum):
name = "name"
label = "label"
class Relabel(BaseModel):
label: str
type: RelabelType = RelabelType.label
description: Optional[str]
default: Optional[str] = None
values: List[str]
class ConfigFile(BaseSettings):
config_file: Optional[Path]
class Settings(BaseSettings):
job_relabelling: Optional[List[Relabel]] = []
job_costs: Optional[Dict[str, float]] = {
"ubuntu-latest": 0.008,
"ubuntu-22.04": 0.008,
"ubuntu-20.04": 0.008,
}
default_cost: Optional[float] = 0
branches: List[str] = ["main", "master"]
check_runs_enabled: bool = False
github_app_id: Optional[int]
github_app_installation_id: Optional[int]
github_app_private_key: Optional[SecretStr]
github_hosted_runner_labels: Optional[List[str]] = [
"ubuntu-latest",
"ubuntu-24.04",
"ubuntu-22.04",
"ubuntu-20.04",
"windows-latest",
"windows-2022",
"windows-2019",
"macos-latest",
"macos-14",
"macos-13",
"macos-12",
"macos-11"
]
class Config:
config: ConfigFile = ConfigFile()
env_file = ".env"
env_file_encoding = "utf-8"
@classmethod
def customise_sources(
cls,
init_settings,
env_settings,
file_secret_settings,
):
return (
init_settings,
yaml_config_settings_source,
env_settings,
file_secret_settings,
)