Improve ci file by using orbs
This commit is contained in:
parent
491efe17ac
commit
c891b2fece
1 changed files with 47 additions and 40 deletions
|
|
@ -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: |
|
||||
|
|
|
|||
Loading…
Reference in a new issue