Created
October 11, 2019 13:01
-
-
Save ArturT/722bccf19bfdce3e5d2dbbc2cb89834a to your computer and use it in GitHub Desktop.
Codefresh.io matrix configuration for running parallel tests with Knapsack Pro for Ruby on Rails project (PostgreSQL + Docker setup). Follow installation guide for knapsack_pro ruby gem here https://docs.knapsackpro.com/knapsack_pro-ruby/guide/ or learn more about it at https://knapsackpro.com
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# .codefresh/codefresh.yml | |
version: "1.0" | |
stages: | |
- "clone" | |
- "build" | |
- "tests" | |
steps: | |
main_clone: | |
type: "git-clone" | |
description: "Cloning main repository..." | |
repo: "${{CF_REPO_OWNER}}/${{CF_REPO_NAME}}" | |
revision: "${{CF_BRANCH}}" | |
stage: "clone" | |
BuildTestDockerImage: | |
title: Building Test Docker image | |
type: build | |
arguments: | |
image_name: '${{CF_ACCOUNT}}/${{CF_REPO_NAME}}-test' | |
tag: '${{CF_BRANCH_TAG_NORMALIZED}}-${{CF_SHORT_REVISION}}' | |
dockerfile: Test.Dockerfile | |
stage: "build" | |
run_tests: | |
stage: "tests" | |
image: '${{BuildTestDockerImage}}' | |
working_directory: /src | |
fail_fast: false | |
environment: | |
- RAILS_ENV=test | |
# set how many parallel jobs you want to run | |
- KNAPSACK_PRO_CI_NODE_TOTAL=2 | |
- PGHOST=postgres | |
- PGUSER=rails-app-with-knapsack_pro | |
- PGPASSWORD=password | |
services: | |
composition: | |
postgres: | |
image: postgres:latest | |
environment: | |
- POSTGRES_DB=rails-app-with-knapsack_pro_test | |
- POSTGRES_PASSWORD=password | |
- POSTGRES_USER=rails-app-with-knapsack_pro | |
ports: | |
- 5432 | |
matrix: | |
environment: | |
# please ensure you have here listed N-1 indexes | |
# where N is KNAPSACK_PRO_CI_NODE_TOTAL | |
- KNAPSACK_PRO_CI_NODE_INDEX=0 | |
- KNAPSACK_PRO_CI_NODE_INDEX=1 | |
commands: | |
- bin/rails db:prepare | |
# run tests in Knapsack Pro Regular Mode | |
- bundle exec rake knapsack_pro:rspec | |
- bundle exec rake knapsack_pro:cucumber | |
- bundle exec rake knapsack_pro:minitest | |
- bundle exec rake knapsack_pro:test_unit | |
- bundle exec rake knapsack_pro:spinach | |
# you can use Knapsack Pro in Queue Mode once recorded first CI build with Regular Mode | |
- bundle exec rake knapsack_pro:queue:rspec | |
- bundle exec rake knapsack_pro:queue:cucumber | |
- bundle exec rake knapsack_pro:queue:minitest |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Test.Dockerfile | |
FROM ruby:2.6.5-alpine3.10 | |
# Prepare Docker image for Nokogiri | |
RUN apk add --update \ | |
build-base \ | |
libxml2-dev \ | |
libxslt-dev \ | |
jq \ | |
nodejs \ | |
npm \ | |
postgresql-dev \ | |
python3-dev \ | |
sqlite-dev \ | |
git \ | |
&& rm -rf /var/cache/apk/* | |
# Install AWS CLI | |
RUN pip3 install awscli | |
# Use libxml2, libxslt a packages from alpine for building nokogiri | |
RUN bundle config build.nokogiri --use-system-libraries | |
# Install Codefresh CLI | |
RUN wget https://github.com/codefresh-io/cli/releases/download/v0.31.1/codefresh-v0.31.1-alpine-x64.tar.gz | |
RUN tar -xf codefresh-v0.31.1-alpine-x64.tar.gz -C /usr/local/bin/ | |
COPY . /src | |
WORKDIR /src | |
RUN bundle install |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment