Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#1 Setup Rails template #30

Merged
merged 6 commits into from Jun 8, 2021
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions .browserslistrc
@@ -0,0 +1 @@
defaults
12 changes: 12 additions & 0 deletions .dockerignore
@@ -0,0 +1,12 @@
.gitignore
.semaphore
.semaphore-cache
log/
tmp/
!tmp/docker
coverage/
node_modules/
docker-compose.dev.yml
docker-compose.test.yml
docker-compose.yml
README.md
20 changes: 20 additions & 0 deletions .editorconfig
@@ -0,0 +1,20 @@
# Editor Configurations
# See: http://editorconfig.org

# Top-most EditorConfig file
root = true

[*]
indent_style = space
indent_size = 2
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

[*.md]
indent_size = 4
trim_trailing_whitespace = false

[Makefile]
indent_style = tab
6 changes: 6 additions & 0 deletions .env
@@ -0,0 +1,6 @@
DOCKER_REGISTRY_HOST=docker.io
DOCKER_IMAGE=nimblehq/google_search_ruby
BRANCH_TAG=latest
PORT=80
CI=false
TEST_RETRY=true
16 changes: 16 additions & 0 deletions .eslintignore
@@ -0,0 +1,16 @@
/node_modules/**
/config/**
/coverage/**
/public/**
/tmp/**
/vendor/**

postcss.config.js
babel.config.js

app/javascript/channels/*
app/javascript/translations/translations.js

engines/*/node_modules/**
engines/*/vendor/**
engines/*/app/javascript/*/translations/translations.js
8 changes: 8 additions & 0 deletions .eslintrc
@@ -0,0 +1,8 @@
{
"extends": [
"@nimblehq/eslint-config-nimble"
],
"globals": {
"I18n": true
}
}
2 changes: 2 additions & 0 deletions .flayignore
@@ -0,0 +1,2 @@
**/db/**/*.rb
**/spec/**/*_spec.rb
10 changes: 10 additions & 0 deletions .gitattributes
@@ -0,0 +1,10 @@
# See https://git-scm.com/docs/gitattributes for more about git attribute files.

# Mark the database schema as having been generated.
db/schema.rb linguist-generated

# Mark the yarn lockfile as having been generated.
yarn.lock linguist-generated

# Mark any vendored files as having been vendored.
vendor/* linguist-vendored
13 changes: 13 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
@@ -0,0 +1,13 @@
Add the story URL here. Prefer the short link format, e.g. https://app.clubhouse.io/acme/story/1234/

## What happened

Describe the big picture of your changes here to communicate to the team why we should accept this pull request.

## Insight

Describe in detail how to test the changes. Referenced documentation is welcome as well.

## Proof Of Work

Show us the implementation: screenshots, gif, etc.
19 changes: 19 additions & 0 deletions .github/workflows/README.md
@@ -0,0 +1,19 @@
# Github Actions

## Requirements:

- Generate new token on docker registry, support `docker.io`, `ghcr.io`, `azurecr.io`, `gcr.io`, `registry.gitlab.com`
- Generate new Heroku API key

## Setup the CI

### Secrets

Depending on the workflow used in the project, set up the following secrets:

- DOCKER_REGISTRY_HOST
- DOCKER_REGISTRY_TOKEN
- DOCKER_REGISTRY_USERNAME (Default: ${{ github.repository_owner }})
- DOCKER_IMAGE (Default: ${{ github. repository }})
- HEROKU_API_KEY (for deployment)
- DANGER_GITHUB_API_TOKEN (Default: ${{ github.token }})
70 changes: 70 additions & 0 deletions .github/workflows/deploy_heroku.yml
@@ -0,0 +1,70 @@
name: Deploy Heroku

on:
workflow_run:
workflows:
- Test
branches:
- master
- main
- development
types:
- completed
workflow_dispatch:

env:
DOCKER_REGISTRY_HOST: ${{ secrets.DOCKER_REGISTRY_HOST }}
DOCKER_REGISTRY_USERNAME: ${{ github.repository_owner }}
DOCKER_REGISTRY_TOKEN: ${{ secrets.DOCKER_REGISTRY_TOKEN }}
DOCKER_IMAGE: ${{ github.repository }}
HEROKU_API_KEY: ${{ secrets.HEROKU_API_KEY }}

jobs:
deploy:
runs-on: ubuntu-latest
if: ${{ github.event_name != 'workflow_run' || github.event.workflow_run.conclusion == 'success' }}
steps:
- name: Cancel previous runs
uses: styfle/cancel-workflow-action@0.6.0
with:
access_token: ${{ github.token }}

- uses: actions/checkout@v2.3.4
with:
ref: ${{ github.event.workflow_run.head_branch || github.ref }}

- name: Set env BRANCH_TAG
uses: nimblehq/branch-tag-action@v1.2
with:
ref: ${{ github.event.workflow_run.head_branch || github.ref }}

- name: Set env HEROKU_APP
run: |
if [[ $BRANCH_TAG = "latest" ]]
then
echo "HEROKU_APP=google_search_ruby" >> $GITHUB_ENV
else
echo "HEROKU_APP=google_search_ruby-staging" >> $GITHUB_ENV
fi

- name: Login to Docker registry
uses: docker/login-action@v1.6.0
with:
registry: ${{ env.DOCKER_REGISTRY_HOST }}
username: ${{ env.DOCKER_REGISTRY_USERNAME }}
password: ${{ env.DOCKER_REGISTRY_TOKEN }}

- name: Build Docker image
run: bin/docker-prepare && docker-compose build

- name: Push Docker image
run: docker-compose push web

- name: Login to Heroku
run: heroku container:login

- name: Push images to Heroku
run: heroku container:push --arg DOCKER_REGISTRY_HOST=$DOCKER_REGISTRY_HOST,DOCKER_IMAGE=$DOCKER_IMAGE,BRANCH_TAG=$BRANCH_TAG --recursive

- name: Release
run: heroku container:release web worker
56 changes: 56 additions & 0 deletions .github/workflows/review_code.yml
@@ -0,0 +1,56 @@
name: Review code

on:
pull_request:
types: [opened, reopened, synchronize]

env:
DANGER_GITHUB_API_TOKEN: ${{ github.token }}

jobs:
automated_code_review:
name: Run Danger
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2.3.4
with:
fetch-depth: 0

- name: Setup Ruby
uses: ruby/setup-ruby@v1
with:
bundler-cache: true

- name: Setup Node
uses: actions/setup-node@v2
with:
node-version: '14.15.4'

- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn cache dir)"

- name: Cache Yarn
uses: actions/cache@v2
id: yarn-cache
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-

- name: Cache Node modules
id: node-modules-cache
uses: actions/cache@v2
with:
path: node_modules
key: ${{ runner.os }}-nodemodules-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-nodemodules-

- name: Yarn install
if: steps.yarn-cache.outputs.cache-hit != 'true' || steps.node-modules-cache.outputs.cache-hit != 'true'
run: yarn

- name: Run Danger
run: bundle exec danger
90 changes: 90 additions & 0 deletions .github/workflows/test.yml
@@ -0,0 +1,90 @@
name: Test

on: push

env:
DOCKER_REGISTRY_HOST: ${{ secrets.DOCKER_REGISTRY_HOST }}
DOCKER_REGISTRY_USERNAME: ${{ github.repository_owner }}
DOCKER_REGISTRY_TOKEN: ${{ secrets.DOCKER_REGISTRY_TOKEN }}
DOCKER_IMAGE: ${{ github.repository }}

# Set the default docker-compose file
COMPOSE_FILE: docker-compose.test.yml

jobs:
build:
name: Build Docker image
runs-on: ubuntu-latest
steps:
- name: Cancel previous runs
uses: styfle/cancel-workflow-action@0.6.0
with:
access_token: ${{ github.token }}

- uses: actions/checkout@v2.3.4

- name: Set env BRANCH_TAG
uses: nimblehq/branch-tag-action@v1.2

- name: Login to Docker registry
uses: docker/login-action@v1.6.0
with:
registry: ${{ env.DOCKER_REGISTRY_HOST }}
username: ${{ env.DOCKER_REGISTRY_USERNAME }}
password: ${{ env.DOCKER_REGISTRY_TOKEN }}

- name: Pull Docker image
if: ${{ env.BRANCH_TAG != 'latest' && env.BRANCH_TAG != 'development' }}
run: docker-compose pull test || true

- name: Build Docker image
run: bin/docker-prepare && docker-compose build

- name: Push Docker image
run: docker-compose push test

unit_tests:
name: Unit tests
runs-on: ubuntu-latest
needs: build
steps:
- uses: actions/checkout@v2.3.4

- name: Set env BRANCH_TAG
uses: nimblehq/branch-tag-action@v1.2

- name: Login to Docker registry
uses: docker/login-action@v1.6.0
with:
registry: ${{ env.DOCKER_REGISTRY_HOST }}
username: ${{ env.DOCKER_REGISTRY_USERNAME }}
password: ${{ env.DOCKER_REGISTRY_TOKEN }}

- name: Pull Docker image
run: docker-compose pull test || true

- name: Run unit tests
run: docker-compose run test bundle exec rspec --exclude-pattern "spec/systems/**/*_spec.rb" --profile

system_tests:
name: System tests
runs-on: ubuntu-latest
needs: build
steps:
- uses: actions/checkout@v2.3.4

- name: Set env BRANCH_TAG
uses: nimblehq/branch-tag-action@v1.2

- name: Login to Docker registry
uses: docker/login-action@v1.6.0
with:
registry: ${{ env.DOCKER_REGISTRY_HOST }}
username: ${{ env.DOCKER_REGISTRY_USERNAME }}
password: ${{ env.DOCKER_REGISTRY_TOKEN }}

- name: Pull Docker image
run: docker-compose pull test || true

- name: Run system tests
run: docker-compose run test bundle exec rspec spec/systems --profile
30 changes: 30 additions & 0 deletions .github/workflows/test_production_build.yml
@@ -0,0 +1,30 @@
name: Test production build

on:
push:
branches-ignore:
- master
- main
- development

env:
DOCKER_REGISTRY_HOST: ${{ secrets.DOCKER_REGISTRY_HOST }}
DOCKER_IMAGE: ${{ github.repository }}

jobs:
docker_production_build_test:
name: Build Docker production image
runs-on: ubuntu-latest
steps:
- name: Cancel previous runs
uses: styfle/cancel-workflow-action@0.6.0
with:
access_token: ${{ github.token }}

- uses: actions/checkout@v2.3.4

- name: Set env BRANCH_TAG
uses: nimblehq/branch-tag-action@v1.2

- name: Build Docker image
run: bin/docker-prepare && docker-compose build