From c8aec6213d8779caeb3d71abc6e23d10e6feadfb Mon Sep 17 00:00:00 2001 From: anthony Date: Mon, 25 Oct 2021 10:03:39 +0200 Subject: [PATCH 1/5] :construction: Add build, test and test-e2e jobs --- .circleci/config.yml | 64 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 .circleci/config.yml diff --git a/.circleci/config.yml b/.circleci/config.yml new file mode 100644 index 0000000..298d6c7 --- /dev/null +++ b/.circleci/config.yml @@ -0,0 +1,64 @@ +globals: + images: + node: &node cimg/node:lts + postgres: &postgres circleci/postgres:9.6.5 + + + +version: 2 +jobs: + build: &shared-config + docker: + - image: *node + working_directory: ~/app + steps: + - checkout + - restore_cache: + keys: + - dependencies-{{ checksum "package.json" }} + # fallback to using the latest cache if no exact match is found + - dependencies- + - run: yarn install + - save_cache: + paths: + - node_modules + key: dependencies-{{ checksum "package.json" }} + test: + <<: *shared-config + steps: + - checkout + - restore_cache: + key: dependencies-{{ checksum "package.json" }} + - run: yarn test + + test-e2e: + docker: + - image: *node + - image: *postgres + environment: + POSTGRES_DB: postgres + POSTGRES_USER: postgres + POSTGRES_PASSWORD: postgres + steps: + - checkout + - restore_cache: + keys: + - dependencies-{{ checksum "package.json" }} + - run: + command: yarn test:e2e + environment: + DATABASE_URL: postgres://postgres:postgres@localhost:5432/postgres + + + +workflows: + version: 2 + build-test-and-lint: + jobs: + - build + - test: + requires: + - build + - test-e2e: + requires: + - build From 5848a8f87788c61d20c32cd1506c250ec4ff1c27 Mon Sep 17 00:00:00 2001 From: anthony Date: Mon, 25 Oct 2021 10:13:44 +0200 Subject: [PATCH 2/5] :green_heart: Add working dir for e2e tests --- .circleci/config.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.circleci/config.yml b/.circleci/config.yml index 298d6c7..2ee4ce4 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -2,6 +2,8 @@ globals: images: node: &node cimg/node:lts postgres: &postgres circleci/postgres:9.6.5 + caches: + @@ -32,6 +34,7 @@ jobs: - run: yarn test test-e2e: + <<: *shared-config docker: - image: *node - image: *postgres From dc24baa55fc0ab56a45362df1e0fea6aa0f1be28 Mon Sep 17 00:00:00 2001 From: anthony Date: Mon, 25 Oct 2021 10:30:56 +0200 Subject: [PATCH 3/5] :construction_worker: Add lint step --- .circleci/config.yml | 43 +++++++++++++++++++++++++++++++++---------- 1 file changed, 33 insertions(+), 10 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 2ee4ce4..47f8675 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -1,13 +1,26 @@ +version: 2 +# --- Constants --- # + globals: images: node: &node cimg/node:lts postgres: &postgres circleci/postgres:9.6.5 caches: + dependencies: &dependencies dependencies-{{ checksum "package.json" }} +# --- Commands --- # +commands: + init: + description: Setup the environment + steps: + - checkout + - restore_cache: + keys: + - *dependencies +# --- Jobs definitions --- # -version: 2 jobs: build: &shared-config docker: @@ -17,20 +30,18 @@ jobs: - checkout - restore_cache: keys: - - dependencies-{{ checksum "package.json" }} + - *dependencies # fallback to using the latest cache if no exact match is found - dependencies- - run: yarn install - save_cache: paths: - node_modules - key: dependencies-{{ checksum "package.json" }} + key: *dependencies test: <<: *shared-config steps: - - checkout - - restore_cache: - key: dependencies-{{ checksum "package.json" }} + - init - run: yarn test test-e2e: @@ -43,16 +54,25 @@ jobs: POSTGRES_USER: postgres POSTGRES_PASSWORD: postgres steps: - - checkout - - restore_cache: - keys: - - dependencies-{{ checksum "package.json" }} + - init - run: command: yarn test:e2e environment: DATABASE_URL: postgres://postgres:postgres@localhost:5432/postgres + lint: + <<: *shared-config + steps: + - init + - run: + name: Check files format + command: yarn format:check + - run: + name: Lint files + command: yarn lint + +# --- Workflow definition --- # workflows: version: 2 @@ -65,3 +85,6 @@ workflows: - test-e2e: requires: - build + - lint: + requires: + - build From 6d363eb89e214f229d8a0ce019a841c21a05cb9f Mon Sep 17 00:00:00 2001 From: anthony Date: Mon, 25 Oct 2021 10:53:58 +0200 Subject: [PATCH 4/5] :green_heart: Change init command name --- .circleci/config.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 47f8675..b7b6b7c 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -11,7 +11,7 @@ globals: # --- Commands --- # commands: - init: + setup_dependencies: description: Setup the environment steps: - checkout @@ -41,7 +41,7 @@ jobs: test: <<: *shared-config steps: - - init + - setup_dependencies - run: yarn test test-e2e: @@ -54,7 +54,7 @@ jobs: POSTGRES_USER: postgres POSTGRES_PASSWORD: postgres steps: - - init + - setup_dependencies - run: command: yarn test:e2e environment: @@ -63,7 +63,7 @@ jobs: lint: <<: *shared-config steps: - - init + - setup_dependencies - run: name: Check files format command: yarn format:check From 3f5e0afc326b4882006161bc32393826bf26b0fa Mon Sep 17 00:00:00 2001 From: anthony Date: Mon, 25 Oct 2021 10:56:17 +0200 Subject: [PATCH 5/5] :green_heart: Switch CI version to 2.1 --- .circleci/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index b7b6b7c..dded634 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -1,4 +1,4 @@ -version: 2 +version: 2.1 # --- Constants --- # globals: