From 345ae7780c1ea0ea1bc78baf9e11de065fe648da Mon Sep 17 00:00:00 2001 From: Loren Johnson Date: Fri, 25 Oct 2024 21:24:25 -0700 Subject: [PATCH] chore: CircleCI Monorepo setup (WIP) --- .circleci/config.yml | 32 +++++++++++++ .circleci/continue_config.yml | 85 +++++++++++++++++++++++++++++++++++ 2 files changed, 117 insertions(+) create mode 100644 .circleci/config.yml create mode 100644 .circleci/continue_config.yml diff --git a/.circleci/config.yml b/.circleci/config.yml new file mode 100644 index 000000000..dc6baaa9b --- /dev/null +++ b/.circleci/config.yml @@ -0,0 +1,32 @@ +version: 2.1 + +# this allows you to use CircleCI's dynamic configuration feature +setup: true + +# the path-filtering orb is required to continue a pipeline based on +# the path of an updated fileset +orbs: + path-filtering: circleci/path-filtering@0.1.1 + +workflows: + # the always-run workflow is always triggered, regardless of the pipeline parameters. + always-run: + jobs: + - path-filtering/filter: + name: check-updated-files + + # Test which path is updated and set the parameter for continue_config + mapping: | + apps/backend/.* backend-changed true + apps/web/.* web-changed true + apps/mobile/.* mobile-changed true + + # Compare changes of the branch with main branch + base-revision: main + + # this is the path of the configuration we should trigger once + # path filtering and pipeline parameter value updates are + # complete. In this case, we are using the parent dynamic + # configuration itself. + + config-path: .circleci/continue_config.yml diff --git a/.circleci/continue_config.yml b/.circleci/continue_config.yml new file mode 100644 index 000000000..7b4160e49 --- /dev/null +++ b/.circleci/continue_config.yml @@ -0,0 +1,85 @@ +version: 2.1 + +commands: + setup: + steps: + - run: + command: | + corepack enable --install-directory ~/bin + yarn install + +# the default pipeline parameters, which will be updated according to +# the results of the path-filtering orb +parameters: + backend-changed: + type: boolean + default: false + web-changed: + type: boolean + default: false + mobile-changed: + type: boolean + default: false + +workflows: + run-backend-tests: + when: << pipeline.parameters.backend-changed >> + jobs: + - backend-tests + run-web-tests: + when: << pipeline.parameters.web-changed >> + jobs: + - web-tests + run-mobile-tests: + when: << pipeline.parameters.mobile-changed >> + jobs: + - mobile-tests + +jobs: + backend-tests: + docker: + - image: cimg/node:20.17 + - image: cimg/postgres:13.4-postgis + environment: + POSTGRES_USER: postgres + POSTGRES_PASSWORD: hylo + POSTGRES_DB: hylo_test + - image: redis + environment: + NODE_ENV: test + DATABASE_URL: postgres://localhost:5432/hylo_test + DOMAIN: testdomain + # this prevents jobs that were queued during testing from being run in development + KUE_NAMESPACE: qtest + PROTOCOL: http + # don't log errors to Rollbar + ROLLBAR_SERVER_TOKEN: 0 + steps: + - checkout + - setup + - run: + command: | + cd apps/backend + yarn test + + web-tests: + docker: + - image: cimg/node:20.17 + steps: + - checkout + - setup + - run: + command: | + cd apps/web + yarn test + + mobile-tests: + docker: + - image: cimg/node:20.17 + steps: + - checkout + - setup + - run: + command: | + cd apps/mobile + yarn test