Skip to content

Instantly share code, notes, and snippets.

@andrewmcodes
Last active December 4, 2019 01:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save andrewmcodes/2c81e1776e1eed4ee831cd3e57689a54 to your computer and use it in GitHub Desktop.
Save andrewmcodes/2c81e1776e1eed4ee831cd3e57689a54 to your computer and use it in GitHub Desktop.
# Going to refactor this with some knowledge i gained about our test suite
#
version: 2
jobs:
build:
docker:
# specify the version you desire here
- image: circleci/ruby:2.6.5-node-browsers
environment:
PG_HOST: localhost
PG_USER: ubuntu
RAILS_ENV: test
RACK_ENV: test
AWS_S3_ACCESS_KEY_ID: AKIAIOSFODNN7EXAMPLE
AWS_S3_BUCKET: example_s3_bucket
AWS_S3_REGION: us-west-2
AWS_S3_SECRET_ACCESS_KEY: wJalrXUtnFEMI/K7MDENG/bPxRfiCYzEXAMPLEKEY
BASE_ECPM: 400
BUFFER_ENABLED: false
DEFAULT_HOST: codefund.io
ENABLED_FEATURES: jobs
HUBSPOT_ENABLED: false
PARALLEL_WORKERS: 1
PG_TIMEOUT_IN_SECONDS: 3
RAILS_MAX_THREADS: 10
REDIS_CACHE_URL: redis://127.0.0.1:6379
REDIS_QUEUE_URL: redis://127.0.0.1:6379
SCOUT_SAMPLE_RATE: 0.3
DATABASE_URL: "postgres://ubuntu@localhost:5432/code_fund_ads_test"
# Specify service dependencies here if necessary
# CircleCI maintains a library of pre-built images
# documented at https://circleci.com/docs/2.0/circleci-images/
- image: circleci/postgres:11.2
environment:
POSTGRES_USER: ubuntu
POSTGRES_DB: code_fund_ads_test
- image: circleci/redis:5.0.4
working_directory: ~/repo
steps:
- checkout
- restore_cache:
name: restore bundler cache
keys:
- cf-bundler-{{ checksum "Gemfile.lock" }}
- cf-bundler-
- restore_cache:
name: restore yarn cache
keys:
- cf-yarn-{{ checksum "yarn.lock" }}
- cf-yarn-
- restore_cache:
name: restore assets cache
keys:
- cf-assets-v1-{{ arch }}-{{ .Branch }}
- cf-assets-v1
- run: sudo apt-get update
- run: sudo apt-get install -y postgresql-client
- run: curl -o- -L https://yarnpkg.com/install.sh | bash
- run:
name: update bundler
command: |
gem install bundler:2.0.1
- run:
name: install gem dependencies
command: |
bundle install --jobs=4 --retry=3 --path vendor/bundle
- save_cache:
name: save bundler cache
paths:
- ./vendor/bundle
key: cf-bundler-{{ checksum "Gemfile.lock" }}
- run:
name: install yarn dependencies
command: |
yarn install --ignore-engines --frozen-lockfile
- save_cache:
name: save yarn cache
paths:
- ~/.cache/yarn
key: cf-yarn-{{ checksum "yarn.lock" }}
- run:
name: precompile assets
command: |
RAILS_ENV=test bundle exec rails webpacker:compile
- save_cache:
name: save assets cache
key: cf-assets-v1-{{ arch }}-{{ .Branch }}
paths:
- public/assets
- public/packs-test
- tmp/cache/bootsnap-load-path-cache
- tmp/cache/bootsnap-compile-cache
- tmp/cache/webpacker
- run:
name: Set up DB
command: bundle exec rails db:drop db:create db:structure:load --trace
- run:
name: run zeitwerk:check
command: bundle exec rails zeitwerk:check
- run:
name: run tests
command: bundle exec rails test
- run:
name: run system tests
command: bundle exec rails test:system
- run:
name: run standardrb check
command: bundle exec standardrb --format progress
- run:
name: run ERB lint check
command: bundle exec erblint app/views_redesigned/**/*.html.erb
- run:
name: run prettier-standard check
command: yarn run --ignore-engines prettier-standard --check 'app/**/*.js'
name: Test
on:
pull_request:
branches:
- '*'
push:
branches:
- master
jobs:
build:
runs-on: ubuntu-latest
services:
postgres:
image: postgres:11
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: postgres
ports: ['5432:5432']
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
redis:
image: redis
ports: ['6379:6379']
options: --entrypoint redis-server
container:
image: andrewmcodes/locomotive:latest
env:
DEFAULT_HOST: app.codefund.io
volumes:
- .:/app
- bundle_cache:/usr/local/bundle/
steps:
- name: Checkout
uses: meetup/express-checkout@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Extract branch name
shell: bash
run: echo "##[set-output name=branch;]$(echo ${GITHUB_REF#refs/heads/})"
id: extract_branch
- name: Get Yarn Cache
id: yarn-cache
run: echo "::set-output name=dir::$(yarn cache dir)"
- name: Cache Node Modules
id: node-modules-cache
uses: actions/cache@v1
with:
path: ${{ steps.yarn-cache.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- name: Cache Gems
id: gem-cache
uses: actions/cache@v1
with:
path: vendor/bundle
key: ${{ runner.os }}-gem-${{ hashFiles('**/Gemfile.lock') }}
restore-keys: |
${{ runner.os }}-gem-
- name: Cache Assets
id: assets-cache
uses: actions/cache@v1
with:
path: public/packs-test
key: ${{ runner.os }}-assets-${{ steps.extract_branch.outputs.branch }}
restore-keys: |
${{ runner.os }}-assets-
- name: Bundle Install
run: bundle check || bundle install --path vendor/bundle --jobs 4 --retry 3
- name: Yarn Install
run: yarn check || bin/rails yarn:install
- name: Compile Assets
run: bin/rails webpacker:compile
- name: Setup DB
run: bin/rails db:drop db:create db:structure:load --trace
- name: Run Rails Tests
run: |
bin/rails test
bin/rails test:system
- name: Zeitwerk Check
run: bundle exec rails zeitwerk:check
- name: StandardRB Check
run: bundle exec standardrb --format progress
- name: ERB Lint Check
run: bundle exec erblint app/views_redesigned/**/*.html.erb
- name: Prettier-Standard Check
run: yarn run --ignore-engines prettier-standard --check 'app/**/*.js'
FROM ruby:2.6.5
LABEL "name"="Locomotive"
LABEL "version"="0.0.1"
ENV APT_KEY_DONT_WARN_ON_DANGEROUS_USAGE=DontWarn
ENV BUNDLE_PATH='/bundle/vendor'
ENV LANG=en_US.UTF-8
ENV LANGUAGE=en_US.UTF-8
ENV LC_ALL=C.UTF-8
ENV PG_HOST='postgres'
ENV PG_PASSWORD='postgres'
ENV PG_USERNAME='postgres'
ENV RACK_ENV='test'
ENV RAILS_ENV='test'
ENV REDIS_CACHE_URL='redis://redis:6379/0'
ENV REDIS_QUEUE_URL='redis://redis:6379/0'
RUN curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - && \
echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list && \
curl -sL https://deb.nodesource.com/setup_13.x | bash - && \
wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - && \
echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" | tee /etc/apt/sources.list.d/google-chrome.list && \
apt-get update && \
apt-get install -y google-chrome-stable && \
echo "CHROME_BIN=/usr/bin/google-chrome" | tee -a /etc/environment && \
wget -q -O - https://dl.google.com/linux/linux_signing_key.pub | apt-key add - && \
echo 'deb http://dl.google.com/linux/chrome/deb/ stable main' | tee /etc/apt/sources.list.d/google-chrome.list && \
apt-get -yqq install libpq-dev && \
apt-get install -qq -y google-chrome-stable yarn nodejs postgresql postgresql-contrib
RUN gem install bundler:2.0.2
name: StandardRB
on:
pull_request:
branches:
- '*'
push:
branches:
- master
jobs:
standard:
name: StandardRB Check Action
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- name: Set up Ruby 2.6
uses: actions/setup-ruby@v1
with:
ruby-version: 2.6.x
- name: Bundle
run: |
gem install bundler
bundle install --jobs 4 --retry 3
- name: Run StandardRB
run: bundle exec standardrb --format progress
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment