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 15, 2023
1 parent 49ac17d commit 82478dd
Show file tree
Hide file tree
Showing 105 changed files with 17,102 additions and 17,047 deletions.
67 changes: 0 additions & 67 deletions .github/workflows/backend.yml

This file was deleted.

93 changes: 93 additions & 0 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
name: Build

on:
- pull_request

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

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Build test image
uses: docker/build-push-action@v5
with:
push: true
context: .
target: test
tags: "gmmcal/gmmcal:test"
cache-from: type=gha
cache-to: type=gha,mode=max

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

steps:
- name: Run rubocop
run: |
docker run --rm gmmcal/gmmcal:test bundle exec rubocop --config .rubocop.yml .
reek:
name: 'Lint: Reek'
runs-on: ubuntu-20.04
needs: docker

steps:
- name: Run reek
run: |
docker run --rm gmmcal/gmmcal:test bundle exec reek --config .reek.yml .
brakeman:
name: 'Lint: Brakeman'
runs-on: ubuntu-20.04
needs: docker

steps:
- name: Run brakeman
run: |
docker run --rm gmmcal/gmmcal:test bundle exec brakeman
scsslint:
name: 'Lint: SCSSLint'
runs-on: ubuntu-20.04
needs: docker

steps:
- name: Run SCSSLint
run: |
docker run --rm gmmcal/gmmcal:test bundle exec scss-lint --config .scss-lint.yml
backend:
name: 'Unit: Backend'
runs-on: ubuntu-20.04
needs: docker

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:
- name: Run rubocop
run: |
docker run --network=${{ job.services.postgres.network }} -e DATABASE_URL='postgres://postgres:postgres@postgres:5432/gmmcalcombr_test' -e DATABASE_CLEANER_ALLOW_REMOTE_DATABASE_URL=true --rm gmmcal/gmmcal:test
102 changes: 1 addition & 101 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,81 +4,6 @@ on:
- pull_request

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

container:
image: ruby:3.2.2

steps:
- uses: actions/checkout@v4

- uses: actions/cache@v3
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
- name: Run rubocop
run: bundle exec rubocop --config .rubocop.yml .

reek:
name: 'Lint: Reek'
runs-on: ubuntu-20.04

container:
image: ruby:3.2.2

steps:
- uses: actions/checkout@v4

- uses: actions/cache@v3
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
- name: Run reek
run: bundle exec reek --config .reek.yml .

brakeman:
name: 'Lint: Brakeman'
runs-on: ubuntu-20.04

container:
image: ruby:3.2.2

steps:
- uses: actions/checkout@v4

- uses: actions/cache@v3
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
- name: Run brakeman
run: bundle exec brakeman

bundler-audit:
name: 'Lint: Bundler Audit'
runs-on: ubuntu-20.04
Expand All @@ -87,7 +12,7 @@ jobs:
image: ruby:3.2.2

steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v3

- name: Install Bundler Audit
run: gem install bundler-audit
Expand All @@ -98,31 +23,6 @@ jobs:
- name: Run bundler-audit
run: bundler-audit

scsslint:
name: 'Lint: SCSSLint'
runs-on: ubuntu-20.04

container:
image: ruby:3.2.2

steps:
- uses: actions/checkout@v4

- uses: actions/cache@v3
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
- name: Run SCSSLint
run: bundle exec scss-lint --config .scss-lint.yml

eslint:
name: 'Lint: ESLint'
runs-on: ubuntu-20.04
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
1 change: 1 addition & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
require:
- rubocop-rails
- rubocop-rspec
- rubocop-factory_bot

AllCops:
TargetRubyVersion: 3.0
Expand Down
11 changes: 5 additions & 6 deletions .scss-lint.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
# Default application configuration that all configurations inherit from.

scss_files: "app/**/*.scss"
scss_files: "scss/**/*.scss"
plugin_directories: ['.scss-linters']

exclude:
- 'app/assets/stylesheets/admin/mdb/**'
- 'app/javascript/stylesheets/components/skill.scss'
- 'app/assets/stylesheets/cv/_functions.scss'
- 'app/assets/stylesheets/cv/application.sass.scss'
- 'app/assets/stylesheets/frontend/components/skill.scss'
- 'scss/admin/mdb/**'
- 'scss/cv/_functions.scss'
- 'scss/cv/application.sass.scss'
- 'scss/frontend/components/skill.scss'

# List of gem names to load custom linters from (make sure they are already
# installed)
Expand Down
21 changes: 21 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -96,3 +96,24 @@ ENTRYPOINT ["/rails/bin/docker-entrypoint"]
# Start the server by default, this can be overwritten at runtime
EXPOSE 3000
CMD ["bundle", "exec", "rspec"]

# Cypress Test image - WIP
FROM cypress/included as cypress

WORKDIR /rails

# Copy application code
COPY . .

# Run and own only the runtime files as a non-root user for security
RUN useradd rails --create-home --shell /bin/bash && \
chown -R rails:rails .
USER rails:rails

RUN ls -la

# Entrypoint prepares the database.
# ENTRYPOINT ["/rails/bin/docker-entrypoint"]

# Start the server by default, this can be overwritten at runtime
CMD ["cypress", "run", "-c", "'{\"e2e\": {\"baseUrl\":\"http://web:3000\"}}'"]
2 changes: 2 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ group :development do
gem 'listen'
gem 'reek'
gem 'rubocop'
gem 'rubocop-factory_bot'
gem 'rubocop-rails'
gem 'rubocop-rspec'
gem 'scss_lint', require: false
Expand All @@ -55,6 +56,7 @@ group :test do
end

group :test, :development do
gem 'bundler-audit'
gem 'cypress-on-rails'
end

Expand Down
5 changes: 5 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,9 @@ GEM
msgpack (~> 1.2)
brakeman (6.0.1)
builder (3.2.4)
bundler-audit (0.9.1)
bundler (>= 1.2.0, < 3)
thor (~> 1.0)
concurrent-ruby (1.2.2)
connection_pool (2.4.1)
crass (1.0.6)
Expand Down Expand Up @@ -343,6 +346,7 @@ PLATFORMS
DEPENDENCIES
bootsnap
brakeman
bundler-audit
cypress-on-rails
database_cleaner
devise
Expand All @@ -361,6 +365,7 @@ DEPENDENCIES
reek
rspec-rails
rubocop
rubocop-factory_bot
rubocop-rails
rubocop-rspec
scss_lint
Expand Down
Loading

0 comments on commit 82478dd

Please sign in to comment.