# Use the latest 2.1 version of CircleCI pipeline process engine # See: https://circleci.com/docs/2.0/configuration-reference version: 2.1 orbs: nx: nrwl/nx@1.7.0 browser-tools: circleci/browser-tools@1.5.3 # ---------------------------------------------------------------------------- # # Environment Variables # # ---------------------------------------------------------------------------- # env-vars: &env-vars NX_BRANCH: << pipeline.git.branch >> NX_VERBOSE_LOGGING: "true" PUPPETEER_SKIP_CHROMIUM_DOWNLOAD: "true" NODE_OPTIONS: "--max-old-space-size=4096" # ---------------------------------------------------------------------------- # # Reusable steps # # ---------------------------------------------------------------------------- # commands: setup-node: steps: - run: name: ๐Ÿ›  Setup Volta command: | export VOLTA_FEATURE_PNPM=1 curl https://get.volta.sh | bash echo 'export VOLTA_FEATURE_PNPM=1' >> $BASH_ENV echo 'export VOLTA_HOME=$HOME/.volta' >> $BASH_ENV echo 'export PATH=$VOLTA_HOME/bin:$PATH' >> $BASH_ENV source $BASH_ENV - run: name: ๐Ÿ”Ž Check Node and PNPM versions command: | node --version pnpm --version setup-deps: steps: # First, try to restore the pnpm store cache - restore_cache: name: ๐Ÿ’ซ Restore PNPM store cache keys: - pnpm-store-{{ arch }}-{{ checksum "pnpm-lock.yaml" }} - pnpm-store-{{ arch }}- - pnpm-store- # Then, try to restore node_modules cache - restore_cache: name: ๐Ÿ’ซ Restore node_modules cache keys: - node-modules-{{ arch }}-{{ checksum "pnpm-lock.yaml" }} - node-modules-{{ arch }}- - node-modules- # Install dependencies with network access but prefer offline when possible - run: name: ๐Ÿ“ฆ Install dependencies command: | # Create pnpm store directory mkdir -p /home/circleci/.pnpm-store # Enable pnpm store compression and other optimizations pnpm config set compression-level 9 pnpm config set store-dir /home/circleci/.pnpm-store pnpm config set prefer-offline true pnpm config set network-concurrency 8 # Install with network access but prefer offline packages PNPM_CACHE_DIR=/home/circleci/.pnpm-store pnpm install --frozen-lockfile --prefer-offline no_output_timeout: 5m # Save the pnpm store cache - save_cache: name: ๐Ÿ’พ Save PNPM store cache key: pnpm-store-{{ arch }}-{{ checksum "pnpm-lock.yaml" }} paths: - /home/circleci/.pnpm-store # Save the node_modules cache - save_cache: name: ๐Ÿ’พ Save node_modules cache key: node-modules-{{ arch }}-{{ checksum "pnpm-lock.yaml" }} paths: - ./node_modules - ./packages/beeq/node_modules - ./packages/beeq-angular/node_modules - ./packages/beeq-react/node_modules - ./packages/beeq-vue/node_modules - ./packages/beeq-tailwindcss/node_modules setup-browser-tools: steps: - browser-tools/install-chrome - browser-tools/install-chromedriver - run: name: ๐Ÿ” Verify Chrome Installation command: | google-chrome --version chromedriver --version echo "export PUPPETEER_EXECUTABLE_PATH=$(which google-chrome)" >> $BASH_ENV # ---------------------------------------------------------------------------- # # Jobs # # ---------------------------------------------------------------------------- # jobs: main: docker: - image: cimg/node:22.15.0-browsers resource_class: large environment: *env-vars steps: - checkout - setup-node - setup-deps - setup-browser-tools # Start Nx Cloud and run all tasks - run: name: ๐Ÿงพ NX report command: pnpm exec nx report - nx/set-shas - run: name: โ–ถ๏ธ Start Nx Cloud CI Run command: pnpm dlx nx-cloud start-ci-run --distribute-on="3 linux-medium-plus-js" --with-env-vars="NX_VERBOSE_LOGGING NX_BRANCH" # Run all Nx commands - run: name: ๐Ÿฉบ Run Linter, Formatter, and Import Sorting command: pnpm exec nx affected -t check --exclude='*,!tag:core' --parallel --base=$NX_BASE --head=$NX_HEAD --verbose - run: name: ๐Ÿงฐ Run Unit Tests command: pnpm exec nx affected -t test --exclude='*,!tag:core' --parallel --base=$NX_BASE --head=$NX_HEAD --ci --verbose - run: name: โณ Build Libraries command: pnpm exec nx affected -t build --exclude='*,!tag:publishable' --parallel --base=$NX_BASE --head=$NX_HEAD --verbose - run: name: ๐Ÿงช Run E2E Tests command: pnpm exec nx affected -t e2e --exclude='*,!tag:core' --parallel --base=$NX_BASE --head=$NX_HEAD --ci --code-coverage --verbose - run: name: ๐Ÿ“š Build Storybook command: pnpm exec nx run beeq:storybook-build --output-style=stream --verbose # Stop Nx Cloud agents - run: name: โน๏ธ Stop Nx Cloud Agents command: pnpm dlx nx-cloud stop-all-agents # Persist artifacts for Chromatic - persist_to_workspace: root: . paths: - dist - .nx - dist/storybook/beeq chromatic: docker: - image: cimg/node:22.15.0-browsers environment: *env-vars steps: - checkout - attach_workspace: at: . - run: name: ๐Ÿš€ Publish to Chromatic command: pnpm dlx chromatic --project-token=${CHROMATIC_PROJECT_TOKEN} --ci --debug --storybook-build-dir dist/storybook/beeq # ---------------------------------------------------------------------------- # # Workflows # # ---------------------------------------------------------------------------- # workflows: version: 2 โณ Build and Test: jobs: - main - chromatic: requires: - main