-
Notifications
You must be signed in to change notification settings - Fork 2
144 lines (118 loc) · 4.64 KB
/
ReviewModelCheck.yml
File metadata and controls
144 lines (118 loc) · 4.64 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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
# Copyright (c) LieberLieber Software GmbH
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at https://mozilla.org/MPL/2.0/.
name: Verify Modelcheck
on:
pull_request:
permissions:
contents: read
pull-requests: write
checks: write
env:
ModelName: LemonTree.DevOps.Demo.qeax
jobs:
ModelReadinessCheck:
defaults:
run:
shell: pwsh
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- uses: actions/checkout@v6.0.2
with:
lfs: true
fetch-depth: 0
# Custom action to setup LemonTree ModelCheck that supports caching
- name: Setup LemonTree ModelCheck Tool
id: modelcheck_setup
uses: ./.github/actions/setup-modelcheck
- name: Run LemonTree Check Tool
id: modelcheck
run: |
Write-Output "starting validation"
$modelCheckExe = "${{ steps.modelcheck_setup.outputs.executable-path }}"
&$modelCheckExe --model "${{env.ModelName}}" --out "./output.md" --ChecksConfig "./checks-config.json" --NoCompact --FailOnErrors --junit junit.xml
Get-Content "./output.md" >> $env:GITHUB_STEP_SUMMARY
# Exit codes of LemonTree.Pipeline.Tools.ModelCheck.exe:
# * -2 = other runtime exception occurred
# * -1 = CLI argument parsing error occurred
# * 0 = model is valid (no error, no warning, no runtime exception)
# * 1 = model has at least one warning (only if --FailOnWarnings or --FailOnErrors)
# * 2 = model has at least one error (only if --FailOnErrors)
Write-Output "modelcheckExitCode=$LASTEXITCODE" >> $env:GITHUB_OUTPUT
Write-Output "finished validation with $LASTEXITCODE"
#for now never stop
exit 0
- name: Publish JUnit Test Results
if: always()
uses: dorny/test-reporter@v3.0.0
with:
name: Model Check Results
path: junit.xml
reporter: java-junit
fail-on-error: false
- name: evaulate Exit Code
run: |
Write-Output "set job failed on ..."
Write-Output "Current Exit Code ${{ steps.modelcheck.outputs.modelcheckExitCode }}"
if (${{ steps.modelcheck.outputs.modelcheckExitCode }} -eq 1)
{
#fail on warning
Write-Output "model has at least one warning"
#fail on warning
#exit 3
#ignore warning
exit 0
}
elseif (${{ steps.modelcheck.outputs.modelcheckExitCode }} -eq 2)
{
#fail on Error
Write-Output "model has at least one error"
exit 2
}
elseif (${{ steps.modelcheck.outputs.modelcheckExitCode }} -eq 0)
{
#brilliant model
Write-Output "modelcheck is passed"
exit 0
}
else
{
exit steps.modelcheck.outputs.modelcheckExitCode
}
- name: Post Model Check Results to PR
if: github.event_name == 'pull_request' && always()
uses: actions/github-script@v8
with:
script: |
const fs = require('fs');
const COMMENT_MARKER = '<!-- modelcheck-results -->';
const markdownContent = fs.readFileSync('./output.md', 'utf8');
// Extract just the first block (summary table)
const blocks = markdownContent.split('\n\n');
const firstBlock = blocks[0];
const body = `${COMMENT_MARKER}\n## Model Check Results\n\n${firstBlock}`;
const { data: comments } = await github.rest.issues.listComments({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
});
const existing = comments.find(
cm => cm.user.login === 'github-actions[bot]' && cm.body.includes(COMMENT_MARKER)
);
if (existing) {
await github.rest.issues.updateComment({
owner: context.repo.owner,
repo: context.repo.repo,
comment_id: existing.id,
body,
});
} else {
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
body,
});
}