Skip to content

Commit

Permalink
chore(circleci): caching again (#3771)
Browse files Browse the repository at this point in the history
  • Loading branch information
greg-in-a-box authored Dec 13, 2024
1 parent 3555ff5 commit 1202142
Show file tree
Hide file tree
Showing 10 changed files with 142 additions and 159 deletions.
201 changes: 107 additions & 94 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,135 +1,148 @@
aliases:
- &yarn
name: Installing dependencies
command: yarn install --non-interactive --frozen-lockfile --cache-folder ~/.cache/yarn
version: 2.1

- &clean
name: Cleaning
command: yarn cache clean

- &i18n
name: Building locales
command: yarn build:i18n
executors:
default:
docker:
- image: cimg/node:18.18
user: root
resource_class: large
working_directory: ~/buie
cypress-executor:
docker:
- image: cypress/included:13.13.0
user: root
resource_class: large
working_directory: ~/buie

- &build
name: Building project
command: yarn build:prod:npm
commands:
yarn-install:
steps:
- run:
name: Installing dependencies
command: yarn install --non-interactive --frozen-lockfile --cache-folder /node_modules

- &restore-yarn-cache
keys:
- yarn-cache-{{ .Branch }}-{{ checksum "yarn.lock" }}
- yarn-cache-{{ .Branch }}-
build-locales:
steps:
- run:
name: Building locales
command: yarn --cwd /buie build:i18n

- &save-yarn-cache
paths:
- ~/.cache/yarn
- node_modules
key: yarn-cache-{{ .Branch }}-{{ checksum "yarn.lock" }}
build-project:
steps:
- run:
name: Building project
command: yarn --cwd /buie build:prod:npm

- &prepare-cache
name: Prepare Yarn Cache
command: |
mkdir -p ~/.cache/yarn
chown -R $(whoami) ~/.cache/yarn
restore-yarn-cache:
steps:
- restore_cache:
keys:
- yarn-cache-v5-{{ checksum "yarn.lock" }}

defaults: &defaults
resource_class: large
working_directory: ~/buie
docker:
- image: cimg/node:18.18
save-yarn-cache:
steps:
- save_cache:
key: yarn-cache-v5-{{ checksum "yarn.lock" }}
paths:
- ./node_modules

version: 2
setup-workspace:
steps:
- attach_workspace:
at: /buie

jobs:
setup:
executor: default
steps:
- checkout
- restore-yarn-cache
- yarn-install
- save-yarn-cache
- persist_to_workspace:
root: .
paths:
- .

lint:
<<: *defaults
executor: default
steps:
- checkout
- run: *prepare-cache
- restore-cache: *restore-yarn-cache
- run: *yarn
- save-cache: *save-yarn-cache
- run: *clean
- run: *i18n
- setup-workspace
- build-locales
- run:
name: Commit lint
command: ./scripts/commitlint.sh
command: /buie/scripts/commitlint.sh
- run:
name: Code lint
command: yarn lint
command: yarn --cwd /buie lint

flow:
<<: *defaults
steps:
- checkout
- run: *prepare-cache
- restore-cache: *restore-yarn-cache
- run: *yarn
- save-cache: *save-yarn-cache
- run: *clean
- run:
name: Flow
command: yarn flow check
executor: default
steps:
- checkout
- setup-workspace
- run:
name: Flow
command: yarn --cwd /buie flow check

build-unit-tests:
<<: *defaults
executor: default
steps:
- checkout
- run: *prepare-cache
- restore-cache: *restore-yarn-cache
- run: *yarn
- save-cache: *save-yarn-cache
- run: *clean
- run: *i18n
- setup-workspace
- build-locales
- run:
name: Babel build
command: yarn build:ci:es
command: yarn --cwd /buie build:ci:es
- run:
name: Checking locales and styles
command: ./scripts/check_generated_files.sh
command: /buie/scripts/check_generated_files.sh
- run:
name: Webpack build
command: yarn build:ci:dist
command: yarn --cwd /buie build:ci:dist
- run: echo 'export TZ=America/Los_Angeles' >> $BASH_ENV
- run:
name: Unit tests
command: yarn test --maxWorkers=3
command: yarn --cwd /buie test --maxWorkers=3

e2e-tests:
<<: *defaults
docker:
- image: cypress/included:13.13.0
steps:
- checkout
- run: *prepare-cache
- restore-cache: *restore-yarn-cache
- run: *yarn
- save-cache: *save-yarn-cache
- run:
name: E2E tests
command: yarn test:e2e
executor: cypress-executor
steps:
- checkout
- setup-workspace
- run:
name: Cypress run
command: yarn --cwd /buie test:e2e

chromatic-deploy:
<<: *defaults
executor: default
steps:
- checkout
- run: *prepare-cache
- restore-cache: *restore-yarn-cache
- run: *yarn
- save-cache: *save-yarn-cache
- run: *clean
- run: *i18n
- run: *build
- run:
name: Chromatic
command: yarn chromatic
- checkout
- setup-workspace
- build-locales
- build-project
- run:
name: Chromatic
command: yarn --cwd /buie chromatic

workflows:
version: 2
lint_test_build:
jobs:
- lint
- flow
- build-unit-tests
- e2e-tests
- chromatic-deploy
- setup
- lint:
requires:
- setup
- flow:
requires:
- setup
- build-unit-tests:
requires:
- setup
- e2e-tests:
requires:
- setup
- chromatic-deploy:
requires:
- setup
1 change: 0 additions & 1 deletion .storybook/preview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ const preview = {
parameters: {
chromatic: {
cropToViewport: true,
delay: 1000,
modes: {
specific: {
viewport: {
Expand Down
2 changes: 1 addition & 1 deletion chromatic.config.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"autoAcceptChanges": "master",
"buildScriptName": "build:prod:storybook",
"onlyStoryFiles": ["./src/**/stories/tests/*.stories.@(js|jsx|ts|tsx)"],
"onlyChanged": true,
"skip": "mojito"
}
2 changes: 1 addition & 1 deletion scripts/check_generated_files.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ check_generated_files() {
printf "${blue}-------------------------------------------------------------${end}"
printf "${blue}Building bundles again, this may update en-US.properties${end}"
printf "${blue}-------------------------------------------------------------${end}"
yarn build:i18n || return 1
yarn --cwd /buie build:i18n || return 1

if [[ $(git status --porcelain 2>/dev/null | egrep "^(M| M)") != "" ]]; then
printf "${red}Your PR has uncommitted files!${end}"
Expand Down
Empty file added scripts/chromatic.sh
Empty file.
2 changes: 1 addition & 1 deletion scripts/commitlint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@ then
echo "Head SHA1 $HEAD_SHA1"
COMMIT_RANGE="${BASE_SHA1}...${HEAD_SHA1}"
echo "Linting ${COMMIT_RANGE}"
git log ${COMMIT_RANGE} --pretty=%B | ./node_modules/.bin/commitlint
git log ${COMMIT_RANGE} --pretty=%B | yarn --cwd /buie commitlint
fi
50 changes: 5 additions & 45 deletions src/elements/__mocks__/mockRequests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@ import { DEFAULT_HOSTNAME_API } from '../../constants';

const apiV2Path = `${DEFAULT_HOSTNAME_API}/2.0`;

export const mockEventRequest = {
url: `${apiV2Path}/events`,
response: {},
};

export const mockUserRequest = {
url: `${apiV2Path}/users/me`,
response: {
Expand All @@ -20,7 +25,6 @@ export const mockUserRequest = {
job_title: '',
phone: '',
address: '',
avatar_url: 'https://previewteam.app.box.com/api/avatar/large/7504104663',
notification_email: null,
},
};
Expand Down Expand Up @@ -57,53 +61,9 @@ export const mockFileRequest = {
name: 'Document (PDF).pdf',
size: 792687,
extension: 'pdf',
representations: {
entries: [
{
representation: 'jpg',
properties: {
dimensions: '1024x1024',
paged: 'false',
thumb: 'false',
},
info: {
url: 'https://api.box.com/2.0/internal_files/415542803939/versions/780895440222/representations/jpg_1024x1024',
},
status: {
state: 'success',
},
content: {
url_template:
'https://dl.boxcloud.com/api/2.0/internal_files/415542803939/versions/780895440222/representations/jpg_1024x1024/content/{+asset_path}',
},
},
{
representation: 'png',
properties: {
dimensions: '2048x2048',
paged: 'true',
thumb: 'false',
},
info: {
url: 'https://api.box.com/2.0/internal_files/415542803939/versions/780895440222/representations/png_paged_2048x2048',
},
status: {
state: 'success',
},
content: {
url_template:
'https://dl.boxcloud.com/api/2.0/internal_files/415542803939/versions/780895440222/representations/png_paged_2048x2048/content/{+asset_path}',
},
metadata: {
pages: 2,
},
},
],
},
watermark_info: {
is_watermarked: false,
},
authenticated_download_url: 'https://dl.boxcloud.com/api/2.0/files/415542803939/content',
is_download_available: true,
},
};
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ import { expect, userEvent, waitFor, within } from '@storybook/test';
import { Notification } from '@box/blueprint-web';
import { http, HttpResponse } from 'msw';

import { mockFileRequest, mockUserRequest } from '../../../__mocks__/mockRequests';
import { mockEventRequest, mockFileRequest, mockUserRequest } from '../../../__mocks__/mockRequests';
import { DEFAULT_HOSTNAME_API } from '../../../../constants';

import ContentPreview from '../../ContentPreview';

const WAIT_TIMEOUT = 2000;
const WAIT_TIMEOUT = 5000;

export const basic = {
play: async ({ canvasElement }) => {
Expand Down Expand Up @@ -250,6 +250,9 @@ export default {
parameters: {
msw: {
handlers: [
http.post(mockEventRequest.url, () => {
return HttpResponse.json(mockEventRequest.response);
}),
http.get(mockUserRequest.url, () => {
return HttpResponse.json(mockUserRequest.response);
}),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { http, HttpResponse } from 'msw';
import ContentSidebar from '../../ContentSidebar';
import BoxAISidebar from '../../BoxAISidebar';
import { mockAgents } from '../__mocks__/BoxAISidebarMocks';
import { mockFileRequest } from '../../../__mocks__/mockRequests';
import { mockFileRequest, mockUserRequest } from '../../../__mocks__/mockRequests';

const mockFeatures = {
'boxai.sidebar.enabled': true,
Expand Down Expand Up @@ -65,6 +65,9 @@ export default {
parameters: {
msw: {
handlers: [
http.get(mockUserRequest.url, () => {
return HttpResponse.json(mockUserRequest.response);
}),
http.get(mockFileRequest.url, () => {
return HttpResponse.json(mockFileRequest.response);
}),
Expand Down
Loading

0 comments on commit 1202142

Please sign in to comment.