Skip to content

Commit

Permalink
Fix documentation build in CI (#7293)
Browse files Browse the repository at this point in the history
  • Loading branch information
yogevbd authored Oct 6, 2021
1 parent 575000c commit 62ab69c
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 16 deletions.
11 changes: 7 additions & 4 deletions scripts/documentation.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,12 @@ const docsVersionsJsonPath = `${docsPath}/versions.json`;
function release(version, removeVersion) {
console.log(`Building documentation version: ${version}`);
if (_versionExists(removeVersion)) _removeDocsVersion(removeVersion);
exec.execSync(`npm --prefix ${docsPath} install`);
exec.execSync(`npm --prefix ${docsPath} run docusaurus docs:version ${version}`);
exec.execSync(`cd ${docsPath}`);
exec.execSync(`current_dir=$PWD`);
exec.execSync(`npm install`);
exec.execSync(`npm run docusaurus docs:version ${version}`);
exec.execSync(`git add website`);
exec.execSync(`cd $current_dir`);
}

function _removeDocsVersion(version) {
Expand All @@ -37,5 +40,5 @@ function _writeDocsVersionsJson(versionsJson) {
}

module.exports = {
release
}
release,
};
32 changes: 20 additions & 12 deletions scripts/documentation.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,30 +13,38 @@ describe('Documentation script', () => {

it('should build new version', () => {
const version = '1.0.0';
fs.readFileSync.mockReturnValue(JSON.stringify([]))
fs.readFileSync.mockReturnValue(JSON.stringify([]));

documentation.release('1.0.0');
expect(exec.execSync).toHaveBeenCalledTimes(3);
expect(exec.execSync).toHaveBeenCalledWith(`npm --prefix ${process.cwd()}/website install`);
expect(exec.execSync).toHaveBeenCalledWith(`npm --prefix ${process.cwd()}/website run docusaurus docs:version ${version}`);
expect(exec.execSync).toHaveBeenCalledTimes(6);
expect(exec.execSync).toHaveBeenCalledWith(`cd ${docsPath()}`);
expect(exec.execSync).toHaveBeenCalledWith(`current_dir=$PWD`);
expect(exec.execSync).toHaveBeenCalledWith(`npm install`);
expect(exec.execSync).toHaveBeenCalledWith(`npm run docusaurus docs:version ${version}`);
expect(exec.execSync).toHaveBeenCalledWith(`git add website`);
expect(exec.execSync).toHaveBeenCalledWith(`cd $current_dir`);
});

it('should override version', () => {
fs.readFileSync.mockReturnValue(JSON.stringify([
"1.0.0",
"2.0.0"
]))
fs.readFileSync.mockReturnValue(JSON.stringify(['1.0.0', '2.0.0']));

const version = '2.0.0';
const removeVersion = '2.0.0';
documentation.release(version, removeVersion);

expect(exec.execSync).toHaveBeenCalledTimes(5);
expect(exec.execSync).toHaveBeenCalledWith(`rm -rf ${docsPath()}/versioned_docs/version-${version}`);
expect(exec.execSync).toHaveBeenCalledWith(`rm -f ${docsPath()}/versioned_sidebars/version-${version}-sidebars.json`);
expect(exec.execSync).toHaveBeenCalledWith(`npm --prefix ${docsPath()} run docusaurus docs:version ${version}`);
expect(exec.execSync).toHaveBeenCalledTimes(8);

expect(exec.execSync).toHaveBeenCalledWith(`cd ${docsPath()}`);
expect(exec.execSync).toHaveBeenCalledWith(`current_dir=$PWD`);
expect(exec.execSync).toHaveBeenCalledWith(
`rm -rf ${docsPath()}/versioned_docs/version-${version}`
);
expect(exec.execSync).toHaveBeenCalledWith(
`rm -f ${docsPath()}/versioned_sidebars/version-${version}-sidebars.json`
);
expect(exec.execSync).toHaveBeenCalledWith(`npm run docusaurus docs:version ${version}`);
expect(exec.execSync).toHaveBeenCalledWith(`git add website`);
expect(exec.execSync).toHaveBeenCalledWith(`cd $current_dir`);
});
});

Expand Down

0 comments on commit 62ab69c

Please sign in to comment.