-
Notifications
You must be signed in to change notification settings - Fork 0
116 lines (102 loc) · 3.65 KB
/
documentation_auto_gen.yml
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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
name: Autogeneration
on:
pull_request:
types: [opened, reopened, synchronize, ready_for_review, converted_to_draft]
jobs:
get-discovery-schemas:
name: Get Discovery Schemas
runs-on: ubuntu-latest
outputs:
schemas: ${{ steps.set-matrix.outputs.matrix }}
steps:
- name: Checkout and Cache
uses: actions/checkout@v4
- id: cache
uses: actions/cache/save@v4
with:
path: .
key: ${{ github.workflow }}-${{ github.repository.event.number }}-clone-${{ hashFiles('**/lockfiles') }}
- name: Set Matrix
id: set-matrix
run: echo "matrix=$(ls schemas/discovery/*.json | jq -R -s -c 'split("\n")[:-1]')" >> $GITHUB_OUTPUT
validation:
name: Validate Discovery Schemas
runs-on: ubuntu-latest
timeout-minutes: 1
needs: get-discovery-schemas
if: ${{ needs.get-discovery-schemas.outputs.schemas != '[]' }}
strategy:
matrix:
schemas: ${{ fromJson(needs.get-discovery-schemas.outputs.schemas) }}
steps:
- uses: actions/cache/restore@v4
with:
path: .
key: ${{ github.workflow }}-${{ github.repository.event.number }}-clone
- name: Setup Python
uses: actions/setup-python@v5
with:
cache: 'pip'
python-version: '3.12'
- name: Install Packages
env:
PIP_DISABLE_PIP_VERSION_CHECK: "1"
PIP_DEFAULT_TIMEOUT: "100"
PYTHONDONTWRITEBYTECODE: "1"
PYTHONUNBUFFERED: "1"
run: pip install -r tools/schemas/validation/requirements.txt
- name: Validate Discovery Schemas
run: python3 tools/schemas/validation/main.py ${{ matrix.schemas }} schemas/definitions/discovery.schema.json
generate-docs:
name: Generate Docs
runs-on: ubuntu-latest
timeout-minutes: 1
needs: [ validation, get-discovery-schemas ]
if: ${{ needs.get-discovery-schemas.outputs.schemas != '[]' }}
strategy:
matrix:
schemas: ${{ fromJson(needs.get-discovery-schemas.outputs.schemas) }}
steps:
- uses: actions/cache/restore@v4
with:
path: .
key: ${{ github.workflow }}-${{ github.repository.event.number }}-clone
- name: Setup Python
uses: actions/setup-python@v5
with:
cache: 'pip'
python-version: '3.12'
- name: Install Packages
env:
PIP_DISABLE_PIP_VERSION_CHECK: "1"
PIP_DEFAULT_TIMEOUT: "100"
PYTHONDONTWRITEBYTECODE: "1"
PYTHONUNBUFFERED: "1"
run: pip install -r tools/autogen/docs/requirements.txt
- name: Generate Docs
run: |
output_path=$(echo "${{ matrix.schemas }}" | sed 's|.*/\(.*\)\.schema\.json|docs/schemas/\1.md|')
python3 tools/autogen/docs/main.py ${{ matrix.schemas }} $output_path
generate-dataclasses:
name: Generate Python DataClasses
runs-on: ubuntu-latest
timeout-minutes: 1
needs: [ validation, get-discovery-schemas ]
if: ${{ needs.get-discovery-schemas.outputs.schemas != '[]' }}
strategy:
matrix:
schemas: ${{ fromJson(needs.get-discovery-schemas.outputs.schemas) }}
steps:
- uses: actions/cache/restore@v4
with:
path: .
key: ${{ github.workflow }}-${{ github.repository.event.number }}-clone
- name: Setup Python
uses: actions/setup-python@v5
with:
cache: 'pip'
python-version: '3.12'
- name: Generate Python DataClasses
run: |
output_path=$(echo "${{ matrix.schemas }}" | sed 's|.*/\(.*\)\.schema\.json|types/python/schemas/\1.py|')
./main.sh python3 ${{ matrix.schemas }} $output_path