-
Notifications
You must be signed in to change notification settings - Fork 8.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[CI] Build and publish storybooks (#87701)
- Loading branch information
1 parent
0438487
commit 03206b6
Showing
12 changed files
with
171 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0 and the Server Side Public License, v 1; you may not use this file except | ||
* in compliance with, at your election, the Elastic License 2.0 or the Server | ||
* Side Public License, v 1. | ||
*/ | ||
|
||
const config = require('@kbn/storybook').defaultConfig; | ||
const aliases = require('../../src/dev/storybook/aliases.ts').storybookAliases; | ||
|
||
config.refs = {}; | ||
|
||
for (const alias of Object.keys(aliases).filter((a) => a !== 'ci_composite')) { | ||
// snake_case -> Title Case | ||
const title = alias | ||
.replace(/_/g, ' ') | ||
.split(' ') | ||
.map((n) => n[0].toUpperCase() + n.slice(1)) | ||
.join(' '); | ||
|
||
config.refs[alias] = { | ||
title: title, | ||
url: `${process.env.STORYBOOK_BASE_URL}/${alias}`, | ||
}; | ||
} | ||
|
||
module.exports = config; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,6 +15,7 @@ node_modules | |
target | ||
snapshots.js | ||
|
||
!/.ci | ||
!/.eslintrc.js | ||
!.storybook | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#!/usr/bin/env bash | ||
|
||
source src/dev/ci_setup/setup_env.sh | ||
|
||
cd "$XPACK_DIR/plugins/canvas" | ||
node scripts/storybook --dll | ||
|
||
cd "$KIBANA_DIR" | ||
|
||
# yarn storybook --site apm # TODO re-enable after being fixed | ||
yarn storybook --site canvas | ||
yarn storybook --site ci_composite | ||
yarn storybook --site url_template_editor | ||
yarn storybook --site codeeditor | ||
yarn storybook --site dashboard | ||
yarn storybook --site dashboard_enhanced | ||
yarn storybook --site data_enhanced | ||
yarn storybook --site embeddable | ||
yarn storybook --site infra | ||
yarn storybook --site security_solution | ||
yarn storybook --site ui_actions_enhanced | ||
yarn storybook --site observability | ||
yarn storybook --site presentation |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
def getStorybooksBucket() { | ||
return "ci-artifacts.kibana.dev/storybooks" | ||
} | ||
|
||
def getDestinationDir() { | ||
return env.ghprbPullId ? "pr-${env.ghprbPullId}" : buildState.get('checkoutInfo').branch.replace("/", "__") | ||
} | ||
|
||
def getUrl() { | ||
return "https://${getStorybooksBucket()}/${getDestinationDir()}" | ||
} | ||
|
||
def getUrlLatest() { | ||
return "${getUrl()}/latest" | ||
} | ||
|
||
def getUrlForCommit() { | ||
return "${getUrl()}/${buildState.get('checkoutInfo').commit}" | ||
} | ||
|
||
def upload() { | ||
dir("built_assets/storybook") { | ||
sh "mv ci_composite composite" | ||
|
||
def storybooks = sh( | ||
script: 'ls -1d */', | ||
returnStdout: true | ||
).trim() | ||
.split('\n') | ||
.collect { it.replace('/', '') } | ||
.findAll { it != 'composite' } | ||
|
||
def listHtml = storybooks.collect { """<li><a href="${getUrlForCommit()}/${it}">${it}</a></li>""" }.join("\n") | ||
|
||
def html = """ | ||
<html> | ||
<body> | ||
<h1>Storybooks</h1> | ||
<p><a href="${getUrlForCommit()}/composite">Composite Storybook</a></p> | ||
<h2>All</h2> | ||
<ul> | ||
${listHtml} | ||
</ul> | ||
</body> | ||
</html> | ||
""" | ||
|
||
writeFile(file: 'index.html', text: html) | ||
|
||
withGcpServiceAccount.fromVaultSecret('secret/kibana-issues/dev/ci-artifacts-key', 'value') { | ||
kibanaPipeline.bash(""" | ||
gsutil -q -m cp -r -z js,css,html,json,map,txt,svg '*' 'gs://${getStorybooksBucket()}/${getDestinationDir()}/${buildState.get('checkoutInfo').commit}/' | ||
gsutil -h "Cache-Control:no-cache, max-age=0, no-transform" cp -z html 'index.html' 'gs://${getStorybooksBucket()}/${getDestinationDir()}/latest/' | ||
""", "Upload Storybooks to GCS") | ||
} | ||
|
||
buildState.set('storybooksUrl', getUrlForCommit()) | ||
} | ||
} | ||
|
||
def build() { | ||
withEnv(["STORYBOOK_BASE_URL=${getUrlForCommit()}"]) { | ||
kibanaPipeline.bash('test/scripts/jenkins_storybook.sh', 'Build Storybooks') | ||
} | ||
} | ||
|
||
def buildAndUpload() { | ||
def sha = buildState.get('checkoutInfo').commit | ||
def context = 'Build and Publish Storybooks' | ||
|
||
githubCommitStatus.create(sha, 'pending', 'Building Storybooks', context) | ||
|
||
try { | ||
build() | ||
upload() | ||
githubCommitStatus.create(sha, 'success', 'Storybooks built', context, getUrlForCommit()) | ||
} catch(ex) { | ||
githubCommitStatus.create(sha, 'error', 'Building Storybooks failed', context) | ||
throw ex | ||
} | ||
} | ||
|
||
return this |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters