Skip to content

Commit

Permalink
Merge branch 'next' into fix/jsdoc
Browse files Browse the repository at this point in the history
  • Loading branch information
kasperpeulen authored Jul 13, 2023
2 parents 2cac7d9 + 471bd4d commit 0b3653b
Show file tree
Hide file tree
Showing 11 changed files with 63 additions and 95 deletions.
63 changes: 5 additions & 58 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ parameters:
workflow:
description: Which workflow to run
type: enum
enum: ['ci', 'pr', 'merged', 'daily']
default: 'ci'
enum: ['normal', 'merged', 'daily', 'skipped']
default: 'skipped'

executors:
sb_node_16_classic:
Expand Down Expand Up @@ -257,7 +257,6 @@ jobs:
parameters:
parallelism:
type: integer
default: 2
executor:
class: medium
name: sb_node_16_browsers
Expand All @@ -282,7 +281,6 @@ jobs:
parameters:
parallelism:
type: integer
default: 2
executor:
class: medium
name: sb_node_16_browsers
Expand All @@ -303,7 +301,6 @@ jobs:
parameters:
parallelism:
type: integer
default: 2
executor:
class: large
name: sb_node_16_browsers
Expand Down Expand Up @@ -338,7 +335,6 @@ jobs:
parameters:
parallelism:
type: integer
default: 2
executor:
class: medium
name: sb_playwright
Expand All @@ -359,7 +355,6 @@ jobs:
parameters:
parallelism:
type: integer
default: 2
executor:
class: large
name: sb_playwright
Expand All @@ -380,7 +375,6 @@ jobs:
parameters:
parallelism:
type: integer
default: 2
executor:
class: medium
name: sb_node_16_browsers
Expand All @@ -400,7 +394,6 @@ jobs:
parameters:
parallelism:
type: integer
default: 2
executor:
class: medium
name: sb_playwright
Expand All @@ -424,7 +417,6 @@ jobs:
parameters:
parallelism:
type: integer
default: 2
executor:
class: medium
name: sb_playwright
Expand All @@ -448,7 +440,6 @@ jobs:
parameters:
parallelism:
type: integer
default: 2
executor:
class: medium
name: sb_playwright
Expand All @@ -468,54 +459,9 @@ jobs:
template: $(yarn get-template --cadence << pipeline.parameters.workflow >> --task bench)

workflows:
ci:
normal:
when:
and:
- equal: [api, << pipeline.trigger_source >>]
- equal: [ci, << pipeline.parameters.workflow >>]
jobs:
- pretty-docs
- build
- lint:
requires:
- build
- check:
requires:
- build
- unit-tests:
requires:
- build
- script-unit-tests:
requires:
- build
- chromatic-internal-storybooks:
requires:
- build
- create-sandboxes:
requires:
- build
- build-sandboxes:
requires:
- create-sandboxes
- chromatic-sandboxes:
requires:
- build-sandboxes
- e2e-production:
requires:
- build-sandboxes
- e2e-dev:
requires:
- create-sandboxes
- test-runner-production:
requires:
- build-sandboxes
# TODO: reenable once we find out the source of flakyness
# - test-runner-dev:
# requires:
# - create-sandboxes
pr:
when:
equal: [pr, << pipeline.parameters.workflow >>]
equal: [normal, << pipeline.parameters.workflow >>]
jobs:
- pretty-docs
- build
Expand Down Expand Up @@ -554,6 +500,7 @@ workflows:
requires:
- build-sandboxes
- e2e-dev:
parallelism: 2
requires:
- create-sandboxes
- test-runner-production:
Expand Down
3 changes: 1 addition & 2 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@ Closes #

#### Maintainers

- [ ] If this PR should be tested against many or all sandboxes,
make sure to add the `ci:merged` or `ci:daily` GH label to it.
- [ ] When this PR is ready for testing, make sure to add `ci:normal`, `ci:merged` or `ci:daily` GH label to it to run a specific set of sandboxes. The particular set of sandboxes can be found in `code/lib/cli/src/sandbox-templates.ts`
- [ ] Make sure this PR contains **one** of the labels below.

`["cleanup", "BREAKING CHANGE", "feature request", "bug", "documentation", "maintenance", "dependencies", "other"]`
Expand Down
13 changes: 11 additions & 2 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,15 @@ jobs:
run:
working-directory: scripts
steps:
- name: Cancel if [skip ci]
if: contains(github.event.head_commit.message, '[skip ci]')
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# From https://stackoverflow.com/a/75809743
run: |
gh run cancel ${{ github.run_id }}
gh run watch ${{ github.run_id }}
- name: Checkout ${{ github.ref_name }}
uses: actions/checkout@v3
with:
Expand Down Expand Up @@ -71,7 +80,7 @@ jobs:
git config --global user.name "storybook-bot"
git config --global user.email "32066757+storybook-bot@users.noreply.github.com"
git add .
git commit -m "Bump version from $CURRENT_VERSION to $DEFERRED_NEXT_VERSION" || true
git commit -m "Bump version from $CURRENT_VERSION to $DEFERRED_NEXT_VERSION [skip ci]" || true
git push origin ${{ github.ref_name }}
- name: Get current version
Expand Down Expand Up @@ -149,7 +158,7 @@ jobs:
git pull
git checkout origin/main ./CHANGELOG.md
git add ./CHANGELOG.md
git commit -m "Update CHANGELOG.md for v${{ steps.version.outputs.current-version }}"
git commit -m "Update CHANGELOG.md for v${{ steps.version.outputs.current-version }} [skip ci]"
git push origin next
- name: Sync versions/next.json from `next` to `main`
Expand Down
33 changes: 9 additions & 24 deletions .github/workflows/trigger-circle-ci-workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ on:
- next
- main

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
get-branch:
runs-on: ubuntu-latest
Expand All @@ -32,39 +36,20 @@ jobs:
outputs:
branch: ${{ env.branch }}

trigger-ci-tests:
runs-on: ubuntu-latest
needs: get-branch
if: github.event_name == 'pull_request_target' && github.event.pull_request.draft == true && !contains(github.event.pull_request.labels.*.name, 'ci:pr') && !contains(github.event.pull_request.labels.*.name, 'ci:merged') && !contains(github.event.pull_request.labels.*.name, 'ci:daily')
steps:
- name: Trigger draft PR tests
run: >
curl -X POST --location "https://circleci.com/api/v2/project/gh/storybookjs/storybook/pipeline" \
-H "Content-Type: application/json" \
-H "Circle-Token: $CIRCLE_CI_TOKEN" \
-d '{
"branch": "'"$BRANCH"'",
"parameters": {
"workflow": "ci"
}
}'
env:
CIRCLE_CI_TOKEN: ${{ secrets.CIRCLE_CI_TOKEN }}
BRANCH: ${{ needs.get-branch.outputs.branch }}
trigger-pr-tests:
trigger-normal-tests:
runs-on: ubuntu-latest
needs: get-branch
if: github.event_name == 'pull_request_target' && (((github.event.pull_request.draft == false && !contains(github.event.pull_request.labels.*.name, 'release')) || contains(github.event.pull_request.labels.*.name, 'ci:pr')) && !contains(github.event.pull_request.labels.*.name, 'ci:merged') && !contains(github.event.pull_request.labels.*.name, 'ci:daily'))
if: github.event_name == 'pull_request_target' && contains(github.event.pull_request.labels.*.name, 'ci:normal')
steps:
- name: Trigger PR tests
- name: Trigger Normal tests
run: >
curl -X POST --location "https://circleci.com/api/v2/project/gh/storybookjs/storybook/pipeline" \
-H "Content-Type: application/json" \
-H "Circle-Token: $CIRCLE_CI_TOKEN" \
-d '{
"branch": "'"$BRANCH"'",
"parameters": {
"workflow": "pr"
"workflow": "normal"
}
}'
env:
Expand All @@ -73,7 +58,7 @@ jobs:
trigger-merged-tests:
runs-on: ubuntu-latest
needs: get-branch
if: github.event_name == 'push' || (contains(github.event.pull_request.labels.*.name, 'ci:merged') && !contains(github.event.pull_request.labels.*.name, 'ci:daily'))
if: github.event_name == 'push' || contains(github.event.pull_request.labels.*.name, 'ci:merged')
steps:
- name: Trigger merged tests
run: >
Expand Down
10 changes: 5 additions & 5 deletions code/lib/cli/src/sandbox-templates.ts
Original file line number Diff line number Diff line change
Expand Up @@ -534,9 +534,9 @@ export const allTemplates: Record<TemplateKey, Template> = {
...benchTemplates,
};

export const ci: TemplateKey[] = ['cra/default-ts', 'react-vite/default-ts'];
export const pr: TemplateKey[] = [
...ci,
export const normal: TemplateKey[] = [
'cra/default-ts',
'react-vite/default-ts',
'angular-cli/default-ts',
'vue3-vite/default-ts',
'vue-cli/vue2-default-js',
Expand All @@ -548,7 +548,7 @@ export const pr: TemplateKey[] = [
'bench/react-webpack-18-ts',
];
export const merged: TemplateKey[] = [
...pr,
...normal,
'react-webpack/18-ts',
'react-webpack/17-ts',
'angular-cli/15-ts',
Expand Down Expand Up @@ -578,4 +578,4 @@ export const daily: TemplateKey[] = [
'html-vite/default-js',
];

export const templatesByCadence = { ci, pr, merged, daily };
export const templatesByCadence = { normal, merged, daily };
6 changes: 4 additions & 2 deletions code/lib/manager-api/src/modules/whatsnew.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,12 @@ export const init: ModuleFn = ({ fullAPI, store }) => {
const whatsNewData = await getLatestWhatsNewPost();
setWhatsNewState(whatsNewData);

const isNewStoryBookUser = fullAPI.getUrlState().path.includes('onboarding');
const urlState = fullAPI.getUrlState();
const isOnboardingView =
urlState?.path === '/onboarding' || urlState.queryParams?.onboarding === 'true';

if (
!isNewStoryBookUser &&
!isOnboardingView &&
whatsNewData.status === 'SUCCESS' &&
!whatsNewData.disableWhatsNewNotifications &&
whatsNewData.showNotification
Expand Down
1 change: 1 addition & 0 deletions code/lib/telemetry/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
"dependencies": {
"@storybook/client-logger": "7.1.0-rc.1",
"@storybook/core-common": "7.1.0-rc.1",
"@storybook/csf-tools": "7.1.0-rc.1",
"chalk": "^4.1.0",
"detect-package-manager": "^2.0.1",
"fetch-retry": "^5.0.2",
Expand Down
11 changes: 11 additions & 0 deletions code/lib/telemetry/src/storybook-metadata.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
getProjectRoot,
} from '@storybook/core-common';
import type { StorybookConfig, PackageJson } from '@storybook/types';
import { readConfig } from '@storybook/csf-tools';

import type { StorybookMetadata, Dependency, StorybookAddon } from './types';
import { getActualPackageVersion, getActualPackageVersions } from './package-json';
Expand Down Expand Up @@ -160,6 +161,16 @@ export const computeStorybookMetadata = async ({
const hasStorybookEslint = !!allDependencies['eslint-plugin-storybook'];

const storybookInfo = getStorybookInfo(packageJson);

const { previewConfig } = storybookInfo;
if (previewConfig) {
const config = await readConfig(previewConfig);
const usesGlobals = !!(
config.getFieldNode(['globals']) || config.getFieldNode(['globalTypes'])
);
metadata.preview = { ...metadata.preview, usesGlobals };
}

const storybookVersion = storybookPackages[storybookInfo.frameworkPackage]?.version;

return {
Expand Down
3 changes: 3 additions & 0 deletions code/lib/telemetry/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ export type StorybookMetadata = {
hasCustomBabel?: boolean;
features?: StorybookConfig['features'];
refCount?: number;
preview?: {
usesGlobals?: boolean;
};
};

export interface Payload {
Expand Down
1 change: 1 addition & 0 deletions code/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -7452,6 +7452,7 @@ __metadata:
dependencies:
"@storybook/client-logger": 7.1.0-rc.1
"@storybook/core-common": 7.1.0-rc.1
"@storybook/csf-tools": 7.1.0-rc.1
chalk: ^4.1.0
detect-package-manager: ^2.0.1
fetch-retry: ^5.0.2
Expand Down
14 changes: 12 additions & 2 deletions scripts/dangerfile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ const Versions = {
MAJOR: 'MAJOR',
};

const ciLabels = ['ci:normal', 'ci:merged', 'ci:daily'];

const branchVersion = Versions.MINOR;

const checkRequiredLabels = (labels: string[]) => {
Expand Down Expand Up @@ -48,12 +50,20 @@ const checkRequiredLabels = (labels: string[]) => {
fail(`Please choose only one of these labels: ${JSON.stringify(foundRequiredLabels)}`);
}

const foundPatchLabels = intersection(['patch:no', 'patch:yes'], labels);
const labelsForPatchStatus = ['patch:no', 'patch:yes'];
const foundPatchLabels = intersection(labelsForPatchStatus, labels);
if (isEmpty(foundPatchLabels)) {
fail(`PR is not labeled with one of: ${JSON.stringify(foundPatchLabels)}`);
fail(`PR is not labeled with one of: ${JSON.stringify(labelsForPatchStatus)}`);
} else if (foundPatchLabels.length > 1) {
fail(`Please choose only one of these labels: ${JSON.stringify(foundPatchLabels)}`);
}

const foundCILabels = intersection(ciLabels, labels);
if (isEmpty(foundCILabels)) {
fail(`PR is not labeled with one of: ${JSON.stringify(ciLabels)}`);
} else if (foundCILabels.length > 1) {
fail(`Please choose only one of these labels: ${JSON.stringify(foundCILabels)}`);
}
};

const checkPrTitle = (title: string) => {
Expand Down

0 comments on commit 0b3653b

Please sign in to comment.