Skip to content

Commit

Permalink
Merge pull request #23335 from storybookjs/valentin/introduce-ci-normal
Browse files Browse the repository at this point in the history
CircleCI: Introduce ci:normal label
  • Loading branch information
valentinpalkovic committed Jul 13, 2023
2 parents 41973a7 + 388a899 commit 6f4883c
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 91 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']
default: 'normal'

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
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 };
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 6f4883c

Please sign in to comment.