Repository navigation
111 lines (91 loc) · 4.02 KB
/
Copy pathpython-schema-generation.yml
File metadata and controls
111 lines (91 loc) · 4.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
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
name: Python schema generation
# Rewrites src/bhom_schema from the C# oM, straight on develop. It is not a pull request: the C# is the source of truth, so a
# change in C# simply becomes a change in the Python. If any check fails, nothing is committed.
on:
schedule:
- cron: '0 4 * * 6' # Saturday at 4 AM UTC, after the BHoM_JSONSchema job (1 AM); the two are independent
workflow_dispatch:
inputs:
dry_run:
description: Generate and check, but do not commit
type: boolean
default: false
# Only one generation at a time
concurrency:
group: python-schema-generation
cancel-in-progress: false
# Raised for the commit step only
permissions:
contents: write
jobs:
generate:
runs-on: windows-latest
env:
PYTHONPATH: ${{ github.workspace }}/.ci/generation
steps:
- name: Checkout develop
uses: actions/checkout@v4
with:
ref: develop
fetch-depth: 0
- uses: actions/setup-dotnet@v4
with:
dotnet-version: '8.0.x'
- uses: microsoft/setup-msbuild@v2
- uses: NuGet/setup-nuget@v2
- uses: actions/setup-python@v5
with:
python-version: '3.12'
# BHoM, BHoM_Engine and JSONSchema_Toolkit give the generator what it references; CSharpSchema_Test holds the classes that are converted.
# They are cloned from GitHub (read only), never taken from a laptop, so the result does not depend on anybody's machine.
- name: Clone the repositories
shell: pwsh
run: ./.github/scripts/Clone-Repositories.ps1 -List Included-repositories.txt
- name: Build the repositories in dependency order
shell: pwsh
run: ./.github/scripts/Build-Repositories.ps1 -List Included-repositories.txt
- name: Build the generator
run: dotnet build .ci/generation/PythonSchemaGeneration/PythonSchemaGeneration.csproj -c Release --nologo
- name: Generate src/bhom_schema
shell: pwsh
run: |
$repos = (Get-Content Converted-repositories.txt | Where-Object { $_.Trim() -ne "" -and -not $_.StartsWith("#") } | ForEach-Object { $_.Trim() }) -join ","
Write-Host "Converting: $repos"
dotnet .ci/generation/PythonSchemaGeneration/bin/Release/net8.0/PythonSchemaGeneration.dll `
--output src/bhom_schema `
--repos $repos `
--manifest "$env:RUNNER_TEMP/manifest.json" `
--report "$env:RUNNER_TEMP/report.txt" `
--baseline-warnings .ci/generation/warnings-baseline.txt
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
- name: Install the Python tools
run: python -m pip install -e ".[dev]"
- name: Every module imports, and the Python reads back as the C# says
run: python -m py2cs verify --package src/bhom_schema --manifest "$env:RUNNER_TEMP/manifest.json"
- name: Pyright
run: python -m pyright
- name: Upload the generation report
uses: actions/upload-artifact@v4
with:
name: generation-report
path: |
${{ runner.temp }}/report.txt
${{ runner.temp }}/manifest.json
- name: Commit to develop
if: ${{ !inputs.dry_run }}
shell: pwsh
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
# Generated files are written with LF line endings; keep them as they are
git config core.autocrlf false
git add src/bhom_schema
git diff --cached --quiet
if ($LASTEXITCODE -eq 0) {
Write-Host "No changes: the Python already matches the C#."
exit 0
}
$commits = (Get-Content .repos/commits.txt | ForEach-Object { "- $_" }) -join "`n"
$runUrl = "$env:GITHUB_SERVER_URL/$env:GITHUB_REPOSITORY/actions/runs/$env:GITHUB_RUN_ID"
git commit -m "Generate bhom_schema from the C# oM" -m "Built from:`n$commits" -m "Workflow run: $runUrl"
git push origin HEAD:develop