Skip to content

Commit

Permalink
Add Github Actions (#46)
Browse files Browse the repository at this point in the history
  • Loading branch information
forsbergplustwo authored Aug 20, 2023
1 parent dc9d6e9 commit e9878e7
Show file tree
Hide file tree
Showing 11 changed files with 126 additions and 27 deletions.
18 changes: 10 additions & 8 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
export SENDGRID_USERNAME=
export SENDGRID_PASSWORD=
export EMAIL_FROM_ADDRESS=
SECRET_KEY_BASE="b9e3d8d8ddf8e997077ff5a4db3d948800c2eebee74c79e1dc5bcfb1e467e087c2f97d9fb2a8b02041abac00785af1a45249sdff5978e2d6a9a6bd28ea4729f1"

export AWS_ACCESS_KEY_ID=
export AWS_SECRET_ACCESS_KEY=
export S3_BUCKET=
SENDGRID_USERNAME=
SENDGRID_PASSWORD=
EMAIL_FROM_ADDRESS=

export INTERCOM_APP_ID=
export INTERCOM_APP_SECRET=
AWS_ACCESS_KEY_ID=
AWS_SECRET_ACCESS_KEY=
S3_BUCKET=

INTERCOM_APP_ID=
INTERCOM_APP_SECRET=
76 changes: 76 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
name: Tests

on:
push:
inputs:
app_name:
required: true
type: string
default: partner-metrics
use_node:
type: boolean
required: false
default: false
secrets:
secret_key_base:
required: true
bundle_token:
required: true

jobs:
build:
runs-on: ubuntu-latest
services:
postgres:
image: postgres:11
env:
POSTGRES_USER: postgres
POSTGRES_DB: ${{ inputs.app_name }}-test
POSTGRES_PASSWORD: ""
POSTGRES_HOST_AUTH_METHOD: trust
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
steps:
- uses: actions/checkout@v3
- name: Set up Node
if: ${{ inputs.use_node == true }}
uses: actions/setup-node@v3
with:
node-version-file: '.node-version'
- name: Set up Ruby
uses: ruby/setup-ruby@v1
env:
BUNDLE_GITHUB__COM: x-access-token:${{ secrets.bundle_token }}
with:
bundler-cache: true
- name: Copy .env sample
run: |
cp .env.example .env
- name: Setup test database
env:
RAILS_ENV: test
SECRET_KEY_BASE: ${{ secrets.master_key }}
run: |
bin/rake db:create
bin/rake db:schema:load
bin/rake db:migrate
- name: Run tests
env:
REDIS_URL: redis://localhost:6379/0
SECRET_KEY_BASE: ${{ secrets.master_key }}
run: |
bin/rake test:all
- name: Upload artifacts
if: failure()
uses: actions/upload-artifact@v3
with:
name: screenshots
path: /home/runner/work/${{ inputs.app_name }}/${{ inputs.app_name }}/tmp/screenshots/
9 changes: 9 additions & 0 deletions .github/workflows/reviewdog.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
name: Reviewdog

on: [pull_request]

jobs:
standard:
uses: forsbergplustwo/github-actions/.github/workflows/standard.yml@main
secrets:
bundle_token: ${{ secrets.BUNDLE_TOKEN }}
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ db/*.sqlite3
.redcar/
.sass-cache
/config/config.yml
/config/database.yml
/coverage.data
/coverage/
/db/*.javadb/
Expand Down
7 changes: 7 additions & 0 deletions .standard.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
ignore:
- 'bin/*'
- 'db/**/*'
- 'config/environments/*'
- '**/*':
- Rails/EnvironmentVariableAccess
- Lint/FloatComparison
4 changes: 2 additions & 2 deletions bin/bundle
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#!/usr/bin/env ruby
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
load Gem.bin_path('bundler', 'bundle')
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__)
load Gem.bin_path("bundler", "bundle")
10 changes: 3 additions & 7 deletions bin/rails
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
#!/usr/bin/env ruby
begin
load File.expand_path("../spring", __FILE__)
rescue LoadError
end
APP_PATH = File.expand_path('../../config/application', __FILE__)
require_relative '../config/boot'
require 'rails/commands'
APP_PATH = File.expand_path("../config/application", __dir__)
require_relative "../config/boot"
require "rails/commands"
8 changes: 2 additions & 6 deletions bin/rake
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
#!/usr/bin/env ruby
begin
load File.expand_path("../spring", __FILE__)
rescue LoadError
end
require_relative '../config/boot'
require 'rake'
require_relative "../config/boot"
require "rake"
Rake.application.run
14 changes: 14 additions & 0 deletions config/database.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
default: &default
adapter: postgresql
encoding: unicode
username: postgres
host: localhost
pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>

development:
<<: *default
database: partner-metrics-dev

test:
<<: *default
database: partner-metrics-test
2 changes: 1 addition & 1 deletion config/initializers/devise.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
# confirmation, reset password and unlock tokens in the database.
# Devise will use the `secret_key_base` as its `secret_key`
# by default. You can change it below and use your own secret key.
# config.secret_key = '00fba28c4fa7352043e289b20243c0307180320741e4eb1503ee77e1ddce0450ea7f51cfc3062c458897d837525822eed85ece6852b55b0f6e61f5334f7d0d1a'
config.secret_key = ENV["SECRET_KEY_BASE"]

# ==> Mailer Configuration
# Configure the e-mail address which will be shown in Devise::Mailer,
Expand Down
4 changes: 2 additions & 2 deletions config/secrets.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@

development:
domain_name: example.com
secret_key_base: b9e3d8d8ddf8e997077ff5a4db3d948800c2eebee74c79e1dc5bcfb1e467e087c2f97d9fb2a8b02041abac00785af1a45249711f5978e2d6a9a6bd28ea4729f1
secret_key_base: <%= ENV["SECRET_KEY_BASE"] %>

test:
secret_key_base: 471eec6ae4ecd33d90c75b2fe5c28245d8a513b15292f7abb4d11f845780f40afeb5ba198ffb85b78a85e755c58696a4220bb28bcde7252bfea68acfb1093913
secret_key_base: <%= ENV["SECRET_KEY_BASE"] %>

# Do not keep production secrets in the repository,
# instead read values from the environment.
Expand Down

0 comments on commit e9878e7

Please sign in to comment.