Skip to content

Commit 6950840

Browse files
authored
Update some basic workflows and add model links. (#247)
1 parent 480bc7a commit 6950840

26 files changed

+2874
-2353
lines changed

.github/workflows/check_input_assets.yml

Lines changed: 33 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,11 @@ jobs:
3030
- name: Run input assets validation
3131
id: validation
3232
run: |
33-
python scripts/check_input_assets.py
33+
python scripts/check_input_assets.py || echo "validation_failed=true" >> $GITHUB_OUTPUT
3434
continue-on-error: true
3535

36-
- name: Comment on PR with validation results
37-
if: always()
36+
- name: Comment on PR with validation results (failures only)
37+
if: steps.validation.outputs.validation_failed == 'true'
3838
uses: actions/github-script@v7
3939
with:
4040
github-token: ${{ secrets.GITHUB_TOKEN }}
@@ -86,6 +86,36 @@ jobs:
8686
console.log('Created new comment');
8787
}
8888
89+
- name: Remove or update comment on successful validation
90+
if: steps.validation.outputs.validation_failed != 'true'
91+
uses: actions/github-script@v7
92+
with:
93+
github-token: ${{ secrets.GITHUB_TOKEN }}
94+
script: |
95+
// Find existing comment
96+
const { data: comments } = await github.rest.issues.listComments({
97+
owner: context.repo.owner,
98+
repo: context.repo.repo,
99+
issue_number: context.issue.number,
100+
});
101+
102+
const botComment = comments.find(comment =>
103+
comment.user.type === 'Bot' &&
104+
comment.body.includes('Input Assets Validation Report')
105+
);
106+
107+
if (botComment) {
108+
// Delete the existing comment since validation passed
109+
await github.rest.issues.deleteComment({
110+
owner: context.repo.owner,
111+
repo: context.repo.repo,
112+
comment_id: botComment.id
113+
});
114+
console.log('Deleted previous validation failure comment - validation now passes');
115+
} else {
116+
console.log('No previous comment found - validation passed cleanly');
117+
}
118+
89119
- name: Upload validation report as artifact
90120
if: always()
91121
uses: actions/upload-artifact@v4

.github/workflows/model-analysis.yml

Lines changed: 34 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ jobs:
6060
report = 'Unable to read model analysis report';
6161
}
6262
63-
const comment = `## ❌ Model Analysis Check Failed
63+
const commentBody = `## ❌ Model Analysis Check Failed
6464
6565
Model configuration issues were found in your template files that need to be fixed.
6666
@@ -83,19 +83,48 @@ jobs:
8383
8484
3. **Markdown link errors**:
8585
- Ensure \`[filename.safetensors](url)\` links have consistent filenames between text and URL
86+
- Note: Civitai links are automatically whitelisted as they use model IDs instead of filenames
8687
8788
4. **Subgraph nodes**:
8889
- Note: Subgraph nodes (UUID-type) are automatically skipped from model validation
8990
- Their model configurations are handled within the subgraph definition
9091
91-
Please fix these issues and resubmit.`;
92+
Please fix these issues and resubmit.
9293
93-
github.rest.issues.createComment({
94-
issue_number: context.issue.number,
94+
---
95+
*This comment is automatically updated by the Model Analysis workflow.*`;
96+
97+
// Find existing comment
98+
const { data: comments } = await github.rest.issues.listComments({
9599
owner: context.repo.owner,
96100
repo: context.repo.repo,
97-
body: comment
101+
issue_number: context.issue.number,
98102
});
103+
104+
const botComment = comments.find(comment =>
105+
comment.user.type === 'Bot' &&
106+
comment.body.includes('Model Analysis Check')
107+
);
108+
109+
if (botComment) {
110+
// Update existing comment
111+
await github.rest.issues.updateComment({
112+
owner: context.repo.owner,
113+
repo: context.repo.repo,
114+
comment_id: botComment.id,
115+
body: commentBody
116+
});
117+
console.log('Updated existing comment');
118+
} else {
119+
// Create new comment
120+
await github.rest.issues.createComment({
121+
issue_number: context.issue.number,
122+
owner: context.repo.owner,
123+
repo: context.repo.repo,
124+
body: commentBody
125+
});
126+
console.log('Created new comment');
127+
}
99128
100129
- name: Fail job if model analysis issues found
101130
if: steps.model_analysis.outputs.model_analysis_failed == 'true'

scripts/analyze_models.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,10 +149,24 @@ def find_markdown_links(obj):
149149
return result
150150

151151
def analyze_markdown_links(result: Dict):
152-
"""Check if markdown safetensors links are consistent (text matches filename in URL)."""
152+
"""Check if markdown safetensors links are consistent (text matches filename in URL).
153+
154+
Whitelisted URLs (skipped from validation):
155+
- Civitai URLs: Use model IDs instead of filenames in paths
156+
"""
157+
# Whitelist patterns for URLs that don't need filename validation
158+
whitelist_patterns = [
159+
r'civitai\.com', # Civitai uses model IDs, not filenames
160+
]
161+
153162
for link in result['markdown_links']:
154163
text_name = link['text']
155164
url = link['url']
165+
166+
# Skip validation for whitelisted URLs
167+
if any(re.search(pattern, url, re.IGNORECASE) for pattern in whitelist_patterns):
168+
continue
169+
156170
# Extract filename from URL path (ignore query string)
157171
m = re.search(r'/([^/?]+\.safetensors)(?:[?]|$)', url)
158172
if m:

0 commit comments

Comments
 (0)