Skip to content

Commit

Permalink
Merge pull request #171 from storybookjs/next
Browse files Browse the repository at this point in the history
Release 0.6.0
  • Loading branch information
yannbf authored Aug 23, 2022
2 parents 5a43421 + 4cae157 commit 0360141
Show file tree
Hide file tree
Showing 37 changed files with 1,057 additions and 269 deletions.
114 changes: 108 additions & 6 deletions .github/workflows/nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,15 @@ name: Nightly checks
# runs every day at midnight
on:
schedule:
- cron: "0 0 * * *"
- cron: '0 0 * * *'
workflow_dispatch:
# To test fixes on push rather than wait for the scheduling
push:
branches:
- fix/nightly

jobs:
test_storybook_prerelease:
assert_test_runner:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
Expand All @@ -24,15 +29,14 @@ jobs:
echo "prev_sb_version=$(yarn list @storybook/react --depth=0 2> /dev/null | grep @storybook/react | awk -F'@' '{print $3}')" >> $GITHUB_ENV
echo "prev_sb_csf_version=$(yarn list @storybook/csf --depth=0 2> /dev/null | grep @storybook/csf | awk -F'@' '{print $3}')" >> $GITHUB_ENV
- name: Upgrade to storybook@next
- name: Upgrade to storybook@future
run: |
npx storybook upgrade --prerelease
npx storybook@future upgrade --prerelease --yes
# TODO: This should not be necessary once @storybook/csf is properly updated
- name: Fix local @storybook/csf version
run: |
yarn add @storybook/csf@0.0.2--canary.4566f4d.1
- name: Run test runner
uses: mathiasvr/command-output@v1
id: tests
Expand All @@ -52,7 +56,7 @@ jobs:
id: slack
uses: slackapi/slack-github-action@v1.19.0
with:
channel-id: "${{ secrets.SLACK_CHANNEL_ID }}"
channel-id: '${{ secrets.SLACK_CHANNEL_ID }}'
payload: |
{
"blocks": [
Expand Down Expand Up @@ -92,3 +96,101 @@ jobs:
}
env:
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}

assert_test_runner_failures:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- name: Use Node.js 14.x
uses: actions/setup-node@v1
with:
node-version: 14.x

- name: Install dependencies
uses: bahmutov/npm-install@v1

- name: Get current version of Storybook
run: |
echo "prev_sb_version=$(yarn list @storybook/react --depth=0 2> /dev/null | grep @storybook/react | awk -F'@' '{print $3}')" >> $GITHUB_ENV
echo "prev_sb_csf_version=$(yarn list @storybook/csf --depth=0 2> /dev/null | grep @storybook/csf | awk -F'@' '{print $3}')" >> $GITHUB_ENV
- name: Upgrade to storybook@future
run: |
npx storybook@future upgrade --prerelease --yes
# TODO: This should not be necessary once @storybook/csf is properly updated
- name: Fix local @storybook/csf version
run: |
yarn add @storybook/csf@0.0.2--canary.4566f4d.1
- name: Run test runner and expect failure
uses: mathiasvr/command-output@v1
with:
run: |
yarn build
yarn test-storybook:ci-failures
- name: Process test results
if: ${{ always() }}
id: tests
uses: sergeysova/jq-action@v2
with:
cmd: 'jq .numPassedTests test-results.json -r'

- name: Set failure check to env
if: ${{ always() }}
run: |
echo "FAILED=${{ steps.tests.outputs.value > 0 }}" >> $GITHUB_ENV
- name: Get prerelease version of Storybook
if: ${{ always() && env.FAILED == 'true' }}
run: |
echo "sb_version=$(yarn list @storybook/react --depth=0 2> /dev/null | grep @storybook/react | awk -F'@' '{print $3}')" >> $GITHUB_ENV
echo "sb_csf_version=$(yarn list @storybook/csf --depth=0 2> /dev/null | grep @storybook/csf | awk -F'@' '{print $3}')" >> $GITHUB_ENV
- name: Report if any test passes
if: ${{ always() && env.FAILED == 'true' }}
id: slack
uses: slackapi/slack-github-action@v1.19.0
with:
channel-id: '${{ secrets.SLACK_CHANNEL_ID }}'
payload: |
{
"blocks": [
{
"type": "header",
"text": {
"type": "plain_text",
"text": ":storybook: :runner: [Test Runner] The Nightly check for **failures** has passed :thinking_face:",
"emoji": true
}
},
{
"type": "section",
"fields": [
{
"type": "mrkdwn",
"text": "*@storybook/react version:*\n${{ env.prev_sb_version }} >> ${{ env.sb_version }}"
},
{
"type": "mrkdwn",
"text": "*@storybook/csf version:*\n${{ env.prev_sb_csf_version }} >> ${{ env.sb_csf_version }}"
}
],
"accessory": {
"type": "button",
"text": {
"type": "plain_text",
"text": "View failure",
"emoji": true
},
"value": "view_failure",
"url": "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}",
"action_id": "button-action"
}
}
]
}
env:
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,4 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
run: |
yarn release
yarn release
2 changes: 1 addition & 1 deletion .github/workflows/stress-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Stress Tests

on:
pull_request:
types: [ labeled ]
types: [labeled]

jobs:
test:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
run: |
yarn build
yarn test-storybook:ci-coverage
- name: Generate code coverage
uses: codecov/codecov-action@v2
with:
Expand Down
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@ build-storybook.log
stories/atoms/StressTest.stories.js
yarn-error.log
.nyc_output
coverage
coverage
test-results.json
4 changes: 4 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

npx lint-staged
7 changes: 7 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -1 +1,8 @@
dist
node_modules
storybook-static
.cache
.env
*.snap
__snapshots__
CHANGELOG.md
20 changes: 12 additions & 8 deletions .storybook/main.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const stories = [
let stories = [
'../stories/docs/**/*.stories.mdx',
// default title prefix
{
Expand All @@ -18,14 +18,18 @@ if (process.env.STRESS_TEST) {
stories.push('../stories/stress-test/*.stories.@(js|jsx|ts|tsx)');
}

if (process.env.TEST_FAILURES) {
stories = ['../stories/expected-failures/*.stories.@(js|jsx|ts|tsx)'];
}

const addons = [
process.env.WITHOUT_DOCS
? {
name: '@storybook/addon-essentials',
options: {
docs: false,
},
}
name: '@storybook/addon-essentials',
options: {
docs: false,
},
}
: '@storybook/addon-essentials',
'@storybook/addon-interactions',
'@storybook/addon-coverage',
Expand All @@ -39,6 +43,6 @@ module.exports = {
buildStoriesJson: true,
},
core: {
disableTelemetry: true
}
disableTelemetry: true,
},
};
5 changes: 5 additions & 0 deletions .storybook/test-runner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import type { TestRunnerConfig } from '../dist/ts';

const snapshotsDir = process.env.SNAPSHOTS_DIR || '__snapshots__';
const customSnapshotsDir = `${process.cwd()}/${snapshotsDir}`;
const skipSnapshots = process.env.SKIP_SNAPSHOTS === 'true';

const config: TestRunnerConfig = {
setup() {
Expand All @@ -17,6 +18,10 @@ const config: TestRunnerConfig = {
return;
}

if (skipSnapshots) {
return;
}

// Visual snapshot tests
const image = await page.screenshot({ fullPage: true });
expect(image).toMatchImageSnapshot({
Expand Down
2 changes: 1 addition & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@
"titleBar.activeBackground": "#004752",
"titleBar.activeForeground": "#ECFCFF"
}
}
}
Loading

0 comments on commit 0360141

Please sign in to comment.