(opts = {})
| 166 | } |
| 167 | |
| 168 | async commentCreate(opts = {}) { |
| 169 | const { |
| 170 | commitSha, |
| 171 | markdownFile, |
| 172 | pr, |
| 173 | publish, |
| 174 | publishUrl, |
| 175 | report: testReport, |
| 176 | rmWatermark, |
| 177 | target: commentTarget = 'auto', |
| 178 | triggerFile, |
| 179 | update, |
| 180 | watch, |
| 181 | watermarkTitle |
| 182 | } = opts; |
| 183 | |
| 184 | const drv = this.getDriver(); |
| 185 | |
| 186 | if (rmWatermark && update) |
| 187 | throw new Error('watermarks are mandatory for updatable comments'); |
| 188 | |
| 189 | // Create the watermark. |
| 190 | const watermark = rmWatermark |
| 191 | ? null |
| 192 | : new Watermark({ |
| 193 | label: watermarkTitle, |
| 194 | workflow: drv.workflowId, |
| 195 | run: drv.runId, |
| 196 | sha: commitSha || (await this.triggerSha()) |
| 197 | }); |
| 198 | |
| 199 | let userReport = testReport; |
| 200 | try { |
| 201 | if (!userReport) { |
| 202 | userReport = await fs.readFile(markdownFile, 'utf-8'); |
| 203 | } |
| 204 | } catch (err) { |
| 205 | if (!watch) throw err; |
| 206 | } |
| 207 | |
| 208 | let report = userReport; |
| 209 | if (watermark) { |
| 210 | report = watermark.appendTo(userReport); |
| 211 | } |
| 212 | |
| 213 | const publishLocalFiles = async (tree) => { |
| 214 | const nodes = []; |
| 215 | |
| 216 | visit(tree, ['definition', 'image', 'link'], (node) => { |
| 217 | nodes.push(node); |
| 218 | }); |
| 219 | |
| 220 | const isWatermark = (node) => { |
| 221 | return node.title && node.title.startsWith('CML watermark'); |
| 222 | }; |
| 223 | const visitor = async (node) => { |
| 224 | if (node.url && !isWatermark(node)) { |
| 225 | // Check for embedded images from dvclive |
no test coverage detected