dawarich/.circleci/config.yml

124 lines
2.9 KiB
YAML
Raw Normal View History

2024-08-20 16:14:29 -04:00
version: 2.1
2025-02-02 15:49:52 -05:00
executors:
docker-executor:
machine:
image: ubuntu-2204:current
2024-08-20 16:14:29 -04:00
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
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:
2025-02-02 15:49:52 -05:00
executor: docker-executor
environment:
DOCKER_CLI_EXPERIMENTAL: enabled
2025-02-02 15:41:41 -05:00
steps:
- checkout
2025-02-02 15:49:52 -05:00
- run:
name: Set branch variable
command: |
if [ -z "$CIRCLE_BRANCH" ]; then
echo 'export BUILD_BRANCH=master' >> $BASH_ENV
else
echo "export BUILD_BRANCH=$CIRCLE_BRANCH" >> $BASH_ENV
fi
- setup_remote_docker:
version: 20.10.24
docker_layer_caching: true
2025-02-02 15:41:41 -05:00
- run:
2025-02-02 15:49:52 -05:00
name: Install dependencies
command: npm install
2025-02-02 15:41:41 -05:00
- run:
2025-02-02 15:49:52 -05:00
name: Login to Docker Hub
command: echo "$DOCKERHUB_TOKEN" | docker login -u "$DOCKERHUB_USERNAME" --password-stdin
2025-02-02 15:41:41 -05:00
- run:
2025-02-02 15:49:52 -05:00
name: Set Docker tags
command: |
if [[ -n "$CIRCLE_TAG" ]]; then
VERSION="${CIRCLE_TAG}"
else
VERSION="latest"
fi
2025-02-02 15:41:41 -05:00
2025-02-02 15:49:52 -05:00
TAGS="freikin/dawarich:${VERSION}"
2025-02-02 15:41:41 -05:00
2025-02-02 15:49:52 -05:00
if [[ "$CIRCLE_TAG" =~ rc ]]; then
TAGS="${TAGS},freikin/dawarich:rc"
else
TAGS="${TAGS},freikin/dawarich:latest"
fi
2025-02-02 15:41:41 -05:00
2025-02-02 15:49:52 -05:00
echo "export DOCKER_TAGS=\"$TAGS\"" >> $BASH_ENV
2025-02-02 15:41:41 -05:00
2025-02-02 15:49:52 -05:00
- run:
name: Build and push (arm64)
command: |
docker buildx create --use
docker buildx build --platform linux/arm64 \
--file ./docker/Dockerfile.dev \
--tag freikin/dawarich:${VERSION} \
--push .
2025-02-02 15:41:41 -05:00
2025-02-02 15:49:52 -05:00
- run:
name: Build and push (other architectures)
command: |
docker buildx build --platform linux/amd64,linux/arm/v7,linux/arm/v6 \
--file ./docker/Dockerfile.dev \
--tag freikin/dawarich:${VERSION} \
--push .
2025-02-02 15:41:41 -05:00
2024-08-20 16:14:29 -04:00
workflows:
2025-02-02 15:49:52 -05:00
version: 2
rspec:
2024-08-20 16:14:29 -04:00
jobs:
- test
2025-02-02 15:49:52 -05:00
build-and-push:
2025-02-02 15:41:41 -05:00
jobs:
2025-02-02 15:49:52 -05:00
- test
2025-02-02 15:41:41 -05:00
- build-and-push:
filters:
branches:
2025-02-02 15:49:52 -05:00
only:
- master
tags:
only: /^v.*/ # Run only on version tags