diff --git a/.circleci/config.yml b/.circleci/config.yml index eb5494e7e43d..6709cc29daf3 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -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: @@ -257,7 +257,6 @@ jobs: parameters: parallelism: type: integer - default: 2 executor: class: medium name: sb_node_16_browsers @@ -282,7 +281,6 @@ jobs: parameters: parallelism: type: integer - default: 2 executor: class: medium name: sb_node_16_browsers @@ -303,7 +301,6 @@ jobs: parameters: parallelism: type: integer - default: 2 executor: class: large name: sb_node_16_browsers @@ -338,7 +335,6 @@ jobs: parameters: parallelism: type: integer - default: 2 executor: class: medium name: sb_playwright @@ -359,7 +355,6 @@ jobs: parameters: parallelism: type: integer - default: 2 executor: class: large name: sb_playwright @@ -380,7 +375,6 @@ jobs: parameters: parallelism: type: integer - default: 2 executor: class: medium name: sb_node_16_browsers @@ -400,7 +394,6 @@ jobs: parameters: parallelism: type: integer - default: 2 executor: class: medium name: sb_playwright @@ -424,7 +417,6 @@ jobs: parameters: parallelism: type: integer - default: 2 executor: class: medium name: sb_playwright @@ -448,7 +440,6 @@ jobs: parameters: parallelism: type: integer - default: 2 executor: class: medium name: sb_playwright @@ -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 @@ -554,6 +500,7 @@ workflows: requires: - build-sandboxes - e2e-dev: + parallelism: 2 requires: - create-sandboxes - test-runner-production: diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index 655dd310ffaf..c4caf9cb3f0e 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -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"]` diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 23a8f37bfaa4..d319a540c376 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -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: @@ -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 @@ -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` diff --git a/.github/workflows/trigger-circle-ci-workflow.yml b/.github/workflows/trigger-circle-ci-workflow.yml index 7b1f853bde1e..2547a08218a3 100644 --- a/.github/workflows/trigger-circle-ci-workflow.yml +++ b/.github/workflows/trigger-circle-ci-workflow.yml @@ -10,6 +10,10 @@ on: - next - main +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + jobs: get-branch: runs-on: ubuntu-latest @@ -32,31 +36,12 @@ 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" \ @@ -64,7 +49,7 @@ jobs: -d '{ "branch": "'"$BRANCH"'", "parameters": { - "workflow": "pr" + "workflow": "normal" } }' env: @@ -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: > diff --git a/code/lib/cli/src/sandbox-templates.ts b/code/lib/cli/src/sandbox-templates.ts index a8babd756aff..5b19a3d8d4ad 100644 --- a/code/lib/cli/src/sandbox-templates.ts +++ b/code/lib/cli/src/sandbox-templates.ts @@ -534,9 +534,9 @@ export const allTemplates: Record = { ...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', @@ -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', @@ -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 }; diff --git a/code/lib/manager-api/src/modules/whatsnew.ts b/code/lib/manager-api/src/modules/whatsnew.ts index 21d0596683f6..5890eaae6fc7 100644 --- a/code/lib/manager-api/src/modules/whatsnew.ts +++ b/code/lib/manager-api/src/modules/whatsnew.ts @@ -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 diff --git a/code/lib/telemetry/package.json b/code/lib/telemetry/package.json index 31a3f8b1ffa7..8ad9770dfae6 100644 --- a/code/lib/telemetry/package.json +++ b/code/lib/telemetry/package.json @@ -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", diff --git a/code/lib/telemetry/src/storybook-metadata.ts b/code/lib/telemetry/src/storybook-metadata.ts index d17294256497..01a54d9c9ec0 100644 --- a/code/lib/telemetry/src/storybook-metadata.ts +++ b/code/lib/telemetry/src/storybook-metadata.ts @@ -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'; @@ -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 { diff --git a/code/lib/telemetry/src/types.ts b/code/lib/telemetry/src/types.ts index 25100149fd44..ba3af37719c0 100644 --- a/code/lib/telemetry/src/types.ts +++ b/code/lib/telemetry/src/types.ts @@ -54,6 +54,9 @@ export type StorybookMetadata = { hasCustomBabel?: boolean; features?: StorybookConfig['features']; refCount?: number; + preview?: { + usesGlobals?: boolean; + }; }; export interface Payload { diff --git a/code/yarn.lock b/code/yarn.lock index 820f77a52beb..746279daa5dc 100644 --- a/code/yarn.lock +++ b/code/yarn.lock @@ -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 diff --git a/scripts/dangerfile.ts b/scripts/dangerfile.ts index 375f45f176bf..6e8c5a2536ae 100644 --- a/scripts/dangerfile.ts +++ b/scripts/dangerfile.ts @@ -17,6 +17,8 @@ const Versions = { MAJOR: 'MAJOR', }; +const ciLabels = ['ci:normal', 'ci:merged', 'ci:daily']; + const branchVersion = Versions.MINOR; const checkRequiredLabels = (labels: string[]) => { @@ -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) => {