From c891b2fece801a38b816779c028e12c8d7c37fd4 Mon Sep 17 00:00:00 2001 From: Arthur Belleville Date: Wed, 29 Oct 2025 10:27:32 +0100 Subject: [PATCH] Improve ci file by using orbs --- .circleci/config.yml | 87 ++++++++++++++++++++++++-------------------- 1 file changed, 47 insertions(+), 40 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 0b2c5c0..6d9c12a 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -1,29 +1,8 @@ version: 2.1 -# Define executor -executors: - node-executor: - docker: - - image: cimg/node:25.0.0 - resource_class: small - working_directory: ~/project - -# Reusable commands -commands: - setup-pnpm: - steps: - - restore_cache: - name: Restore pnpm Package Cache - keys: - - pnpm-packages-{{ checksum "pnpm-lock.yaml" }} - - run: - name: Install Dependencies - command: pnpm install - - save_cache: - name: Save pnpm Package Cache - key: pnpm-packages-{{ checksum "pnpm-lock.yaml" }} - paths: - - .pnpm-store +# Import the Node orb +orbs: + node: circleci/node@5.2.0 # Jobs jobs: @@ -32,10 +11,14 @@ jobs: # ============================================ test-lint: - executor: node-executor + docker: + - image: cimg/node:lts + resource_class: small steps: - checkout - - setup-pnpm + - node/install-packages: + pkg-manager: pnpm + cache-path: ~/.pnpm-store - run: name: Run linting command: pnpm run lint @@ -44,19 +27,27 @@ jobs: command: pnpm run format --check || echo "Format check complete" test-typecheck: - executor: node-executor + docker: + - image: cimg/node:lts + resource_class: small steps: - checkout - - setup-pnpm + - node/install-packages: + pkg-manager: pnpm + cache-path: ~/.pnpm-store - run: name: Type check all packages command: pnpm run typecheck test-unit: - executor: node-executor + docker: + - image: cimg/node:lts + resource_class: small steps: - checkout - - setup-pnpm + - node/install-packages: + pkg-manager: pnpm + cache-path: ~/.pnpm-store - run: name: Run unit tests command: pnpm run test @@ -67,7 +58,9 @@ jobs: destination: coverage test-api: - executor: node-executor + docker: + - image: cimg/node:lts + resource_class: small steps: - checkout - restore_cache: @@ -100,24 +93,28 @@ jobs: # ============================================ build-apps: - executor: node-executor + docker: + - image: cimg/node:lts + resource_class: small parameters: environment: type: string default: "staging" steps: - checkout - - setup-pnpm + - node/install-packages: + pkg-manager: pnpm + cache-path: ~/.pnpm-store - run: name: Build main app for << parameters.environment >> command: | cd apps/main - npm run build:<< parameters.environment >> + pnpm run build:<< parameters.environment >> - run: name: Build external app command: | cd apps/external - npm run build + pnpm run build - persist_to_workspace: root: . paths: @@ -133,7 +130,9 @@ jobs: destination: external-app build-api: - executor: node-executor + docker: + - image: cimg/node:lts + resource_class: small steps: - checkout - restore_cache: @@ -190,12 +189,16 @@ jobs: # ============================================ deploy-staging: - executor: node-executor + docker: + - image: cimg/node:lts + resource_class: small steps: - checkout - attach_workspace: at: . - - setup-pnpm + - node/install-packages: + pkg-manager: pnpm + cache-path: ~/.pnpm-store - run: name: Deploy main app to staging command: | @@ -218,12 +221,16 @@ jobs: # gcloud run deploy xtablo-api-staging --image gcr.io/${GCP_PROJECT}/xtablo-api:${CIRCLE_SHA1} --region us-central1 deploy-production: - executor: node-executor + docker: + - image: cimg/node:lts + resource_class: small steps: - checkout - attach_workspace: at: . - - setup-pnpm + - node/install-packages: + pkg-manager: pnpm + cache-path: ~/.pnpm-store - run: name: Deploy main app to production command: |