Files
writer/.circleci/config.yml
2022-07-31 15:18:14 +02:00

181 lines
5.4 KiB
YAML

version: 2
jobs:
test-backend:
docker:
- image: circleci/node:14
- image: circleci/mariadb:latest
environment:
MYSQL_ALLOW_EMPTY_PASSWORD: "true"
MYSQL_DATABASE: writer_test
MYSQL_USER: writer
MYSQL_PASSWORD: writer
MYSQL_HOST: "localhost"
working_directory: ~/writer
steps:
- checkout
- restore_cache:
keys:
- backend-dependencies-{{ checksum "package.json" }}
- run:
name: install backend deps
command: npm i
- save_cache:
paths:
- node_modules
key: backend-dependencies-{{ checksum "package.json" }}
- run:
name: test backend
command: npm test
test-frontend:
docker:
- image: circleci/node:12
working_directory: ~/writer/frontend
steps:
- checkout:
- restore_cache:
keys:
- backend-dependencies-{{ checksum "package.json" }}
- run:
name: install backend deps
command: npm i
- save_cache:
paths:
- node_modules
key: backend-dependencies-{{ checksum "package.json" }}
- restore_cache:
keys:
- frontend-dependencies-{{ checksum "package.json" }}
- run:
name: install frontend deps
command: cd frontend && npm i
- save_cache:
paths:
- frontend/node_modules
key: frontend-dependencies-{{ checksum "package.json" }}
- run:
name: test frontend
command: cd frontend && npm test
test-frontend-build:
docker:
- image: circleci/node:12
working_directory: ~/writer/frontend
steps:
- checkout:
- restore_cache:
keys:
- backend-dependencies-{{ checksum "package.json" }}
- run:
name: install backend deps
command: npm i
- save_cache:
paths:
- node_modules
key: backend-dependencies-{{ checksum "package.json" }}
- restore_cache:
keys:
- frontend-dependencies-{{ checksum "package.json" }}
- run:
name: install frontend deps
command: cd frontend && npm i
- save_cache:
paths:
- frontend/node_modules
key: frontend-dependencies-{{ checksum "package.json" }}
- run:
name: build frontend
command: cd frontend && npm run build
build:
machine:
image: ubuntu-2004:202107-01
working_directory: ~/writer
steps:
- checkout
- run:
name: log in to docker hub
command: echo "$DOCKER_PASSWORD" | docker login --username $DOCKER_USERNAME --password-stdin
- run:
name: install emulators
command: docker run --privileged --rm tonistiigi/binfmt --install all
- run:
name: create docker builder
command: docker buildx create --use
- run:
name: build and push to docker hub
#command: docker buildx build --push --platform linux/arm/v7,linux/arm64/v8,linux/amd64 --tag stepanusatiuk/writer:latest .
command: docker buildx build --push --platform linux/amd64 --tag stepanusatiuk/writer:$CIRCLE_BRANCH .
build-arm:
machine:
image: ubuntu-2004:202107-01
resource_class: arm.medium
working_directory: ~/writer
steps:
- checkout
- run:
name: log in to docker hub
command: echo "$DOCKER_PASSWORD" | docker login --username $DOCKER_USERNAME --password-stdin
- run:
name: install emulators
command: docker run --privileged --rm tonistiigi/binfmt --install all
- run:
name: create docker builder
command: docker buildx create --use
- run:
name: build and push to docker hub
#command: docker buildx build --push --platform linux/arm/v7,linux/arm64/v8,linux/amd64 --tag stepanusatiuk/writer:latest .
command: docker buildx build --push --platform linux/arm64/v8 --tag stepanusatiuk/writer:$CIRCLE_BRANCH .
workflows:
version: 2
test-build:
jobs:
- test-backend
- test-frontend
- test-frontend-build:
requires:
- test-frontend
- build:
requires:
- test-backend
- test-frontend
- test-frontend-build
- build-arm:
requires:
- test-backend
- test-frontend
- test-frontend-build