dawarich/.circleci/config.yml

110 lines
2.6 KiB
YAML
Raw Normal View History

2024-08-20 16:14:29 -04:00
version: 2.1
orbs:
2024-09-05 15:23:24 -04:00
ruby: circleci/ruby@2.1.4
browser-tools: circleci/browser-tools@1.4.8
2025-02-02 15:41:41 -05:00
docker: circleci/docker@2.4.0
parameters:
branch:
type: string
default: "master"
2024-08-20 16:14:29 -04:00
jobs:
test:
2024-08-20 16:14:29 -04:00
docker:
2024-09-12 16:45:38 -04:00
- image: cimg/ruby:3.3.4
environment:
RAILS_ENV: test
2025-01-29 05:57:53 -05:00
- image: cimg/postgres:13.3-postgis
environment:
POSTGRES_USER: postgres
POSTGRES_DB: test_database
POSTGRES_PASSWORD: mysecretpassword
2024-08-20 16:56:42 -04:00
- image: redis:7.0
2024-08-20 16:14:29 -04:00
steps:
- checkout
- run:
name: Install Bundler
command: gem install bundler
- run:
name: Bundle Install
command: bundle install --jobs=4 --retry=3
- run:
name: Database Setup
command: |
2025-01-29 05:55:33 -05:00
bundle exec rails db:create
bundle exec rails db:schema:load
- run:
name: Run RSpec tests
command: bundle exec rspec
2024-08-20 16:44:09 -04:00
- store_artifacts:
path: coverage
2025-02-02 15:41:41 -05:00
build-and-push:
machine:
image: ubuntu-2204:current
steps:
- checkout
- docker/setup-buildx
- restore_cache:
keys:
- docker-layers-{{ .Branch }}-{{ .Revision }}
- docker-layers-{{ .Branch }}
- docker-layers-
- run:
name: Install dependencies
command: npm install
- run:
name: Login to DockerHub
command: echo "$DOCKERHUB_TOKEN" | docker login -u "$DOCKERHUB_USERNAME" --password-stdin
- run:
name: Set Docker tags
command: |
VERSION=${CIRCLE_TAG:-latest}
TAGS="freikin/dawarich:${VERSION}"
# Add :rc tag for pre-releases (assuming tag contains 'rc' for pre-releases)
if [[ $CIRCLE_TAG == *"rc"* ]]; then
TAGS="${TAGS},freikin/dawarich:rc"
fi
# Add :latest tag only if not a pre-release
if [[ $CIRCLE_TAG != *"rc"* ]]; then
TAGS="${TAGS},freikin/dawarich:latest"
fi
echo "export DOCKER_TAGS=${TAGS}" >> $BASH_ENV
- docker/build:
image: freikin/dawarich
tag: ${DOCKER_TAGS}
dockerfile: ./docker/Dockerfile.dev
platform: linux/amd64,linux/arm64,linux/arm/v7,linux/arm/v6
push: true
- save_cache:
key: docker-layers-{{ .Branch }}-{{ .Revision }}
paths:
- /tmp/docker-cache
2024-08-20 16:14:29 -04:00
workflows:
rspec:
2024-08-20 16:14:29 -04:00
jobs:
- test
2025-02-02 15:41:41 -05:00
version: 2
build-and-deploy:
jobs:
- build-and-push:
filters:
tags:
only: /^v.*/
branches:
only: master