1
+ name : Generate Model Configuration
2
+
3
+ on :
4
+ push :
5
+ branches : [ main ]
6
+ paths :
7
+ - ' src/emd/models/**'
8
+ - ' tests/generate_model_config.py'
9
+ pull_request :
10
+ branches : [ main ]
11
+ paths :
12
+ - ' src/emd/models/**'
13
+ - ' tests/generate_model_config.py'
14
+ workflow_dispatch : # Allow manual trigger
15
+
16
+ jobs :
17
+ generate-config :
18
+ runs-on : ubuntu-latest
19
+
20
+ steps :
21
+ - name : Checkout repository
22
+ uses : actions/checkout@v4
23
+ with :
24
+ fetch-depth : 0
25
+
26
+ - name : Set up Python
27
+ uses : actions/setup-python@v4
28
+ with :
29
+ python-version : ' 3.9'
30
+
31
+ - name : Cache pip dependencies
32
+ uses : actions/cache@v3
33
+ with :
34
+ path : ~/.cache/pip
35
+ key : ${{ runner.os }}-pip-${{ hashFiles('**/requirements*.txt', '**/pyproject.toml') }}
36
+ restore-keys : |
37
+ ${{ runner.os }}-pip-
38
+
39
+ - name : Install dependencies
40
+ run : |
41
+ python -m pip install --upgrade pip
42
+ # Install from pyproject.toml if it exists
43
+ if [ -f pyproject.toml ]; then
44
+ pip install -e .
45
+ elif [ -f requirements.txt ]; then
46
+ pip install -r requirements.txt
47
+ fi
48
+ # Install additional dependencies that might be needed
49
+ pip install pathlib datetime
50
+
51
+ - name : Create docs directory
52
+ run : |
53
+ mkdir -p docs
54
+
55
+ - name : Run model configuration generator
56
+ run : |
57
+ cd ${{ github.workspace }}
58
+ python tests/generate_model_config.py
59
+ env :
60
+ PYTHONPATH : ${{ github.workspace }}/src
61
+
62
+ - name : Check if model config was generated
63
+ run : |
64
+ if [ -f docs/model_config.js ]; then
65
+ echo "✅ Model configuration file generated successfully"
66
+ echo "File size: $(wc -c < docs/model_config.js) bytes"
67
+ echo "Lines: $(wc -l < docs/model_config.js)"
68
+ # Show first few lines for verification
69
+ echo "First 10 lines of generated file:"
70
+ head -10 docs/model_config.js
71
+ else
72
+ echo "❌ Model configuration file was not generated"
73
+ exit 1
74
+ fi
75
+
76
+ - name : Commit and push changes
77
+ if : github.event_name != 'pull_request'
78
+ run : |
79
+ git config --local user.email "[email protected] "
80
+ git config --local user.name "GitHub Action"
81
+
82
+ if [ -n "$(git status --porcelain docs/model_config.js)" ]; then
83
+ git add docs/model_config.js
84
+ git commit -m "🤖 Auto-update model configuration
85
+
86
+ - Generated from EMD Python model definitions
87
+ - Updated at: $(date -u '+%Y-%m-%d %H:%M:%S UTC')
88
+ - Triggered by: ${{ github.event_name }}
89
+ - Commit: ${{ github.sha }}"
90
+
91
+ git push
92
+ echo "✅ Model configuration updated and committed"
93
+ else
94
+ echo "ℹ️ No changes to model configuration"
95
+ fi
96
+
97
+ - name : Upload model config as artifact
98
+ uses : actions/upload-artifact@v3
99
+ with :
100
+ name : model-config
101
+ path : docs/model_config.js
102
+ retention-days : 30
103
+
104
+ - name : Generate summary
105
+ run : |
106
+ echo "## 📊 Model Configuration Generation Summary" >> $GITHUB_STEP_SUMMARY
107
+ echo "" >> $GITHUB_STEP_SUMMARY
108
+
109
+ if [ -f docs/model_config.js ]; then
110
+ echo "✅ **Status**: Successfully generated" >> $GITHUB_STEP_SUMMARY
111
+ echo "📁 **Output**: \`docs/model_config.js\`" >> $GITHUB_STEP_SUMMARY
112
+ echo "📏 **Size**: $(wc -c < docs/model_config.js) bytes" >> $GITHUB_STEP_SUMMARY
113
+ echo "📄 **Lines**: $(wc -l < docs/model_config.js)" >> $GITHUB_STEP_SUMMARY
114
+ echo "" >> $GITHUB_STEP_SUMMARY
115
+
116
+ # Extract model count from the generated file if possible
117
+ if grep -q "getModelCount" docs/model_config.js; then
118
+ echo "🎯 **Generated**: Model configuration with helper functions" >> $GITHUB_STEP_SUMMARY
119
+ fi
120
+
121
+ echo "" >> $GITHUB_STEP_SUMMARY
122
+ echo "### 📋 Generated Configuration Includes:" >> $GITHUB_STEP_SUMMARY
123
+ echo "- 🤖 Model definitions and metadata" >> $GITHUB_STEP_SUMMARY
124
+ echo "- 🖥️ Instance type specifications" >> $GITHUB_STEP_SUMMARY
125
+ echo "- ⚙️ Engine configurations" >> $GITHUB_STEP_SUMMARY
126
+ echo "- 🔧 Service definitions" >> $GITHUB_STEP_SUMMARY
127
+ echo "- 🛠️ JavaScript helper functions" >> $GITHUB_STEP_SUMMARY
128
+ else
129
+ echo "❌ **Status**: Generation failed" >> $GITHUB_STEP_SUMMARY
130
+ echo "Please check the workflow logs for details." >> $GITHUB_STEP_SUMMARY
131
+ fi
0 commit comments