From 463983d33b9e36c89acbbec07af6115250c94d56 Mon Sep 17 00:00:00 2001 From: Vitor Oliveira Date: Thu, 26 May 2022 13:51:32 -0700 Subject: [PATCH 1/8] Add Dockerfile, docker-compose and scripts folder --- Dockerfile | 9 +++++++++ Makefile | 20 ++++++++++++++++++++ docker-compose.yml | 18 ++++++++++++++++++ scripts/brakeman | 3 +++ scripts/specs | 5 +++++ 5 files changed, 55 insertions(+) create mode 100644 Dockerfile create mode 100644 Makefile create mode 100644 docker-compose.yml create mode 100755 scripts/brakeman create mode 100755 scripts/specs diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..1f2887b --- /dev/null +++ b/Dockerfile @@ -0,0 +1,9 @@ +FROM ruby:2.7.2 + +WORKDIR /var/gem + +COPY . . + +RUN gem install bundler:1.17.2 + +RUN bundle check > /dev/null 2>&1 || bundle install -j4 \ No newline at end of file diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..3d9e8ae --- /dev/null +++ b/Makefile @@ -0,0 +1,20 @@ +build: + docker-compose build + +start: + docker-compose up + +specs: + docker-compose run --entrypoint ./scripts/specs web + +bash: + docker-compose exec web bash + +console: + docker-compose exec web bundle exec rails c + +brakeman: + docker-compose run --entrypoint ./scripts/brakeman web + +rubocop: + docker-compose run --entrypoint rubocop web diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..348d3d6 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,18 @@ +version: '2' + +services: + web: + build: + context: . + volumes: + - .:/var/gem + depends_on: + - db + db: + image: postgres:9.6.2-alpine + ports: + - '5432' + volumes: + - postgres96:/var/lib/postgresql/data +volumes: + postgres96: diff --git a/scripts/brakeman b/scripts/brakeman new file mode 100755 index 0000000..0ee1a5b --- /dev/null +++ b/scripts/brakeman @@ -0,0 +1,3 @@ +#!/bin/bash + +brakeman --no-exit-on-warn --no-exit-on-error --no-pager --path . \ No newline at end of file diff --git a/scripts/specs b/scripts/specs new file mode 100755 index 0000000..bd29e7f --- /dev/null +++ b/scripts/specs @@ -0,0 +1,5 @@ +#!/bin/bash + +bundle install +bundle exec rake db:create db:migrate RAILS_ENV=test +bundle exec rspec . \ No newline at end of file From 66f3f4aafd1e9f81de10a3de8a154ec1d1513b6c Mon Sep 17 00:00:00 2001 From: Vitor Oliveira Date: Thu, 26 May 2022 13:52:21 -0700 Subject: [PATCH 2/8] Fix end of file issues --- Dockerfile | 2 +- scripts/brakeman | 2 +- scripts/specs | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index 1f2887b..49a18d7 100644 --- a/Dockerfile +++ b/Dockerfile @@ -6,4 +6,4 @@ COPY . . RUN gem install bundler:1.17.2 -RUN bundle check > /dev/null 2>&1 || bundle install -j4 \ No newline at end of file +RUN bundle check > /dev/null 2>&1 || bundle install -j4 diff --git a/scripts/brakeman b/scripts/brakeman index 0ee1a5b..fdc5203 100755 --- a/scripts/brakeman +++ b/scripts/brakeman @@ -1,3 +1,3 @@ #!/bin/bash -brakeman --no-exit-on-warn --no-exit-on-error --no-pager --path . \ No newline at end of file +brakeman --no-exit-on-warn --no-exit-on-error --no-pager --path . diff --git a/scripts/specs b/scripts/specs index bd29e7f..31e7dd3 100755 --- a/scripts/specs +++ b/scripts/specs @@ -2,4 +2,4 @@ bundle install bundle exec rake db:create db:migrate RAILS_ENV=test -bundle exec rspec . \ No newline at end of file +bundle exec rspec . From 2dd73e79c9386ea14a349256d8e5a6a48d676756 Mon Sep 17 00:00:00 2001 From: Vitor Oliveira Date: Thu, 26 May 2022 14:44:51 -0700 Subject: [PATCH 3/8] Bundle to ruby 3.0.0 --- .ruby-version | 1 - Dockerfile | 4 ++-- Gemfile | 2 +- Gemfile.lock | 4 ++-- config/database.yml | 2 +- 5 files changed, 6 insertions(+), 7 deletions(-) delete mode 100644 .ruby-version diff --git a/.ruby-version b/.ruby-version deleted file mode 100644 index 2eb2fe9..0000000 --- a/.ruby-version +++ /dev/null @@ -1 +0,0 @@ -ruby-2.7.2 diff --git a/Dockerfile b/Dockerfile index 49a18d7..0258bdf 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,9 +1,9 @@ -FROM ruby:2.7.2 +FROM ruby:3.0.0 WORKDIR /var/gem COPY . . -RUN gem install bundler:1.17.2 +RUN gem install bundler:2.3.14 RUN bundle check > /dev/null 2>&1 || bundle install -j4 diff --git a/Gemfile b/Gemfile index 07b40fc..3f928d2 100644 --- a/Gemfile +++ b/Gemfile @@ -3,7 +3,7 @@ source "https://rubygems.org" git_source(:github) {|repo| "https://github.com/#{repo}.git" } -ruby "2.7.2" +ruby "3.0.0" gem "bootsnap", "1.5.1" gem "brakeman", "~> 5.0.0" diff --git a/Gemfile.lock b/Gemfile.lock index 2d1f86d..ed23a74 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -289,7 +289,7 @@ DEPENDENCIES spring-watcher-listen (~> 2.0.0) RUBY VERSION - ruby 2.7.2p137 + ruby 3.0.0p0 BUNDLED WITH - 2.1.4 + 2.3.14 diff --git a/config/database.yml b/config/database.yml index cc58f29..3813189 100644 --- a/config/database.yml +++ b/config/database.yml @@ -1,7 +1,7 @@ default: &default adapter: postgresql encoding: unicode - port: 5433 + port: 5432 username: postgres password: postgres pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %> From 6ec73ea692528edfeb87b237c14f00ed1bcb62b4 Mon Sep 17 00:00:00 2001 From: Vitor Oliveira Date: Thu, 26 May 2022 15:22:12 -0700 Subject: [PATCH 4/8] Update devise-jwt to fix broken tests --- Gemfile.lock | 12 ++++++------ .../app/models/authentication/jwt_blacklist.rb | 2 +- components/authentication/authentication.gemspec | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index ed23a74..e98f150 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -10,7 +10,7 @@ PATH authentication (0.1.0) active_model_serializers (~> 0.10.9) devise - devise-jwt (~> 0.5.8) + devise-jwt (~> 0.9.0) PATH remote: components/chat @@ -105,9 +105,9 @@ GEM railties (>= 4.1.0) responders warden (~> 1.2.3) - devise-jwt (0.5.9) + devise-jwt (0.9.0) devise (~> 4.0) - warden-jwt_auth (~> 0.3.6) + warden-jwt_auth (~> 0.6) diff-lcs (1.5.0) dotenv (2.7.6) dotenv-rails (2.7.6) @@ -253,9 +253,9 @@ GEM unicode-display_width (2.1.0) warden (1.2.9) rack (>= 2.0.9) - warden-jwt_auth (0.3.6) - dry-auto_inject (~> 0.6) - dry-configurable (~> 0.8) + warden-jwt_auth (0.6.0) + dry-auto_inject (~> 0.8) + dry-configurable (~> 0.13) jwt (~> 2.1) warden (~> 1.2) websocket-driver (0.7.5) diff --git a/components/authentication/app/models/authentication/jwt_blacklist.rb b/components/authentication/app/models/authentication/jwt_blacklist.rb index a752bb3..b5e7cdf 100644 --- a/components/authentication/app/models/authentication/jwt_blacklist.rb +++ b/components/authentication/app/models/authentication/jwt_blacklist.rb @@ -4,6 +4,6 @@ module Authentication class JWTBlacklist < ActiveRecord::Base self.table_name = "jwt_blacklists" - include Devise::JWT::RevocationStrategies::Blacklist + include Devise::JWT::RevocationStrategies::Denylist end end diff --git a/components/authentication/authentication.gemspec b/components/authentication/authentication.gemspec index 98f346e..a27d7d4 100644 --- a/components/authentication/authentication.gemspec +++ b/components/authentication/authentication.gemspec @@ -20,5 +20,5 @@ Gem::Specification.new do |spec| spec.add_dependency "active_model_serializers", "~> 0.10.9" spec.add_dependency "devise" - spec.add_dependency "devise-jwt", "~> 0.5.8" + spec.add_dependency "devise-jwt", "~> 0.9.0" end From 47791979c1356c246a2c29238cede752bf3c0274 Mon Sep 17 00:00:00 2001 From: Vitor Oliveira Date: Thu, 26 May 2022 15:28:28 -0700 Subject: [PATCH 5/8] Make brakeman scan components folder --- scripts/brakeman | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/scripts/brakeman b/scripts/brakeman index fdc5203..050c9c9 100755 --- a/scripts/brakeman +++ b/scripts/brakeman @@ -1,3 +1,5 @@ #!/bin/bash -brakeman --no-exit-on-warn --no-exit-on-error --no-pager --path . +brakeman --no-exit-on-warn --no-exit-on-error --no-pager --path components/api +brakeman --no-exit-on-warn --no-exit-on-error --no-pager --path components/chat +brakeman --no-exit-on-warn --no-exit-on-error --no-pager --path components/authentication From f15091c3bec45ea872f5db0e2451b7b941ade39d Mon Sep 17 00:00:00 2001 From: Vitor Oliveira Date: Thu, 26 May 2022 17:01:14 -0700 Subject: [PATCH 6/8] Add .circleci/config.yml --- .circleci/config.yml | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 .circleci/config.yml diff --git a/.circleci/config.yml b/.circleci/config.yml new file mode 100644 index 0000000..6554e1f --- /dev/null +++ b/.circleci/config.yml @@ -0,0 +1,26 @@ +# Use the latest 2.1 version of CircleCI pipeline process engine. +# See: https://circleci.com/docs/2.0/configuration-reference +version: 2.1 + +# Define a job to be invoked later in a workflow. +# See: https://circleci.com/docs/2.0/configuration-reference/#jobs +jobs: + say-hello: + # Specify the execution environment. You can specify an image from Dockerhub or use one of our Convenience Images from CircleCI's Developer Hub. + # See: https://circleci.com/docs/2.0/configuration-reference/#docker-machine-macos-windows-executor + docker: + - image: cimg/base:stable + # Add steps to the job + # See: https://circleci.com/docs/2.0/configuration-reference/#steps + steps: + - checkout + - run: + name: "Say hello" + command: "echo Hello, World!" + +# Invoke jobs via workflows +# See: https://circleci.com/docs/2.0/configuration-reference/#workflows +workflows: + say-hello-workflow: + jobs: + - say-hello From fa8f59798b79c7347c880780734809b2128a18f6 Mon Sep 17 00:00:00 2001 From: Vitor Oliveira Date: Thu, 26 May 2022 17:02:33 -0700 Subject: [PATCH 7/8] add new ci file versio --- .circleci/config.yml | 48 +++++++++++++++++++++++++------------------- 1 file changed, 27 insertions(+), 21 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 6554e1f..3aa27e9 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -1,26 +1,32 @@ -# Use the latest 2.1 version of CircleCI pipeline process engine. -# See: https://circleci.com/docs/2.0/configuration-reference -version: 2.1 -# Define a job to be invoked later in a workflow. -# See: https://circleci.com/docs/2.0/configuration-reference/#jobs +version: 2 jobs: - say-hello: - # Specify the execution environment. You can specify an image from Dockerhub or use one of our Convenience Images from CircleCI's Developer Hub. - # See: https://circleci.com/docs/2.0/configuration-reference/#docker-machine-macos-windows-executor - docker: - - image: cimg/base:stable - # Add steps to the job - # See: https://circleci.com/docs/2.0/configuration-reference/#steps + build: + machine: + docker: + - image: alpine:3.4 + environment: + DATABASE_URL: postgres://127.0.0.1:5432 + RAILS_ENV: test + - image: circleci/postgres:9.6.2-alpine + environment: + POSTGRES_USER: root + POSTGRES_DB: circle-test_test steps: - checkout + - run: mkdir -p /tmp/artifacts - run: - name: "Say hello" - command: "echo Hello, World!" - -# Invoke jobs via workflows -# See: https://circleci.com/docs/2.0/configuration-reference/#workflows -workflows: - say-hello-workflow: - jobs: - - say-hello + name: build_image + command: make build + - run: + name: run specs + command: | + make specs + - run: + name: rubocop + command: | + make rubocop + - run: + name: brakeman + command: | + make brakeman From 5374d02a07e0a640425ef02ffb113ed19a87f737 Mon Sep 17 00:00:00 2001 From: Vitor Oliveira Date: Thu, 26 May 2022 17:17:53 -0700 Subject: [PATCH 8/8] Add redis image to circle ci --- .circleci/config.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.circleci/config.yml b/.circleci/config.yml index 3aa27e9..df5a023 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -12,6 +12,7 @@ jobs: environment: POSTGRES_USER: root POSTGRES_DB: circle-test_test + - image: redis steps: - checkout - run: mkdir -p /tmp/artifacts