Skip to content

Commit

Permalink
Configure linters and add CI workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
fblupi committed Jan 9, 2024
1 parent 93951d2 commit 7653ceb
Show file tree
Hide file tree
Showing 62 changed files with 492 additions and 208 deletions.
30 changes: 30 additions & 0 deletions .erb-lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
---

linters:
ExtraNewline:
enabled: true

FinalNewline:
enabled: true

SpaceAroundErbTag:
enabled: true

AllowedScriptType:
enabled: true
allowed_types:
- text/javascript
- text/template

Rubocop:
enabled: true

rubocop_config:
AllCops:
DisabledByDefault: true

Style/StringLiterals:
EnforcedStyle: double_quotes

Layout/SpaceInsideHashLiteralBraces:
Enabled: true
15 changes: 15 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
**/*{.,-}min.js
decidim-*/vendor/**/*.js
spec/decidim_dummy_app/**/*.js
development_app
**/node_modules/**
bundle.js
karma.conf.js
webpack.config.js
webpack.config.babel.js
entry.test.js
entry.js
*_manifest.js
coverage
decidim-dev/**/*/test/**/*.js
vendor/bundle
3 changes: 3 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"extends": "@decidim"
}
44 changes: 44 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: Lint

on:
push:
branches:
- main
pull_request:

env:
RUBY_VERSION: 2.7.3
NODE_VERSION: 16.9.1

jobs:
lint:
name: Lint code
runs-on: ubuntu-20.04
steps:
- uses: actions/[email protected]
with:
fetch-depth: 1

- uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ env.RUBY_VERSION }}
bundler-cache: true

- uses: actions/setup-node@master
with:
node-version: ${{ env.NODE_VERSION }}

- run: bundle exec rubocop -P
name: Lint Ruby files

- run: bundle exec mdl *.md
name: Lint Markdown files

- run: bundle exec erblint app/{overrides,views}/**/*.{erb,deface}
name: Lint ERB files

- run: npm run stylelint
name: Lint SCSS files

- run: npm run lint
name: Lint JS files
62 changes: 62 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
name: Test

on:
push:
branches:
- main
pull_request:

env:
RUBY_VERSION: 2.7.3
NODE_VERSION: 16.9.1

jobs:
test:
name: Test
runs-on: ubuntu-20.04
services:
postgres:
image: postgres:11
ports:
- 5432:5432
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_HOST_AUTH_METHOD: trust
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5

steps:
- uses: actions/checkout@v2
with:
fetch-depth: 1

- uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ env.RUBY_VERSION }}
bundler-cache: true

- name: Bundle Install
run: bundle install

- name: Setup & create Database
run: bundle exec rake db:test:prepare
env:
RAILS_ENV: test
DATABASE_USERNAME: postgres
DATABASE_PASSWORD: postgres

- name: Precompile assets
run: |
npm install
bundle exec rake assets:precompile
env:
RAILS_ENV: test
DATABASE_USERNAME: postgres
DATABASE_PASSWORD: postgres

- name: Run RSpec
run: SIMPLECOV=1 CODECOV=1 bundle exec rspec
env:
RAILS_ENV: test
DATABASE_USERNAME: postgres
DATABASE_PASSWORD: postgres
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,4 @@ config/*-development.yml
/public/packs-test
yarn-debug.log*
.yarn-integrity
.rubocop-https*
15 changes: 15 additions & 0 deletions .mdl_style.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# frozen_string_literal: true

all

exclude_rule "first-line-h1"

exclude_rule "line-length"

exclude_rule "no-bare-urls"

exclude_rule "no-inline-html"

exclude_rule "ol-prefix"

rule "no-trailing-punctuation", punctuation: ".,;:!"
1 change: 1 addition & 0 deletions .mdlrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
style ".mdl_style.rb"
21 changes: 21 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
inherit_from: https://raw.githubusercontent.com/decidim/decidim/release/0.25-stable/.rubocop.yml

AllCops:
Include:
- "**/*.rb"
- "**/*.rake"
- "**/*.ru"
- "**/Gemfile"
- "**/Rakefile"
Exclude:
- "development_app/**/*"
- "**/development_app/**/*"
- "spec/decidim_dummy_app/**/*"
- "**/spec/decidim_dummy_app/**/*"
- "bin/**/*"
- "node_modules/**/*"
- "**/node_modules/**/*"
- "db/schema.rb"
- "db/migrate/*"
- "vendor/**/*"
- "**/vendor/**/*"
67 changes: 34 additions & 33 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,54 +1,55 @@
# frozen_string_literal: true

source 'https://rubygems.org'
source "https://rubygems.org"

ruby RUBY_VERSION

DECIDIM_VERSION = { git: 'https://github.com/decidim/decidim.git', branch: 'release/0.25-stable' }
DECIDIM_VERSION = { git: "https://github.com/decidim/decidim.git", branch: "release/0.25-stable" }.freeze

gem 'activerecord-session_store'
gem 'chamber', '~> 2.12.1'
gem "activerecord-session_store"
gem "chamber", "~> 2.12.1"
# Change term_customizer dependency to ruby-gems' when term-customizer is compatible with DECIDIM_bVERSION
gem 'decidim-term_customizer', git: 'https://github.com/mainio/decidim-module-term_customizer', branch: 'release/0.25-stable'
gem "decidim-term_customizer", git: "https://github.com/mainio/decidim-module-term_customizer", branch: "release/0.25-stable"

gem 'decidim', DECIDIM_VERSION
gem 'decidim-consultations', DECIDIM_VERSION
gem 'decidim-direct_verifications', '~> 1.2.0'
gem 'omniauth-saml', '~> 2.0'
gem "decidim", DECIDIM_VERSION
gem "decidim-consultations", DECIDIM_VERSION
gem "decidim-direct_verifications", "~> 1.2.0"
gem "omniauth-saml", "~> 2.0"

# Metrics require a queue system and a daily cron
gem 'delayed_job_active_record'
gem "delayed_job_active_record"
# daemons: required to manage the delayed_job background process
gem 'daemons'
gem 'whenever', require: false
gem "daemons"
gem "whenever", require: false

gem 'bootsnap', '~> 1.3'
gem "bootsnap", "~> 1.3"

gem 'puma', '~> 5.0'
gem 'uglifier', '~> 4.1'
gem "puma", "~> 5.0"
gem "uglifier", "~> 4.1"

gem 'httplog'
gem "deface"
gem "httplog"

group :development, :test do
gem 'byebug', platform: :mri
gem 'rspec-rails'
gem 'decidim-dev', DECIDIM_VERSION
gem 'faker', "~> 2.14"
gem "byebug", platform: :mri
gem "decidim-dev", DECIDIM_VERSION
gem "faker", "~> 2.14"
gem "rspec-rails"
end

group :development do
gem 'airbrussh', require: false
gem 'capistrano', '3.3.5'
gem 'capistrano-bundler', '~> 1.2'
gem 'capistrano-db-tasks', require: false
gem 'capistrano-faster-assets', '~> 1.0'
gem 'capistrano-passenger'
gem 'capistrano-rails'
gem 'capistrano3-delayed-job', '~> 1.0'
gem 'letter_opener_web', '~> 1.3'
gem 'listen', '~> 3.1'
gem 'spring', '~> 2.0'
gem 'spring-watcher-listen', '~> 2.0'
gem 'web-console', '~> 3.5'
gem "airbrussh", require: false
gem "capistrano", "3.3.5"
gem "capistrano3-delayed-job", "~> 1.0"
gem "capistrano-bundler", "~> 1.2"
gem "capistrano-db-tasks", require: false
gem "capistrano-faster-assets", "~> 1.0"
gem "capistrano-passenger"
gem "capistrano-rails"
gem "letter_opener_web", "~> 1.3"
gem "listen", "~> 3.1"
gem "rubocop-faker"
gem "spring", "~> 2.0"
gem "spring-watcher-listen", "~> 2.0"
gem "web-console", "~> 3.5"
end
4 changes: 4 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -752,6 +752,9 @@ GEM
unicode-display_width (>= 1.4.0, < 2.0)
rubocop-ast (1.30.0)
parser (>= 3.2.1.0)
rubocop-faker (1.1.0)
faker (>= 2.12.0)
rubocop (>= 0.82.0)
rubocop-rails (2.9.1)
activesupport (>= 4.2.0)
rack (>= 1.1)
Expand Down Expand Up @@ -899,6 +902,7 @@ DEPENDENCIES
omniauth-saml (~> 2.0)
puma (~> 5.0)
rspec-rails
rubocop-faker
spring (~> 2.0)
spring-watcher-listen (~> 2.0)
uglifier (~> 4.1)
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ Al autenticar con OAUTH comprueba que los campos del csv tengan el estado activo
Ejemplo de csv:
```
```csv
Matricula;Cognoms;Nom;mail;Estat;Tipus d'Empleat
DXXXXXX;Sanchez Inclan ;Manuel;[email protected];ACTIVE;T1
```
Expand Down Expand Up @@ -170,4 +170,4 @@ finalmente se borran las respuestas:
```ruby
a.destroy_all
```
```
4 changes: 3 additions & 1 deletion Rakefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# frozen_string_literal: true

# Add your own tasks in files placed in lib/tasks ending in .rake,
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.

require_relative 'config/application'
require_relative "config/application"

Rails.application.load_tasks
2 changes: 2 additions & 0 deletions app/channels/application_cable/channel.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module ApplicationCable
class Channel < ActionCable::Channel::Base
end
Expand Down
2 changes: 2 additions & 0 deletions app/channels/application_cable/connection.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module ApplicationCable
class Connection < ActionCable::Connection::Base
end
Expand Down
2 changes: 2 additions & 0 deletions app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
# frozen_string_literal: true

class ApplicationController < ActionController::Base
end
2 changes: 2 additions & 0 deletions app/controllers/decidim_controller.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

# Entry point for Decidim. It will use the `DecidimController` as
# entry point, but you can change what controller it inherits from
# so you can customize some methods.
Expand Down
2 changes: 2 additions & 0 deletions app/helpers/application_helper.rb
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
# frozen_string_literal: true

module ApplicationHelper
end
2 changes: 2 additions & 0 deletions app/jobs/application_job.rb
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
# frozen_string_literal: true

class ApplicationJob < ActiveJob::Base
end
6 changes: 4 additions & 2 deletions app/mailers/application_mailer.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
# frozen_string_literal: true

class ApplicationMailer < ActionMailer::Base
default from: '[email protected]'
layout 'mailer'
default from: "[email protected]"
layout "mailer"
end
2 changes: 2 additions & 0 deletions app/models/application_record.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

class ApplicationRecord < ActiveRecord::Base
self.abstract_class = true
end
2 changes: 2 additions & 0 deletions app/models/employee.rb
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
# frozen_string_literal: true

class Employee < ApplicationRecord
end
Empty file removed app/packs/stylesheets/.keep
Empty file.
2 changes: 1 addition & 1 deletion app/views/layouts/mailer.html.erb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<style>
/* Email styles need to be inline */
</style>
Expand Down
Loading

0 comments on commit 7653ceb

Please sign in to comment.