diff --git a/.circleci/config.yml b/.circleci/config.yml index ed9a052f..6eb75069 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -13,13 +13,25 @@ jobs: image: ubuntu-1604:201903-01 steps: - checkout + - restore_cache: + keys: + - deps1-{{ .Branch }}-{{ checksum "{{cookiecutter.project_slug}}/backend/requirements.txt" }} + - deps1-{{ .Branch }}-{{ checksum "{{cookiecutter.project_slug}}/frontend/package.json" }} + - deps1-{{ .Branch }}-{{ checksum "{{cookiecutter.project_slug}}/docker-compose.yml" }} - run: command: sudo pip install cookiecutter + - run: + command: ./scripts/build.sh + name: build + - save_cache: + key: deps1-{{ .Branch }}-{{ checksum "{{cookiecutter.project_slug}}/backend/requirements.txt" }} + paths: + - /home/circleci/.local/bin/ - run: command: ./scripts/test.sh name: Test environment: - CIRCLE_CI_ENV: true + CIRCLE_CI_ENV: true workflows: main: diff --git a/scripts/build.sh b/scripts/build.sh new file mode 100755 index 00000000..a1c60bfa --- /dev/null +++ b/scripts/build.sh @@ -0,0 +1,13 @@ +# Exit in case of error +set -e + +# Run this from the root of the project +cookiecutter --no-input -f ./ project_slug="testing-project" + +cd testing-project + +docker-compose build +docker-compose down -v --remove-orphans +docker-compose up -d +# Run migrations first +docker-compose run --rm backend alembic upgrade head \ No newline at end of file diff --git a/scripts/test.sh b/scripts/test.sh index 7656db41..608afd64 100755 --- a/scripts/test.sh +++ b/scripts/test.sh @@ -1,18 +1,11 @@ #! /usr/bin/env bash -# Exit in case of error -set -e - -# Run this from the root of the project -cookiecutter --no-input -f ./ project_slug="testing-project" +#!/bin/bash -cd testing-project +set -e -docker-compose build -docker-compose down -v --remove-orphans -docker-compose up -d -# Run migrations first -docker-compose run --rm backend alembic upgrade head +# Created by build.sh +cd project/testing_project # Backend/frontend tests ./scripts/test.sh