Skip to content

Commit

Permalink
Play with docker build
Browse files Browse the repository at this point in the history
  • Loading branch information
gmmcal committed Oct 14, 2023
1 parent 49ac17d commit 9d92e3d
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 16 deletions.
36 changes: 36 additions & 0 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Docker

on:
workflow_call:

jobs:
docker:
name: 'Docker: Build'
runs-on: ubuntu-20.04

services:
postgres:
image: postgres:16
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: gmmcalcombr_test
ports:
- 5432:5432
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5

steps:
- uses: actions/checkout@v4

- name: Build test image
uses: docker/build-push-action@v2
with:
push: false
context: .
target: test
tags: "gmmcal:test"

- name: Upload image
uses: ishworkh/[email protected]
with:
image: "gmmcal:test"
25 changes: 9 additions & 16 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,30 +4,23 @@ on:
- pull_request

jobs:
build:
uses: gmmcal/gmmcal.com.br/.github/workflows/docker.yml@actions

rubocop:
name: 'Lint: Rubocop'
runs-on: ubuntu-20.04

container:
image: ruby:3.2.2
needs: build

steps:
- uses: actions/checkout@v4

- uses: actions/cache@v3
- name: Download an image
uses: ishworkh/[email protected]
with:
path: vendor/bundle
key: ${{ runner.os }}-gems-gmmcal-${{ hashFiles('/Gemfile.lock') }}
restore-keys: |
${{ runner.os }}-gems-gmmcal-
- name: Run bundle install
run: |
bundle config path vendor/bundle
bundle install --jobs 4 --retry 3
image: "gmmcal:test"

- name: Run rubocop
run: bundle exec rubocop --config .rubocop.yml .
run: |
docker run --rm gmmcal:test bundle exec rubocop --config .rubocop.yml .
reek:
name: 'Lint: Reek'
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ capybara-*.html
/public/assets
/public/uploads
/coverage/
!/coverage/.keep
/spec/tmp
/spec/backend/examples.txt
/spec/end-to-end/screenshots
Expand Down
5 changes: 5 additions & 0 deletions bin/docker-entrypoint
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,9 @@ if [ "${1}" == "./bin/rails" ] && [ "${2}" == "server" ]; then
./bin/rails db:seed:all
fi

# bundle exec rspec
if [ "${3}" == "rspec" ]; then
./bin/rails db:migrate
fi

exec "${@}"
Empty file added coverage/.keep
Empty file.

0 comments on commit 9d92e3d

Please sign in to comment.