{"id":2926,"date":"2022-08-29T18:08:02","date_gmt":"2022-08-29T09:08:02","guid":{"rendered":"https:\/\/p-corporate-blog-cms.mmmcorp.co.jp\/?p=2926"},"modified":"2022-09-03T08:54:14","modified_gmt":"2022-09-02T23:54:14","slug":"storycap-reg-suit-codebuild","status":"publish","type":"post","link":"https:\/\/p-corporate-blog-cms.mmmcorp.co.jp\/blog\/2022\/08\/29\/storycap-reg-suit-codebuild\/","title":{"rendered":"storycap+reg-suit\u3092\u5229\u7528\u3057\u305f\u30d3\u30b8\u30e5\u30a2\u30eb\u30ea\u30b0\u30ec\u30c3\u30b7\u30e7\u30f3\u30c6\u30b9\u30c8\u3092CodeBuild\u4e0a\u3067\u5b9f\u884c\u3059\u308b"},"content":{"rendered":"
\u30d3\u30b8\u30e5\u30a2\u30eb\u30ea\u30b0\u30ec\u30c3\u30b7\u30e7\u30f3\u30c6\u30b9\u30c8\u3068\u306f\u3001\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u306e\u30b9\u30af\u30ea\u30fc\u30f3\u30b7\u30e7\u30c3\u30c8\u753b\u50cf\u306e\u5dee\u5206\u3092\u30c1\u30a7\u30c3\u30af\u3059\u308b\u3053\u3068\u3067\u4e88\u671f\u305b\u306c\u753b\u9762\u306e\u5d29\u308c\u306a\u3069\u3092\u691c\u77e5\u3059\u308b\u3053\u3068\u3092\u76ee\u7684\u3068\u3057\u305f\u30c6\u30b9\u30c8\u306e\u3053\u3068\u3067\u3059\u3002\u57fa\u672c\u7684\u306b\u306fmain\u3084develop\u306a\u3069\u306e\u958b\u767a\u30d6\u30e9\u30f3\u30c1\u3068feature\u3084bugfix\u306a\u3069\u306e\u5404\u7a2e\u6a5f\u80fd\u958b\u767a\/\u30d0\u30b0\u4fee\u6b63\u30d6\u30e9\u30f3\u30c1\u306e\u5dee\u5206\u3092\u30c1\u30a7\u30c3\u30af\u3059\u308b\u904b\u7528\u306b\u306a\u308b\u3053\u3068\u304c\u591a\u3044\u306e\u3067\u306f\u306a\u3044\u3067\u3057\u3087\u3046\u304b\u3002<\/p>\n
\u4f3c\u305f\u3088\u3046\u306a\u30c6\u30b9\u30c8\u5f62\u5f0f\u3068\u3057\u3066\u30b9\u30ca\u30c3\u30d7\u30b7\u30e7\u30c3\u30c8\u30c6\u30b9\u30c8<\/a>\u304c\u3042\u308a\u307e\u3059\u3002\u30d3\u30b8\u30e5\u30a2\u30eb\u30ea\u30b0\u30ec\u30c3\u30b7\u30e7\u30f3\u30c6\u30b9\u30c8\u306e\u5834\u5408\u3001\u30b9\u30bf\u30a4\u30eb\u30b7\u30fc\u30c8\u306e\u5909\u66f4\u306b\u3088\u308b\u5dee\u5206\u3082\u691c\u77e5\u3057\u3084\u3059\u304f\u306a\u308b\u30e1\u30ea\u30c3\u30c8\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n Web\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u306b\u5bfe\u3057\u3066\u30d3\u30b8\u30e5\u30a2\u30eb\u30ea\u30b0\u30ec\u30c3\u30b7\u30e7\u30f3\u30c6\u30b9\u30c8\u3092\u5b9f\u884c\u3059\u308b\u305f\u3081\u306e\u30c4\u30fc\u30eb\u306b\u306f\u3044\u304f\u3064\u304b\u9078\u629e\u80a2\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n \u4f8b\uff1a<\/p>\n \u4eca\u56de\u306fstorycap<\/a>\u3092\u7528\u3044\u3066Storybook<\/a>\u306e\u30b9\u30af\u30ea\u30fc\u30f3\u30b7\u30e7\u30c3\u30c8\u3092\u751f\u6210\u3057\u3001reg-suit<\/a>\u3067\u753b\u50cf\u5dee\u5206\u30c1\u30a7\u30c3\u30af\u3092\u884c\u3046\u5de5\u7a0b\u3092AWS CodeBuild<\/a>\u4e0a\u3067\u5b9f\u884c\u3057\u3001Slack\u4e0a\u306b\u305d\u306e\u30c6\u30b9\u30c8\u7d50\u679c\u3068\u30ec\u30dd\u30fc\u30c8\u304c\u901a\u77e5\u3055\u308c\u308b\u3068\u3053\u308d\u307e\u3067\u3092\u691c\u8a3c\u3057\u305f\u5185\u5bb9\u3092\u5171\u6709\u3055\u305b\u3066\u3044\u305f\u3060\u304d\u307e\u3059\u3002<\/p>\n \u4eca\u56de\u306fVue3+Vite\u3092\u30d9\u30fc\u30b9\u306b\u3057\u305f\u30b5\u30f3\u30d7\u30eb\u30a2\u30d7\u30ea\u3092\u4f5c\u6210\u3057\u307e\u3059\u3002 Storybook\u306e\u8a2d\u5b9a( \u751f\u6210\u3057\u305f\u30b5\u30f3\u30d7\u30eb\u30a2\u30d7\u30ea\u306e\u3046\u3061\u4e00\u90e8\u306e\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8\u3092Storybook\u306b\u3057\u307e\u3059\u3002 \u3053\u3053\u307e\u3067\u3067\u3001Storybook\u304c\u4f5c\u6210\u3055\u308c\u308b\u3068\u3053\u308d\u307e\u3067\u51fa\u6765\u307e\u3057\u305f\u3002 \u6b21\u306bstorycap\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3057\u3066\u3001Storybook\u306e\u30b9\u30af\u30ea\u30fc\u30f3\u30b7\u30e7\u30c3\u30c8\u3092\u64ae\u5f71\u3067\u304d\u308b\u3088\u3046\u306b\u3057\u307e\u3059\u3002<\/p>\n \u8a66\u3057\u306b\u5b9f\u884c\u3059\u308b\u3068\u3001\u30b9\u30af\u30ea\u30fc\u30f3\u30b7\u30e7\u30c3\u30c8\u304c\u751f\u6210\u3055\u308c\u307e\u3059\u3002<\/p>\n \u5b9f\u969b\u306b\u4ee5\u4e0b\u306e\u3088\u3046\u306a\u753b\u50cf\u304c\u751f\u6210\u3055\u308c\u307e\u3057\u305f\u3002 reg-suit\u3092\u5c0e\u5165\u3059\u308b\u3053\u3068\u3067\u3001\u30b9\u30af\u30ea\u30fc\u30f3\u30b7\u30e7\u30c3\u30c8\u306e\u5dee\u5206\u3092\u30c1\u30a7\u30c3\u30af\u3067\u304d\u308b\u3088\u3046\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n \u4f75\u305b\u3066\u3001\u4ee5\u4e0b\u306e\u30d7\u30e9\u30b0\u30a4\u30f3\u3092\u4f7f\u7528\u3057\u307e\u3059<\/p>\n reg-suit\u306e\u8a2d\u5b9a( S3\u30d0\u30b1\u30c3\u30c8\u306f\u624b\u52d5\u3067\u4f5c\u6210\u3057\u3066\u3044\u305f\u3060\u3044\u3066\u3082\u69cb\u3044\u307e\u305b\u3093\u3057\u3001 \u74b0\u5883\u5909\u6570\u3092\u8a2d\u5b9a\u3057\u305f\u4e0a\u3067\u624b\u5143\u306e\u30ed\u30fc\u30ab\u30eb\u74b0\u5883\u3067\u5b9f\u884c\u3059\u308b\u3068\u3001\u4ee5\u4e0b\u306e\u3088\u3046\u306a\u30ec\u30dd\u30fc\u30c8\u304c\u751f\u6210\u3055\u308c\u307e\u3059\u3002<\/p>\n <\/p>\n Slack\u306b\u3082\u901a\u77e5\u304c\u6765\u3066\u3044\u307e\u3059 \u6700\u5f8c\u306b\u30ed\u30fc\u30ab\u30eb\u3067\u5b9f\u884c\u3067\u304d\u305fstorycap+reg-suit\u306e\u64cd\u4f5c\u3092CodeBuild\u4e0a\u3067\u5b9f\u884c\u3067\u304d\u308b\u3088\u3046\u306b\u3057\u3066\u3044\u304d\u307e\u3059\u3002\u4eca\u56de\u306f\u30de\u30cd\u30fc\u30b8\u30c9\u578b\u30a4\u30e1\u30fc\u30b8\u306eUbuntu\u3092\u4f7f\u7528\u3057\u307e\u3059\u3002\u307e\u305f\u3001CodeBuild\u306e\u30b5\u30fc\u30d3\u30b9\u30ed\u30fc\u30eb\u4e0a\u3067S3\u3078\u306e\u30a2\u30c3\u30d7\u30ed\u30fc\u30c9\u3092\u8a31\u53ef\u3059\u308b\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n <\/p>\n \u4ee5\u4e0b\u306e\u3088\u3046\u306b AWS\u30b3\u30f3\u30bd\u30fc\u30eb\u4e0a\u3067S3\u30d0\u30b1\u30c3\u30c8\u540d\u3068Slack\u306eWebHookURL(\u3044\u305a\u308c\u3082\u5b9a\u6570)\u306e\u74b0\u5883\u5909\u6570\u3092\u30bb\u30c3\u30c8\u3057\u307e\u3059\u3002<\/p>\n <\/p>\n \u8a66\u3057\u306b\u610f\u56f3\u7684\u306b\u5dee\u5206\u3092\u767a\u751f\u3055\u305b\u305f\u72b6\u614b\u3067\u30bd\u30fc\u30b9\u3092push\u5f8c\u3001CodeBuild\u306e\u30d3\u30eb\u30c9\u3092\u5b9f\u884c\u3059\u308b\u3068\u3001\u624b\u5143\u306e\u30ed\u30fc\u30ab\u30eb\u74b0\u5883\u3067\u5b9f\u884c\u3057\u305f\u6642\u3068\u540c\u69d8\u306b\u30ec\u30dd\u30fc\u30c8\u304c\u4f5c\u6210\u3055\u308c\u3001Slack\u306b\u901a\u77e5\u3055\u308c\u307e\u3057\u305f\u3002<\/p>\n \u51fa\u529b\u3055\u308c\u305f\u30ec\u30dd\u30fc\u30c8\u4e0a\u3067\u30b9\u30af\u30ea\u30fc\u30f3\u30b7\u30e7\u30c3\u30c8\u306e\u5dee\u5206\u3092\u8996\u899a\u7684\u306b\u78ba\u8a8d\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002 Slack\u306b\u3082\u540c\u69d8\u306b\u901a\u77e5\u3055\u308c\u3066\u3044\u307e\u3059\u3002 \u5b9f\u969b\u306e\u904b\u7528\u3067\u306fCode4\u5144\u5f1f\u3067CI\/CD\u3092\u5b8c\u7d50\u3055\u305b\u308b\u524d\u63d0\u3067\u30d3\u30b8\u30e5\u30a2\u30eb\u30ea\u30b0\u30ec\u30c3\u30b7\u30e7\u30f3\u30c6\u30b9\u30c8\u3092\u5c0e\u5165\u3059\u308b\u5834\u5408\u306f\u4efb\u610f\u306e\u30d6\u30e9\u30f3\u30c1\u3067\u30d3\u30eb\u30c9\u304c\u5b9f\u884c\u3067\u304d\u308b\u3088\u3046\u306b\u8ffd\u52a0\u306e\u4f5c\u696d\u304c\u767a\u751f<\/a>\u3059\u308b\u3053\u3068\u3092\u8003\u616e\u3059\u308b\u3068\u3088\u308a\u4fbf\u5229\u306b\u306a\u308b\u306e\u3067\u306f\u306a\u3044\u3067\u3057\u3087\u3046\u304b\u3002<\/p>\n\n
\u624b\u9806<\/h2>\n
\u30b5\u30f3\u30d7\u30eb\u30a2\u30d7\u30ea\u4f5c\u6210~Storybook\u4f5c\u6210<\/h3>\n
\nnpx sb init<\/code>\u3092\u5b9f\u884c\u3059\u308b\u3068\u81ea\u52d5\u7684\u306b\u6700\u9069\u5316\u3055\u308c\u305f\u5f62\u3067Storybook\u306e\u8a2d\u5b9a\u304c\u5c0e\u5165\u3055\u308c\u307e\u3059\u3002\u305d\u306e\u305f\u3081\u4eca\u56de\u306fStorybook\u306e\u30d3\u30eb\u30c9\u30c4\u30fc\u30eb\u3082\u81ea\u52d5\u7684\u306bVite\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n
$ npm init vue@latest\n\n$ npx sb init<\/code><\/pre>\n
.storybook\/main.js<\/code>)\u3067Vue\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u7528\u306e
vite.config.js<\/code>\u306e\u8a2d\u5b9a\u3092\u518d\u5229\u7528\u3059\u308b\u3088\u3046\u306b\u6307\u5b9a\u3057\u307e\u3059\u3002<\/p>\n
const path = require("path")\nconst { mergeConfig, loadConfigFromFile } = require("vite")\n\nmodule.exports = {\n \/\/ \u4e00\u90e8\u7701\u7565\n async viteFinal(config, { configType }) {\n const { config: userConfig } = await loadConfigFromFile(\n path.resolve(__dirname, "..\/vite.config.ts")\n );\n return mergeConfig(config, {\n ...userConfig,\n plugins: [],\n });\n },\n}\n<\/code><\/pre>\n
\nStorybook\u3067\u306e\u898b\u305b\u65b9\u3092\u8abf\u6574\u3059\u308b\u610f\u56f3\u3067margin\u3092\u8a2d\u5b9a\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\nimport TheWelcome from '.\/TheWelcome.vue';\nimport '..\/assets\/base.css'\nimport type { Meta } from '@storybook\/vue3';\n\nexport default {\n title: 'TheWelcome',\n component: TheWelcome,\n decorators: [() => ({ template: '<div style="margin: 3em;"><story \/><\/div>' })],\n} as Meta<typeof TheWelcome>;\n\nexport const Sample = () => ({\n components: { TheWelcome },\n template: '<TheWelcome> <\/TheWelcome>',\n});<\/code><\/pre>\n
\n<\/p>\nstorycap\u5c0e\u5165<\/h3>\n
$ npm i -D storycap<\/code><\/pre>\n
$ npx storycap --serverCmd "npx start-storybook -p 6060 --ci" http:\/\/localhost:6060\ninfo Wait for connecting storybook server http:\/\/localhost:6060.\ninfo Executable Chromium path: \/Applications\/Google Chrome.app\/Contents\/MacOS\/Google Chrome\ninfo Storycap runs with simple mode\ninfo Found 1 stories.\ninfo Screenshot stored: __screenshots__\/TheWelcome\/Sample.png in 657 msec.\ninfo Screenshot was ended successfully in 60326 msec capturing 1 PNGs.<\/code><\/pre>\n
\n<\/p>\nreg-suit\u5c0e\u5165<\/h3>\n
$ npm install -D reg-suit<\/code><\/pre>\n
\n
$ npm i reg-simple-keygen-plugin -D\n$ npm i reg-keygen-git-hash-plugin -D\n$ npm i reg-notify-slack-plugin -D<\/code><\/pre>\n
regconfig.json<\/code>)\u3067\u306f\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u5f8c\u307b\u3069CodeBuild\u4e0a\u3067\u5b9f\u884c\u3059\u308b\u3053\u3068\u3092\u8e0f\u307e\u3048\u3066\u3001\u74b0\u5883\u5909\u6570\u3067\u6307\u5b9a\u3059\u308b\u5f62\u5f0f\u3067\u8a18\u8ff0\u3057\u307e\u3059\u3002
\n\u307e\u305f\u3001regconfig.json<\/code>\u306b\u76f4\u63a5\u8a18\u8ff0\u3059\u308b\u65b9\u6cd5\u4ee5\u5916\u306b\u3082\u3001
npx reg-suit init<\/code>\u30b3\u30de\u30f3\u30c9\u3092\u5b9f\u884c\u3059\u308b\u3068\u5bfe\u8a71\u5f62\u5f0f\u3067\u8a2d\u5b9a\u3092\u6c7a\u5b9a\u3057\u3066\u3044\u304f\u3053\u3068\u3082\u3067\u304d\u307e\u3059\u3002<\/p>\n
{\n "core": {\n "workingDir": ".reg",\n "actualDir": "__screenshots__",\n "thresholdRate": 0,\n "addIgnore": true,\n "ximgdiff": {\n "invocationType": "client"\n }\n },\n "plugins": {\n "reg-notify-slack-plugin": {\n "webhookUrl": "$SLACK_WEBHOOK_URL"\n },\n "reg-publish-s3-plugin": {\n "bucketName": "$S3_BUCKET_NAME"\n },\n "reg-simple-keygen-plugin": {\n "expectedKey": "$EXPECTED_KEY",\n "actualKey": "$ACTUAL_KEY"\n }\n }\n}<\/code><\/pre>\n
npx reg-suit prepare -p publish-s3<\/code>\u30b3\u30de\u30f3\u30c9\u3067\u81ea\u52d5\u3067\u4f5c\u6210\u3057\u3066\u3044\u305f\u3060\u304f\u3053\u3068\u3082\u53ef\u80fd\u3067\u3059\u3002<\/p>\n
$ npx reg-suit run<\/code><\/pre>\n
\n<\/p>\nCodeBuild\u8a2d\u5b9a<\/h3>\n
buildspec.yml<\/code>\u3092\u8a18\u8ff0\u3057\u307e\u3059\u3002CodeBuild\u4e0a\u3067Storybook\u3092Headless\u30e2\u30fc\u30c9\u3067\u8d77\u52d5\u3057\u3066\u3044\u307e\u3059\u3002\u307e\u305f\u3001Chrome\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3059\u308b\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002
\nreg-simple-keygen-plugin<\/code>\u306e\u5b9f\u969b\u5024(actual)Git\u30b3\u30df\u30c3\u30c8\u30cf\u30c3\u30b7\u30e5\u5024\u3068\u3057\u3066\u3001CodeBuild\u306b\u4e88\u3081\u7528\u610f\u3055\u308c\u3066\u3044\u308b\u74b0\u5883\u5909\u6570<\/a>\u3092\u6307\u5b9a\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n
version: 0.2\n\nenv:\n variables:\n EXPECTED_KEY: ""\n ACTUAL_KEY: ""\n\nphases:\n install:\n runtime-versions:\n nodejs: latest\n commands:\n # install node.js\n - npm i -g npm@latest\n - npm pkg get engines.node | sed 's\/"\/\/g' | xargs n\n # install packages\n - npm ci\n # chrome\n - curl -sS -o - https:\/\/dl-ssl.google.com\/linux\/linux_signing_key.pub | apt-key add -\n - echo "deb http:\/\/dl.google.com\/linux\/chrome\/deb\/ stable main" >> \/etc\/apt\/sources.list.d\/google-chrome.list\n - apt-get -y update\n - apt-get -y install google-chrome-stable\n pre_build:\n commands:\n - npx storycap --serverCmd "npx start-storybook -p 6060 --ci" http:\/\/localhost:6060\n - EXPECTED_KEY=$(git rev-parse origin\/main)\n - ACTUAL_KEY=$CODEBUILD_RESOLVED_SOURCE_VERSION\n - npm run reg-suit<\/code><\/pre>\n
\n<\/p>\n
\n<\/p>\n
\n<\/p>\n\u53c2\u8003<\/h2>\n