Skip to content

Commit aadfee9

Browse files
committed
Add a way to skip test on CI based on metadata
```` _quarto: tests-on-ci: false ```` `smoke-all.test.ts` should skip tests when this metadata is set to false inside a CI context This can be useful for mermaid test for example
1 parent f87df74 commit aadfee9

3 files changed

Lines changed: 15 additions & 0 deletions

File tree

dev-docs/feature-format-matrix/qmd-files/crossref/float/custom/document.qmd

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ crossref:
77
reference-prefix: Diagram
88
format:
99
docusaurus-md: {}
10+
_quarto:
11+
tests-on-ci: false
1012
---
1113

1214
::: {#dia-1}

dev-docs/feature-format-matrix/qmd-files/mermaid/document.qmd

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
title: Mermaid
33
format:
44
docusaurus-md: {}
5+
_quarto:
6+
tests-on-ci: false
57
---
68

79
::: {.content-visible when-format="docusaurus-md"}

tests/smoke/smoke-all.test.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ import {
3838
shouldError,
3939
ensureHtmlElementContents,
4040
ensureHtmlElementCount,
41+
directoryContainsOnlyAllowedPaths,
4142
} from "../verify.ts";
4243
import { readYamlFromMarkdown } from "../../src/core/yaml.ts";
4344
import { findProjectDir, findProjectOutputDir, outputForInput } from "../utils.ts";
@@ -46,6 +47,7 @@ import { basename, dirname, join, relative } from "../../src/deno_ral/path.ts";
4647
import { WalkEntry } from "../../src/deno_ral/fs.ts";
4748
import { quarto } from "../../src/quarto.ts";
4849
import { safeExistsSync, safeRemoveSync } from "../../src/core/path.ts";
50+
import { runningInCI } from "../../src/core/ci-info.ts";
4951

5052
async function fullInit() {
5153
await initYamlIntelligenceResourcesFromFilesystem();
@@ -90,6 +92,10 @@ async function guessFormat(fileName: string): Promise<string[]> {
9092
return Array.from(formats);
9193
}
9294

95+
function skipTestOnCi(metadata: Record<string, any>): boolean {
96+
return runningInCI() && metadata["_quarto"]?.["tests-on-ci"] === false;
97+
}
98+
9399
//deno-lint-ignore no-explicit-any
94100
function hasTestSpecs(metadata: any, input: string): boolean {
95101
const hasTestSpecs = metadata?.["_quarto"]?.["tests"] != undefined
@@ -285,6 +291,11 @@ for (const { path: fileName } of files) {
285291
? readYamlFromMarkdown(Deno.readTextFileSync(input))
286292
: readYamlFromMarkdown(await jupyterNotebookToMarkdown(input, false));
287293

294+
if (skipTestOnCi(metadata) === true) {
295+
console.log(`Skipping tests for ${input} as tests-on-ci is false in metadata`);
296+
continue;
297+
}
298+
288299
const testSpecs: QuartoInlineTestSpec[] = [];
289300

290301
if (hasTestSpecs(metadata, input)) {

0 commit comments

Comments
 (0)