diff --git a/.circleci/config.yml b/.circleci/config.yml index e69de29bb2..3d5e1db9b2 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -0,0 +1,168 @@ +version: 2.1 + +orbs: + codecov: codecov/codecov@3.2.5 + jq: circleci/jq@2.2.0 + github-status: assurance-maladie-digital/github-status@1.3.0 + netlify: assurance-maladie-digital/netlify@1.1.0 + +defaults: + &defaults + working_directory: ~/project + docker: + - image: cimg/node:16.20-browsers + +aliases: + - &restore_cache + name: Restore Yarn Package Cache + key: yarn-packages-{{ checksum "yarn.lock" }} + - &save_cache + name: Save Yarn Package Cache + key: yarn-packages-{{ checksum "yarn.lock" }} + paths: + - node_modules/ + - .cache/ + - .config/yarn/global/ + - .yarn/ + - &install + name: Install Dependencies + command: yarn install --frozen-lockfile --non-interactive --ignore-scripts + - &build + name: Build Packages + command: yarn build && yarn generate + environment: + NODE_OPTIONS: --max_old_space_size=4096 + CI: "true" + CIRCLE_NODE_TOTAL: 0 + +jobs: + install: + <<: *defaults + steps: + - run: echo "export TARGET_URL=$CIRCLE_BUILD_URL" >> $BASH_ENV + - github-status/pending: + context: circleci/integration + - checkout + - restore_cache: *restore_cache + - run: *install + - save_cache: *save_cache + - persist_to_workspace: + root: ~/ + paths: + - project/ + - .cache/ + - .yarn/ + resource_class: large + lint: + <<: *defaults + steps: + - attach_workspace: + at: ~/ + - run: yarn lint + - github-status/report_failed_only: + context: circleci/integration + test: + <<: *defaults + steps: + - attach_workspace: + at: ~/ + - run: yarn test + - codecov/upload + - github-status/report_failed_only: + context: circleci/integration + resource_class: large + build: + <<: *defaults + steps: + - attach_workspace: + at: ~/ + - run: *build + - persist_to_workspace: + root: ~/ + paths: + - ./project/packages/docs + - github-status/report_failed_only: + context: circleci/integration + resource_class: large + deploy-preview: + <<: *defaults + steps: + - github-status/post_status: + state: success + context: circleci/integration + - github-status/pending: + context: circleci/deploy-preview + description: Deploy Preview in progress + - attach_workspace: + at: ~/ + - netlify/deploy: + folder: packages/docs/dist + - run: echo "export TARGET_URL=$NETLIFY_DEPLOY_URL" >> $BASH_ENV + - github-status/report: + context: circleci/deploy-preview + description: Deploy Preview ready! + deploy: + <<: *defaults + steps: + - github-status/pending: + context: circleci/deploy + description: Deploy in progress + - attach_workspace: + at: ~/ + - netlify/deploy_to_prod: + folder: packages/docs/dist + - run: echo "export TARGET_URL=$NETLIFY_DEPLOY_URL" >> $BASH_ENV + - github-status/report: + context: circleci/deploy + description: Deploy ready! + +workflows: + integration: + jobs: + - install + - lint: + requires: + - install + - test: + requires: + - install + - build: + requires: + - install + - deploy-preview: + requires: + - lint + - test + - build + - hold_for_deploy: + type: approval + requires: + - deploy-preview + filters: + branches: + only: main + - deploy: + requires: + - hold_for_deploy + filters: + branches: + only: main + nightly: + triggers: + - schedule: + cron: "0 0 * * *" + filters: + branches: + only: + - main + jobs: + - install + - build: + requires: + - install + - deploy: + requires: + - build + filters: + branches: + only: main