Skip to content

Instantly share code, notes, and snippets.

@chiefpansancolt
Created November 14, 2019 14:13
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 chiefpansancolt/4e655e467a8aaeebfae7766830bb6d31 to your computer and use it in GitHub Desktop.
Save chiefpansancolt/4e655e467a8aaeebfae7766830bb6d31 to your computer and use it in GitHub Desktop.
Ruby on Rails Github Actions
name: Builds
on: [pull_request]
jobs:
ruby-build:
runs-on: ubuntu-latest
services:
postgres:
image: postgres:11
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: ""
POSTGRES_DB: postgres
ports:
- 5432/tcp
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
steps:
- uses: actions/checkout@v1
- name: Set up Ruby 2.6.x
uses: actions/setup-ruby@v1
with:
ruby-version: 2.6.x
- name: Build and create DB
env:
PGHOST: localhost
PGUSER: postgres
PGPORT: ${{ job.services.postgres.ports[5432] }}
RAILS_ENV: test
run: |
sudo apt-get install libpq-dev
gem install bundler
bundle install --jobs 4 --retry 3
bundle exec rails db:prepare
node-build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: actions/setup-node@v1
with:
node-version: '13.x'
- run: yarn install
name: Lints
on: [pull_request]
jobs:
ruby-lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: Rubocop Linter
uses: andrewmcodes/rubocop-linter-action@v1.0.3
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
haml-lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: HAML Lint
uses: andrewmcodes/haml-lint-action@v0.0.1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
js-lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: eslint
uses: reviewdog/action-eslint@v1
with:
github_token: ${{ secrets.github_token }}
reporter: github-pr-check
eslint_flags: 'app/**/* postcss.config.js babel.config.js'
css-lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: stylelint
uses: reviewdog/action-stylelint@v1
with:
github_token: ${{ secrets.github_token }}
reporter: github-pr-check
stylelint_input: 'app/**/*.scss'
# usage with redis
name: Tests
on: [pull_request]
jobs:
ruby-test:
runs-on: ubuntu-latest
services:
postgres:
image: postgres:11
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: ""
POSTGRES_DB: postgres
ports:
- 5432/tcp
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
steps:
- uses: actions/checkout@v1
- uses: zhulik/redis-action@v1.0.0
with:
redis version: '4'
- name: Set up Ruby 2.6.x
uses: actions/setup-ruby@v1
with:
ruby-version: 2.6.x
- name: Build and create DB
env:
PGHOST: localhost
PGUSER: postgres
PGPORT: ${{ job.services.postgres.ports[5432] }}
RAILS_ENV: test
run: |
sudo apt-get install libpq-dev
gem install bundler
bundle install --jobs 4 --retry 3
bundle exec rails db:prepare
name: Tests
on: [pull_request]
jobs:
ruby-test:
runs-on: ubuntu-latest
services:
postgres:
image: postgres:11
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: ""
POSTGRES_DB: postgres
ports:
- 5432/tcp
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
steps:
- uses: actions/checkout@v1
- name: Set up Ruby 2.6.x
uses: actions/setup-ruby@v1
with:
ruby-version: 2.6.x
- name: Build and Run Tests
env:
PGHOST: localhost
PGUSER: postgres
PGPORT: ${{ job.services.postgres.ports[5432] }}
RAILS_ENV: test
run: |
sudo apt-get install libpq-dev
gem install bundler
bundle install --jobs 4 --retry 3
bundle exec rails db:prepare
bundle exec rake test
@chiefpansancolt
Copy link
Author

Redis cannot be used as an image as the url disallows connection from cable from what i have found not sure why just does not allow connection to the redis server

@andrewmcodes
Copy link

@chiefpansancolt I would disagree with that statement. I have used Redis in production as an image before, but it’s hard to say that with 100% confidence without knowing what you’re doing with it.

I have Redis working on my test repo as a service I believe ¯_(ツ)_/¯

@chiefpansancolt
Copy link
Author

Yea this action is using redis in a docker file. over setting redis in a services. That caused my issue, why i do not know. I am still using a docker image just adding in a different way. @andrewmcodes

@andrewmcodes
Copy link

@chiefpansancolt gotcha. Interesting.

@chiefpansancolt
Copy link
Author

Yea it puzzled me haha, but its working so im just rolling with it haha.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment