Skip to content

Commit 057b17e

Browse files
committed
fix ci
1 parent a7a364c commit 057b17e

File tree

5 files changed

+252
-219
lines changed

5 files changed

+252
-219
lines changed

docs/diagrams.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,3 +37,19 @@ npm install -g @mermaid-js/mermaid-cli
3737
```
3838

3939
:::
40+
41+
:::{note .dropdown} For CI Environments
42+
43+
The Mermaid CLI uses Puppeteer which may require special configuration in CI environments. MyST automatically handles this by detecting the `CI` environment variable or you can manually control it:
44+
45+
```bash
46+
# Automatic detection (recommended for CI)
47+
CI=true npm run build
48+
49+
# Manual control
50+
MERMAID_NO_SANDBOX=true npm run build
51+
```
52+
53+
This automatically creates a Puppeteer configuration file with `--no-sandbox` flag to resolve sandbox issues in Linux CI environments.
54+
55+
:::

packages/jtex/tests/download.spec.ts

Lines changed: 47 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -4,57 +4,53 @@ import { TemplateKind } from 'myst-common';
44
import MystTemplate, { downloadTemplate, resolveInputs, Session } from 'myst-templates';
55
import { renderTemplate } from '../src';
66

7-
describe(
8-
'Download Template',
9-
() => {
10-
it('Download default template', async () => {
11-
const session = new Session();
12-
const inputs = resolveInputs(session, { buildDir: '_build', kind: TemplateKind.tex });
13-
await downloadTemplate(session, {
14-
templatePath: inputs.templatePath,
15-
templateUrl: inputs.templateUrl as string,
16-
});
17-
expect(fs.existsSync('_build/templates/tex/myst/plain_latex/template.zip')).toBe(true);
18-
expect(fs.existsSync('_build/templates/tex/myst/plain_latex/template.yml')).toBe(true);
19-
expect(fs.existsSync('_build/templates/tex/myst/plain_latex/template.tex')).toBe(true);
7+
describe('Download Template', { timeout: 15000 }, () => {
8+
it('Download default template', async () => {
9+
const session = new Session();
10+
const inputs = resolveInputs(session, { buildDir: '_build', kind: TemplateKind.tex });
11+
await downloadTemplate(session, {
12+
templatePath: inputs.templatePath,
13+
templateUrl: inputs.templateUrl as string,
2014
});
21-
it('Bad template paths to throw', async () => {
22-
const jtex = new MystTemplate(new Session(), {
23-
template: 'not-there',
24-
kind: TemplateKind.tex,
25-
});
26-
expect(() => jtex.prepare({} as any)).toThrow(/does not exist/);
15+
expect(fs.existsSync('_build/templates/tex/myst/plain_latex/template.zip')).toBe(true);
16+
expect(fs.existsSync('_build/templates/tex/myst/plain_latex/template.yml')).toBe(true);
17+
expect(fs.existsSync('_build/templates/tex/myst/plain_latex/template.tex')).toBe(true);
18+
});
19+
it('Bad template paths to throw', async () => {
20+
const jtex = new MystTemplate(new Session(), {
21+
template: 'not-there',
22+
kind: TemplateKind.tex,
2723
});
28-
it('Render out the template', async () => {
29-
const jtex = new MystTemplate(new Session(), {
30-
kind: TemplateKind.tex,
31-
template: `${__dirname}/example`,
32-
});
33-
renderTemplate(jtex, {
34-
contentOrPath: `${__dirname}/test.tex`,
35-
outputPath: '_build/out/article.tex',
36-
frontmatter: {
37-
title: 'test',
38-
description: 'test',
39-
date: new Date(2022, 6, 22).toISOString(),
40-
authors: [
41-
{ name: 'Rowan Cockett', affiliations: ['Curvenote'] },
42-
{ name: 'Steve Purves', affiliations: ['Curvenote'], orcid: '0000' },
43-
],
44-
},
45-
options: {
46-
keywords: '',
47-
},
48-
parts: {
49-
abstract: 'My abstract!',
50-
},
51-
});
52-
expect(fs.existsSync('_build/out/article.tex')).toBe(true);
53-
const content = fs.readFileSync('_build/out/article.tex').toString();
54-
expect(content.includes('Volcanic Archipelago')).toBe(true);
55-
expect(content.includes('Rowan Cockett')).toBe(true);
56-
expect(content.includes('My abstract!')).toBe(true);
24+
expect(() => jtex.prepare({} as any)).toThrow(/does not exist/);
25+
});
26+
it('Render out the template', async () => {
27+
const jtex = new MystTemplate(new Session(), {
28+
kind: TemplateKind.tex,
29+
template: `${__dirname}/example`,
5730
});
58-
},
59-
{ timeout: 15000 },
60-
);
31+
renderTemplate(jtex, {
32+
contentOrPath: `${__dirname}/test.tex`,
33+
outputPath: '_build/out/article.tex',
34+
frontmatter: {
35+
title: 'test',
36+
description: 'test',
37+
date: new Date(2022, 6, 22).toISOString(),
38+
authors: [
39+
{ name: 'Rowan Cockett', affiliations: ['Curvenote'] },
40+
{ name: 'Steve Purves', affiliations: ['Curvenote'], orcid: '0000' },
41+
],
42+
},
43+
options: {
44+
keywords: '',
45+
},
46+
parts: {
47+
abstract: 'My abstract!',
48+
},
49+
});
50+
expect(fs.existsSync('_build/out/article.tex')).toBe(true);
51+
const content = fs.readFileSync('_build/out/article.tex').toString();
52+
expect(content.includes('Volcanic Archipelago')).toBe(true);
53+
expect(content.includes('Rowan Cockett')).toBe(true);
54+
expect(content.includes('My abstract!')).toBe(true);
55+
});
56+
});

packages/myst-cli/src/build/jats/single.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,17 @@ import { resolveFrontmatterParts } from '../../utils/resolveFrontmatterParts.js'
1414
import type { ExportWithOutput, ExportFnOptions } from '../types.js';
1515
import { cleanOutput } from '../utils/cleanOutput.js';
1616
import { getFileContent } from '../utils/getFileContent.js';
17+
import { mermaidPlugin } from '../../transforms/mermaid.js';
18+
import type { TransformSpec } from 'myst-common';
19+
20+
const mermaidTransform: TransformSpec = {
21+
name: 'mermaid',
22+
stage: 'document',
23+
plugin: mermaidPlugin,
24+
options: {
25+
format: 'png',
26+
},
27+
};
1728

1829
/**
1930
* Build a MyST project as JATS XML
@@ -39,6 +50,7 @@ export async function runJatsExport(
3950
projectPath,
4051
imageExtensions: KNOWN_IMAGE_EXTENSIONS,
4152
extraLinkTransformers,
53+
transforms: [mermaidTransform],
4254
preFrontmatters: [
4355
filterKeys(article, [...PAGE_FRONTMATTER_KEYS, ...Object.keys(FRONTMATTER_ALIASES)]),
4456
], // only apply to article, not sub_articles

0 commit comments

Comments
 (0)