.github/workflows/build.yml
name: Build
on: [push]
env:
CI: "true"
NODE_VERSION: 16.13.0
APP_NAME: trampos
jobs:
build:
runs-on: ubuntu-latest
services:
redis:
image: redis:6.0.12-alpine
ports: ["6379:6379"]
postgres:
image: postgres:13.2-alpine
ports: ["5432:5432"]
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
env:
POSTGRES_PASSWORD: postgres
env:
DB_USER: postgres
DB_PASS: postgres
DATABASE_HOST: localhost
steps:
- uses: actions/checkout@v2
- name: Set up Ruby version
uses: ruby/setup-ruby@v1
with:
bundler-cache: true
- uses: actions/setup-node@v1
with:
node-version: ${{ env.NODE_VERSION }}
- name: Get npm cache directory path
id: npm-cache-dir-path
run: echo "::set-output name=dir::$(npm get cache)-${{ env.APP_NAME }}"
- uses: actions/cache@v2
id: npm-cache
with:
path: ${{ steps.npm-cache-dir-path.outputs.dir }}
key: npm-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
npm-
- name: Build and test
run: |
bundle exec rails db:create
bundle exec rails db:migrate
bundle exec rails db:test:prepare
bundle exec rails spec
- name: Publish code coverage
uses: paambaati/codeclimate-action@v3.0.0
env:
CC_TEST_REPORTER_ID: 86bbdf4badf3f08a454c1022696446d17801aca331013de524773c7b117f2b71
with:
coverageLocations: ${{github.workspace}}/coverage/coverage.xml:cobertura