From a2669e0aa44a3bcd568535d937a143abe47b26ed Mon Sep 17 00:00:00 2001 From: f Date: Tue, 15 Jun 2021 17:07:52 -0300 Subject: [PATCH 1/8] =?UTF-8?q?actualizaci=C3=B3n=20de=20cuidados?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Gemfile.lock | 69 +++++++++++++++++++++++++--------------------------- 1 file changed, 33 insertions(+), 36 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 942d7d6f..e0c19860 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -89,11 +89,11 @@ GEM jekyll-relative-urls (~> 0.0) jekyll-seo-tag (~> 2.1) ast (2.4.2) - autoprefixer-rails (10.2.5.0) - execjs (< 2.8.0) + autoprefixer-rails (10.2.5.1) + execjs (> 0) bcrypt (3.1.16-x86_64-linux-musl) bcrypt_pbkdf (1.1.0-x86_64-linux-musl) - benchmark-ips (2.8.4) + benchmark-ips (2.9.1) bindex (0.8.1-x86_64-linux-musl) blazer (2.4.2) activerecord (>= 5) @@ -104,7 +104,7 @@ GEM autoprefixer-rails (>= 9.1.0) popper_js (>= 1.14.3, < 2) sassc-rails (>= 2.0.0) - brakeman (5.0.1) + brakeman (5.0.4) builder (3.2.4) capybara (2.18.0) addressable @@ -119,9 +119,9 @@ GEM colorator (1.1.0) commonmarker (0.21.2-x86_64-linux-musl) ruby-enum (~> 0.5) - concurrent-ruby (1.1.8) - concurrent-ruby-ext (1.1.8-x86_64-linux-musl) - concurrent-ruby (= 1.1.8) + concurrent-ruby (1.1.9) + concurrent-ruby-ext (1.1.9-x86_64-linux-musl) + concurrent-ruby (= 1.1.9) crass (1.0.6) database_cleaner (2.0.1) database_cleaner-active_record (~> 2.0.0) @@ -157,7 +157,7 @@ GEM dotenv-rails (2.7.6) dotenv (= 2.7.6) railties (>= 3.2) - down (5.2.1) + down (5.2.2) addressable (~> 2.5) ed25519 (1.2.4-x86_64-linux-musl) editorial-autogestiva-jekyll-theme (0.3.4) @@ -188,7 +188,7 @@ GEM exception_notification (4.4.3) actionmailer (>= 4.0, < 7) activesupport (>= 4.0, < 7) - execjs (2.7.0) + execjs (2.8.1) factory_bot (6.2.0) activesupport (>= 5.0.0) factory_bot_rails (6.2.0) @@ -196,7 +196,7 @@ GEM railties (>= 5.0.0) fast_blank (1.0.0-x86_64-linux-musl) fast_jsonparser (0.5.0-x86_64-linux-musl) - ffi (1.15.0-x86_64-linux-musl) + ffi (1.15.1-x86_64-linux-musl) flamegraph (0.9.5) forwardable-extended (2.6.0) friendly_id (5.4.2) @@ -285,8 +285,6 @@ GEM jekyll-locales (0.1.12) jekyll-lunr (0.2.0) loofah (~> 2.4) - jekyll-node-modules (0.1.0) - jekyll (~> 4) jekyll-order (0.1.4) jekyll-relative-urls (0.0.6) jekyll (~> 4) @@ -328,7 +326,7 @@ GEM activesupport (>= 4) railties (>= 4) request_store (~> 1.0) - loofah (2.9.1) + loofah (2.10.0) crass (~> 1.0.2) nokogiri (>= 1.5.9) mail (2.7.1) @@ -343,7 +341,6 @@ GEM mini_histogram (0.3.1) mini_magick (4.11.0) mini_mime (1.0.3) - mini_portile2 (2.5.1) minima (2.5.1) jekyll (>= 3.5, < 5.0) jekyll-feed (~> 0.9) @@ -356,8 +353,7 @@ GEM net-ssh (6.1.0) netaddr (2.0.4) nio4r (2.5.7-x86_64-linux-musl) - nokogiri (1.11.5-x86_64-linux-musl) - mini_portile2 (~> 2.5.0) + nokogiri (1.11.7-x86_64-linux) racc (~> 1.4) orm_adapter (0.5.0) parallel (1.20.1) @@ -373,7 +369,7 @@ GEM coderay (~> 1.1) method_source (~> 1.0) public_suffix (4.0.6) - puma (5.3.1-x86_64-linux-musl) + puma (5.3.2-x86_64-linux-musl) nio4r (~> 2.0) pundit (2.1.0) activesupport (>= 3.0.0) @@ -383,11 +379,11 @@ GEM rack (>= 2.0.0) rack-mini-profiler (2.3.2) rack (>= 1.2.0) - rack-proxy (0.6.5) + rack-proxy (0.7.0) rack rack-test (1.1.0) rack (>= 1.0, < 3) - radios-comunitarias-jekyll-theme (0.1.4) + radios-comunitarias-jekyll-theme (0.1.5) jekyll (~> 4.0) jekyll-data (~> 1.1) jekyll-feed (~> 0.9) @@ -434,29 +430,30 @@ GEM rb-fsevent (0.11.0) rb-inotify (0.10.1) ffi (~> 1.0) - recursero-jekyll-theme (0.1.3) - jekyll (~> 4.0) + recursero-jekyll-theme (0.2.0) + jekyll (~> 4) + jekyll-commonmark (~> 1.3) jekyll-data (~> 1.1) - jekyll-feed (~> 0.9) + jekyll-dotenv (>= 0.2) + jekyll-feed (~> 0.15) + jekyll-ignore-layouts (~> 0) jekyll-images (~> 0.2) jekyll-include-cache (~> 0) - jekyll-linked-posts (~> 0.2) + jekyll-linked-posts (~> 0) jekyll-locales (~> 0.1) jekyll-lunr (~> 0.1) - jekyll-node-modules (~> 0.1) - jekyll-order (~> 0.1) - jekyll-relative-urls (~> 0.0) - jekyll-seo-tag (~> 2.1) - jekyll-turbolinks (~> 0) + jekyll-order (~> 0) + jekyll-relative-urls (~> 0) + jekyll-seo-tag (~> 2) jekyll-unique-urls (~> 0.1) sutty-archives (~> 2.2) - sutty-liquid (~> 0.1) - redis (4.2.5) + sutty-liquid (~> 0) + redis (4.3.1) redis-actionpack (5.2.0) actionpack (>= 5, < 7) redis-rack (>= 2.1.0, < 3) redis-store (>= 1.1.0, < 2) - redis-activesupport (5.2.0) + redis-activesupport (5.2.1) activesupport (>= 3, < 7) redis-store (>= 1.3, < 2) redis-rack (2.1.3) @@ -476,16 +473,16 @@ GEM railties (>= 5.0) rexml (3.2.5) rouge (3.26.0) - rubocop (1.15.0) + rubocop (1.17.0) parallel (~> 1.10) parser (>= 3.0.0.0) rainbow (>= 2.2.2, < 4.0) regexp_parser (>= 1.8, < 3.0) rexml - rubocop-ast (>= 1.5.0, < 2.0) + rubocop-ast (>= 1.7.0, < 2.0) ruby-progressbar (~> 1.7) unicode-display_width (>= 1.4.0, < 3.0) - rubocop-ast (1.5.0) + rubocop-ast (1.7.0) parser (>= 3.0.1.1) rubocop-rails (2.10.1) activesupport (>= 4.2.0) @@ -571,7 +568,7 @@ GEM jekyll (>= 3.5, < 5.0) jekyll-feed (~> 0.9) jekyll-seo-tag (~> 2.1) - symbol-fstring (1.0.0-x86_64-linux-musl) + symbol-fstring (1.0.2-x86_64-linux-musl) sysexits (1.2.0) temple (0.8.2) terminal-table (2.0.0) @@ -606,7 +603,7 @@ GEM railties (>= 5.2) semantic_range (>= 2.3.0) webrick (1.7.0) - websocket-driver (0.7.3-x86_64-linux-musl) + websocket-driver (0.7.5-x86_64-linux-musl) websocket-extensions (>= 0.1.0) websocket-extensions (0.1.5) xpath (3.2.0) From 2ceeeff86c23dcdd32d2c05d3164c11c6e3712fe Mon Sep 17 00:00:00 2001 From: f Date: Sat, 10 Jul 2021 20:03:19 -0300 Subject: [PATCH 2/8] Mejorar el entorno de desarrollo fixes #1190 fixes #732 --- .env.example | 2 + Makefile | 180 +++++++++++++++++++++++++-------------------------- README.md | 21 ++++++ 3 files changed, 112 insertions(+), 91 deletions(-) diff --git a/.env.example b/.env.example index a1348593..a62e2b0a 100644 --- a/.env.example +++ b/.env.example @@ -1,3 +1,5 @@ +DELEGATE=athshe.sutty.nl +HAINISH=../haini.sh/haini.sh DATABASE= RAILS_ENV= IMAP_SERVER= diff --git a/Makefile b/Makefile index c083ddf8..a4480476 100644 --- a/Makefile +++ b/Makefile @@ -1,134 +1,111 @@ -.SHELL := /bin/bash -# Incluir las variables de entorno -mkfile_path := $(abspath $(lastword $(MAKEFILE_LIST))) -root_dir := $(patsubst %/,%,$(dir $(mkfile_path))) -include $(root_dir)/.env +SHELL := /bin/bash +.DEFAULT_GOAL := help -delegate := athshe +# Copiar el archivo de configuración y avisar cuando hay que +# actualizarlo. +.env: .env.example + @test -f $@ || cp -v $< $@ + @test -f $@ && echo "Revisa $@ para actualizarlo con respecto a $<" + @test -f $@ && diff -auN --color $@ $< -assets := package.json yarn.lock $(shell find app/assets/ app/javascript/ -type f) +include .env -alpine_version := 3.13 -hain ?= ../haini.sh/haini.sh +export -env ?= staging +args ?= ## Argumentos para Hain +commit ?= origin/rails ## Commit desde el que actualizar +env ?= staging ## Entorno del nodo delegado +sutty ?= $(SUTTY) ## Dirección local +delegate ?= $(DELEGATE) ## Cambia el nodo delegado +hain ?= $(HAINISH) ## Ubicación de Hainish +# El nodo delegado tiene dos entornos, production y staging. +# Dependiendo del entorno que elijamos, se van a generar los assets y el +# contenedor y subirse a un servidor u otro. No utilizamos CI/CD (aún). +# +# Production es el entorno de panel.sutty.nl ifeq ($(env),production) container ?= sutty +## TODO: Cambiar a otra cosa branch ?= rails public ?= public endif +# Staging es el entorno de panel.staging.sutty.nl ifeq ($(env),staging) container := staging branch := staging public := staging endif -export +help: always ## Ayuda + @echo -e "Sutty\n" | sed -re "s/^.*/\x1B[38;5;197m&\x1B[0m/" + @echo -e "Servidor: https://panel.$(SUTTY_WITH_PORT)/\n" + @echo -e "Uso: make TAREA args=\"ARGUMENTOS\"\n" + @echo -e "Tareas:\n" + @grep -E "^[a-z\-]+:.*##" Makefile | sed -re "s/(.*):.*##(.*)/\1;\2/" | column -s ";" -t | sed -re "s/^([^ ]+) /\x1B[38;5;197m\1\x1B[0m/" + @echo -e "\nArgumentos:\n" + @grep -E "^[a-z\-]+ \?=.*##" Makefile | sed -re "s/(.*) \?=.*##(.*)/\1;\2/" | column -s ";" -t | sed -re "s/^([^ ]+) /\x1B[38;5;197m\1\x1B[0m/" -public/packs/manifest.json.br: $(assets) - $(hain) 'cd /Sutty/sutty; PANEL_URL=https://panel.sutty.nl RAILS_ENV=production NODE_ENV=production bundle exec rake assets:precompile assets:clean' +assets: node_modules public/packs/manifest.json.br ## Compilar los assets -assets: public/packs/manifest.json.br +test: always ## Ejecutar los tests + $(MAKE) rake args="test RAILS_ENV=test $(args)" -tests := $(shell find test/ -name "*_test.rb") -$(tests): always - $(hain) 'cd /Sutty/sutty; bundle exec rake test TEST="$@" RAILS_ENV=test' - -test: always - $(hain) 'cd /Sutty/sutty; RAILS_ENV=test bundle exec rake test' - -postgresql: /etc/hosts +postgresql: /etc/hosts ## Iniciar la base de datos pgrep postgres >/dev/null || $(hain) postgresql -serve: /etc/hosts postgresql +serve-js: /etc/hosts node_modules ## Iniciar el servidor de desarrollo de Javascript + $(hain) 'bundle exec ./bin/webpack-dev-server' + +serve: /etc/hosts postgresql Gemfile.lock ## Iniciar el servidor de desarrollo de Rails $(MAKE) rails args=server -# make rails args="db:migrate" -rails: +rails: ## Tareas de Rails $(MAKE) bundle args="exec rails $(args)" -rake: +rake: ## Tareas de Rake $(MAKE) bundle args="exec rake $(args)" -bundle: - $(hain) 'cd /Sutty/sutty; bundle $(args)' +bundle: ## Tareas de bundler + $(hain) 'bundle $(args)' -yarn: +rubocop: ## Yutea el código que está por ser commiteado + git status --porcelain \ + | grep -E "^(A|M)" \ + | sed "s/^...//" \ + | grep ".rb$$" \ + | ../haini.sh/haini.sh "xargs -r ./bin/rubocop --auto-correct" + +audit: ## Encuentra dependencias con vulnerabilidades + $(hain) 'gem install bundler-audit' + $(hain) 'bundle audit --update' + +brakeman: ## Busca posibles vulnerabilidades en Sutty + $(MAKE) bundle args='exec brakeman' + +yarn: ## Tareas de yarn $(hain) 'yarn $(args)' -# Servir JS con el dev server. -# Esto acelera la compilación del javascript, tiene que correrse por separado -# de serve. -serve-js: /etc/hosts - $(hain) 'cd /Sutty/sutty; bundle exec ./bin/webpack-dev-server' +clean: ## Limpieza + rm -rf _sites/test-* _deploy/test-* log/*.log tmp/cache tmp/letter_opener tmp/miniprofiler tmp/storage -# Limpiar los archivos de testeo -clean: - rm -rf _sites/test-* _deploy/test-* - -# Generar la imagen Docker -build: assets +build: Gemfile.lock ## Generar la imagen Docker time docker build --build-arg="BRANCH=$(branch)" --build-arg="RAILS_MASTER_KEY=`cat config/master.key`" -t sutty/$(container) . docker tag sutty/$(container):latest sutty:keep + @echo -e "\a" -save: - time docker save sutty/$(container):latest | ssh root@$(delegate).sutty.nl docker load +save: ## Subir la imagen Docker al nodo delegado + time docker save sutty/$(container):latest | ssh root@$(delegate) docker load date +%F | xargs -I {} git tag -f $(container)-{} @echo -e "\a" -# proyectos. -../gems/: - mkdir -p $@ - -# Crear el directorio donde se almacenan las gemas binarias -# TODO: Mover a un proyecto propio, porque lo utilizamos en todos los -gem_dir := $(shell readlink -f ../gems) -gem_cache_dir := $(gem_dir)/cache -gem_binary_dir := $(gem_dir)/$(alpine_version) -ifeq ($(MAKECMDGOALS),build-gems) -gems := $(shell bundle show --paths | xargs -I {} sh -c 'find {}/ext/ -name extconf.rb &>/dev/null && basename {}') -gems := $(patsubst %-x86_64-linux,%,$(gems)) -gems := $(patsubst %,$(gem_cache_dir)/%.gem,$(gems)) -gems_musl := $(patsubst $(gem_cache_dir)/%.gem,$(gem_binary_dir)/%-x86_64-linux-musl.gem,$(gems)) -endif - -$(gem_binary_dir)/%-x86_64-linux-musl.gem: - @docker run \ - -v $(gem_dir):/srv/gems \ - -v `readlink -f ~/.ccache`:/home/builder/.ccache \ - -e HTTP_BASIC_USER=$(HTTP_BASIC_USER) \ - -e HTTP_BASIC_PASSWORD=$(HTTP_BASIC_PASSWORD) \ - -e GEM=`echo $(notdir $*) | sed -re "s/-[^-]+$$//"` \ - -e VERSION=`echo $(notdir $*) | sed -re "s/.*-([^-]+)$$/\1/"` \ - -e JOBS=2 \ - --rm -it \ - sutty/gem-compiler:latest || echo "No se pudo compilar $*" - -# Compilar todas las gemas binarias y subirlas a gems.sutty.nl para que -# al crear el contenedor no tengamos que compilarlas cada vez -build-gems: $(gems_musl) - -cached_gems = $(wildcard $(gem_dir)/cache/*.gem) -rebuild_gems = $(patsubst $(gem_dir)/cache/%.gem,$(gem_dir)/$(alpine_version)/%-x86_64-linux-musl.gem,$(cached_gems)) -rebuild-gems: $(rebuild_gems) - -dirs := $(patsubst %,root/%,data sites deploy public) - -$(dirs): - mkdir -p $@ - -ota: assets +ota-js: assets ## Actualizar Javascript en el nodo delegado sudo chgrp -R 82 public/ - rsync -avi --delete-after public/ $(delegate):/srv/sutty/srv/http/data/_$(public)/ - ssh $(delegate) docker exec $(container) sh -c "cat /srv/http/tmp/puma.pid | xargs -r kill -USR2" + rsync -avi --delete-after public/ root@$(delegate):/srv/sutty/srv/http/data/_$(public)/ + ssh root@$(delegate) docker exec $(container) sh -c "cat /srv/http/tmp/puma.pid | xargs -r kill -USR2" -# Hotfixes -# -# TODO: Reemplazar esto por git pull en el contenedor -commit ?= origin/rails -ota-rb: +ota: ## Actualizar Rails en el nodo delegado umask 022; git format-patch $(commit) scp ./0*.patch $(delegate):/tmp/ ssh $(delegate) mkdir -p /tmp/patches-$(commit)/ @@ -140,6 +117,19 @@ ota-rb: ssh $(delegate) docker exec $(container) ota $(commit) rm ./0*.patch +# Todos los archivos de assets. Si alguno cambia, se van a recompilar +# los assets que luego se suben al nodo delegado. +assets := package.json yarn.lock $(shell find app/assets/ app/javascript/ -type f) +public/packs/manifest.json.br: $(assets) + $(hain) 'PANEL_URL=https://panel.sutty.nl RAILS_ENV=production NODE_ENV=production bundle exec rake assets:precompile assets:clean' + +# Correr un test en particular por ejemplo +# `make test/models/usuarie_test.rb` +tests := $(shell find test/ -name "*_test.rb") +$(tests): always + $(MAKE) test args="TEST=$@" + +# Agrega las direcciones locales al sistema /etc/hosts: always @echo "Chequeando si es necesario agregar el dominio local $(SUTTY)" @grep -q " $(SUTTY)$$" $@ || echo -e "127.0.0.1 $(SUTTY)\n::1 $(SUTTY)" | sudo tee -a $@ @@ -147,4 +137,12 @@ ota-rb: @grep -q " panel.$(SUTTY)$$" $@ || echo -e "127.0.0.1 panel.$(SUTTY)\n::1 panel.$(SUTTY)" | sudo tee -a $@ @grep -q " postgresql.$(SUTTY)$$" $@ || echo -e "127.0.0.1 postgresql.$(SUTTY)\n::1 postgresql.$(SUTTY)" | sudo tee -a $@ +# Instala las dependencias de Javascript +node_modules: package.json + $(MAKE) yarn + +# Instala las dependencias de Rails +Gemfile.lock: Gemfile + $(MAKE) bundle args=install + .PHONY: always diff --git a/README.md b/README.md index ef889f9b..25d0d31c 100644 --- a/README.md +++ b/README.md @@ -15,6 +15,17 @@ Este repositorio es la plataforma _Ruby on Rails_ para alojar el Para más información visita el [sitio de Sutty](https://sutty.nl/). +### Desarrollar + +Todas las tareas se gestionan con `make`, por favor instala GNU Make +antes de comenzar. + +```bash +make help +``` + +[Leer la documentación](https://docs.sutty.nl/) + ## English Sutty is a platform for hosting safer, faster and more resilient @@ -25,3 +36,13 @@ This repository is the Ruby on Rails platform that hosts the self-managed [panel](https://panel.sutty.nl/). For more information, visit [Sutty's website](https://sutty.nl/en/). + +### Development + +Every task is run via `make`, please install GNU Make before developing. + +```bash +make help +``` + +[Read the documentation](https://docs.sutty.nl/en/) From 68bd68a2ee2cac6e990f49f1266b612e771fd4d3 Mon Sep 17 00:00:00 2001 From: f Date: Tue, 13 Jul 2021 17:22:05 -0300 Subject: [PATCH 3/8] =?UTF-8?q?actualizaci=C3=B3n=20de=20cuidados,=20resue?= =?UTF-8?q?lve=20un=20cve=20en=20addressable?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Gemfile.lock | 162 +++++++++++++++++++++++++-------------------------- 1 file changed, 81 insertions(+), 81 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index aed60b18..33fba3a0 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -18,66 +18,66 @@ GIT GEM remote: https://gems.sutty.nl/ specs: - actioncable (6.1.3.2) - actionpack (= 6.1.3.2) - activesupport (= 6.1.3.2) + actioncable (6.1.4) + actionpack (= 6.1.4) + activesupport (= 6.1.4) nio4r (~> 2.0) websocket-driver (>= 0.6.1) - actionmailbox (6.1.3.2) - actionpack (= 6.1.3.2) - activejob (= 6.1.3.2) - activerecord (= 6.1.3.2) - activestorage (= 6.1.3.2) - activesupport (= 6.1.3.2) + actionmailbox (6.1.4) + actionpack (= 6.1.4) + activejob (= 6.1.4) + activerecord (= 6.1.4) + activestorage (= 6.1.4) + activesupport (= 6.1.4) mail (>= 2.7.1) - actionmailer (6.1.3.2) - actionpack (= 6.1.3.2) - actionview (= 6.1.3.2) - activejob (= 6.1.3.2) - activesupport (= 6.1.3.2) + actionmailer (6.1.4) + actionpack (= 6.1.4) + actionview (= 6.1.4) + activejob (= 6.1.4) + activesupport (= 6.1.4) mail (~> 2.5, >= 2.5.4) rails-dom-testing (~> 2.0) - actionpack (6.1.3.2) - actionview (= 6.1.3.2) - activesupport (= 6.1.3.2) + actionpack (6.1.4) + actionview (= 6.1.4) + activesupport (= 6.1.4) rack (~> 2.0, >= 2.0.9) rack-test (>= 0.6.3) rails-dom-testing (~> 2.0) rails-html-sanitizer (~> 1.0, >= 1.2.0) - actiontext (6.1.3.2) - actionpack (= 6.1.3.2) - activerecord (= 6.1.3.2) - activestorage (= 6.1.3.2) - activesupport (= 6.1.3.2) + actiontext (6.1.4) + actionpack (= 6.1.4) + activerecord (= 6.1.4) + activestorage (= 6.1.4) + activesupport (= 6.1.4) nokogiri (>= 1.8.5) - actionview (6.1.3.2) - activesupport (= 6.1.3.2) + actionview (6.1.4) + activesupport (= 6.1.4) builder (~> 3.1) erubi (~> 1.4) rails-dom-testing (~> 2.0) rails-html-sanitizer (~> 1.1, >= 1.2.0) - activejob (6.1.3.2) - activesupport (= 6.1.3.2) + activejob (6.1.4) + activesupport (= 6.1.4) globalid (>= 0.3.6) - activemodel (6.1.3.2) - activesupport (= 6.1.3.2) - activerecord (6.1.3.2) - activemodel (= 6.1.3.2) - activesupport (= 6.1.3.2) - activestorage (6.1.3.2) - actionpack (= 6.1.3.2) - activejob (= 6.1.3.2) - activerecord (= 6.1.3.2) - activesupport (= 6.1.3.2) + activemodel (6.1.4) + activesupport (= 6.1.4) + activerecord (6.1.4) + activemodel (= 6.1.4) + activesupport (= 6.1.4) + activestorage (6.1.4) + actionpack (= 6.1.4) + activejob (= 6.1.4) + activerecord (= 6.1.4) + activesupport (= 6.1.4) marcel (~> 1.0.0) - mini_mime (~> 1.0.2) - activesupport (6.1.3.2) + mini_mime (>= 1.1.0) + activesupport (6.1.4) concurrent-ruby (~> 1.0, >= 1.0.2) i18n (>= 1.6, < 2) minitest (>= 5.1) tzinfo (~> 2.0) zeitwerk (~> 2.3) - addressable (2.7.0) + addressable (2.8.0) public_suffix (>= 2.0.2, < 5.0) adhesiones-jekyll-theme (0.2.1) jekyll (~> 4.0) @@ -113,7 +113,7 @@ GEM rack (>= 1.0.0) rack-test (>= 0.5.4) xpath (>= 2.0, < 4.0) - chartkick (4.0.4) + chartkick (4.0.5) childprocess (3.0.0) coderay (1.1.3) colorator (1.1.0) @@ -130,7 +130,7 @@ GEM database_cleaner-core (~> 2.0.0) database_cleaner-core (2.0.1) dead_end (1.1.7) - derailed_benchmarks (2.1.0) + derailed_benchmarks (2.1.1) benchmark-ips (~> 2) dead_end get_process_mem (~> 0) @@ -148,8 +148,8 @@ GEM railties (>= 4.1.0) responders warden (~> 1.2.3) - devise-i18n (1.9.4) - devise (>= 4.7.1) + devise-i18n (1.10.0) + devise (>= 4.8.0) devise_invitable (2.0.5) actionmailer (>= 5.0) devise (>= 4.6) @@ -196,7 +196,7 @@ GEM railties (>= 5.0.0) fast_blank (1.0.0-x86_64-linux-musl) fast_jsonparser (0.5.0-x86_64-linux-musl) - ffi (1.15.1-x86_64-linux-musl) + ffi (1.15.3-x86_64-linux-musl) flamegraph (0.9.5) forwardable-extended (2.6.0) friendly_id (5.4.2) @@ -214,7 +214,7 @@ GEM tilt haml-lint (0.999.999) haml_lint - haml_lint (0.37.0) + haml_lint (0.37.1) haml (>= 4.0, < 5.3) parallel (~> 1.10) rainbow @@ -264,8 +264,8 @@ GEM rouge (~> 3.0) safe_yaml (~> 1.0) terminal-table (~> 2.0) - jekyll-commonmark (1.3.1) - commonmarker (~> 0.14) + jekyll-commonmark (1.3.2) + commonmarker (~> 0.14, < 0.22) jekyll (>= 3.7, < 5.0) jekyll-data (1.1.2) jekyll (>= 3.3, < 5.0.0) @@ -284,10 +284,10 @@ GEM ruby-vips (~> 2) jekyll-include-cache (0.2.1) jekyll (>= 3.7, < 5.0) - jekyll-linked-posts (0.2.0) + jekyll-linked-posts (0.4.0) jekyll (~> 4) jekyll-locales (0.1.12) - jekyll-lunr (0.2.0) + jekyll-lunr (0.3.0) loofah (~> 2.4) jekyll-order (0.1.4) jekyll-relative-urls (0.0.6) @@ -296,7 +296,7 @@ GEM sassc (> 2.0.1, < 3.0) jekyll-seo-tag (2.7.1) jekyll (>= 3.8, < 5.0) - jekyll-spree-client (0.1.14) + jekyll-spree-client (0.1.15) fast_blank (~> 1) spree-api-client (~> 0.2) jekyll-turbolinks (0.0.5) @@ -324,7 +324,7 @@ GEM ruby_dep (~> 1.2) loaf (0.10.0) railties (>= 3.2) - lockbox (0.6.4) + lockbox (0.6.5) lograge (0.11.2) actionpack (>= 4) activesupport (>= 4) @@ -341,10 +341,10 @@ GEM method_source (1.0.0) mime-types (3.3.1) mime-types-data (~> 3.2015) - mime-types-data (3.2021.0225) + mime-types-data (3.2021.0704) mini_histogram (0.3.1) mini_magick (4.11.0) - mini_mime (1.0.3) + mini_mime (1.1.0) minima (2.5.1) jekyll (>= 3.5, < 5.0) jekyll-feed (~> 0.9) @@ -361,7 +361,7 @@ GEM racc (~> 1.4) orm_adapter (0.5.0) parallel (1.20.1) - parser (3.0.1.1) + parser (3.0.2.0) ast (~> 2.4.1) pathutil (0.16.2) forwardable-extended (~> 2.6) @@ -370,7 +370,7 @@ GEM activerecord (>= 5.2) activesupport (>= 5.2) popper_js (1.16.0) - prometheus_exporter (0.7.0) + prometheus_exporter (0.8.0) webrick pry (0.14.1) coderay (~> 1.1) @@ -401,20 +401,20 @@ GEM jekyll-relative-urls (~> 0.0) jekyll-seo-tag (~> 2.1) jekyll-turbolinks (~> 0) - rails (6.1.3.2) - actioncable (= 6.1.3.2) - actionmailbox (= 6.1.3.2) - actionmailer (= 6.1.3.2) - actionpack (= 6.1.3.2) - actiontext (= 6.1.3.2) - actionview (= 6.1.3.2) - activejob (= 6.1.3.2) - activemodel (= 6.1.3.2) - activerecord (= 6.1.3.2) - activestorage (= 6.1.3.2) - activesupport (= 6.1.3.2) + rails (6.1.4) + actioncable (= 6.1.4) + actionmailbox (= 6.1.4) + actionmailer (= 6.1.4) + actionpack (= 6.1.4) + actiontext (= 6.1.4) + actionview (= 6.1.4) + activejob (= 6.1.4) + activemodel (= 6.1.4) + activerecord (= 6.1.4) + activestorage (= 6.1.4) + activesupport (= 6.1.4) bundler (>= 1.15.0) - railties (= 6.1.3.2) + railties (= 6.1.4) sprockets-rails (>= 2.0.0) rails-dom-testing (2.0.3) activesupport (>= 4.2.0) @@ -426,14 +426,14 @@ GEM railties (>= 6.0.0, < 7) rails_warden (0.6.0) warden (>= 1.2.0) - railties (6.1.3.2) - actionpack (= 6.1.3.2) - activesupport (= 6.1.3.2) + railties (6.1.4) + actionpack (= 6.1.4) + activesupport (= 6.1.4) method_source - rake (>= 0.8.7) + rake (>= 0.13) thor (~> 1.0) rainbow (3.0.0) - rake (13.0.3) + rake (13.0.6) rb-fsevent (0.11.0) rb-inotify (0.10.1) ffi (~> 1.0) @@ -480,7 +480,7 @@ GEM railties (>= 5.0) rexml (3.2.5) rouge (3.26.0) - rubocop (1.17.0) + rubocop (1.18.3) parallel (~> 1.10) parser (>= 3.0.0.0) rainbow (>= 2.2.2, < 4.0) @@ -491,7 +491,7 @@ GEM unicode-display_width (>= 1.4.0, < 3.0) rubocop-ast (1.7.0) parser (>= 3.0.1.1) - rubocop-rails (2.10.1) + rubocop-rails (2.11.3) activesupport (>= 4.2.0) rack (>= 1.1) rubocop (>= 1.7.0, < 2.0) @@ -506,10 +506,10 @@ GEM ruby_parser (~> 3.1) sexp_processor (~> 4.6) ruby_dep (1.5.0) - ruby_parser (3.15.1) - sexp_processor (~> 4.9) - rubyzip (2.3.0) - rugged (1.1.0-x86_64-linux-musl) + ruby_parser (3.16.0) + sexp_processor (~> 4.15, >= 4.15.1) + rubyzip (2.3.2) + rugged (1.1.1-x86_64-linux-musl) safe_yaml (1.0.6) safely_block (0.3.0) errbase (>= 0.1.1) @@ -525,7 +525,7 @@ GEM childprocess (>= 0.5, < 4.0) rubyzip (>= 1.2.2) semantic_range (3.0.0) - sexp_processor (4.15.2) + sexp_processor (4.15.3) share-to-fediverse-jekyll-theme (0.1.4) jekyll (~> 4.0) jekyll-data (~> 1.1) @@ -537,7 +537,7 @@ GEM simpleidn (0.2.1) unf (~> 0.1.4) sourcemap (0.1.1) - spree-api-client (0.2.1) + spree-api-client (0.2.2) fast_blank (~> 1) httparty (~> 0.18.0) spring (2.1.1) From 8f88023d52257fba2152dfcd8bc4bc62ea57214f Mon Sep 17 00:00:00 2001 From: f Date: Thu, 22 Jul 2021 16:16:10 -0300 Subject: [PATCH 4/8] El espacio es importante --- Makefile | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/Makefile b/Makefile index a4480476..0bb5f582 100644 --- a/Makefile +++ b/Makefile @@ -12,12 +12,13 @@ include .env export -args ?= ## Argumentos para Hain -commit ?= origin/rails ## Commit desde el que actualizar -env ?= staging ## Entorno del nodo delegado -sutty ?= $(SUTTY) ## Dirección local -delegate ?= $(DELEGATE) ## Cambia el nodo delegado -hain ?= $(HAINISH) ## Ubicación de Hainish +# XXX: El espacio antes del comentario cuenta como espacio +args ?=## Argumentos para Hain +commit ?= origin/rails## Commit desde el que actualizar +env ?= staging## Entorno del nodo delegado +sutty ?= $(SUTTY)## Dirección local +delegate ?= $(DELEGATE)## Cambia el nodo delegado +hain ?= $(HAINISH)## Ubicación de Hainish # El nodo delegado tiene dos entornos, production y staging. # Dependiendo del entorno que elijamos, se van a generar los assets y el From d474b819ad60ebe24e3f3ba63616bfe2300c6d5c Mon Sep 17 00:00:00 2001 From: f Date: Thu, 22 Jul 2021 16:19:25 -0300 Subject: [PATCH 5/8] agregar request_uri a los logs sutty/containers/nginx!1 --- .../20210722191718_add_request_uri_to_access_logs.rb | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 db/migrate/20210722191718_add_request_uri_to_access_logs.rb diff --git a/db/migrate/20210722191718_add_request_uri_to_access_logs.rb b/db/migrate/20210722191718_add_request_uri_to_access_logs.rb new file mode 100644 index 00000000..3d225aed --- /dev/null +++ b/db/migrate/20210722191718_add_request_uri_to_access_logs.rb @@ -0,0 +1,10 @@ +# frozen_string_literal: true + +# Agrega la columna de request_uri a la tabla de logs +class AddRequestUriToAccessLogs < ActiveRecord::Migration[6.1] + def change + return unless Rails.env.production? + + add_column :access_logs, :request_uri, :string, default: '' + end +end From d456feac8e70418f52c962e82a40b58559858a4e Mon Sep 17 00:00:00 2001 From: f Date: Thu, 29 Jul 2021 14:46:29 -0300 Subject: [PATCH 6/8] =?UTF-8?q?Cancelar=20la=20tarea=20pendiente=20si=20to?= =?UTF-8?q?m=C3=B3=20mas=20de=2010=20minutos?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Si la tarea se reintentó durante 10 minutos, lo más probable es que haya quedado trabada en algún lado. Este cambio permite volver a compilar sitios al cambiar el estado a espera y cancelarse a sí misma. --- app/jobs/deploy_job.rb | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/app/jobs/deploy_job.rb b/app/jobs/deploy_job.rb index f1ceca9e..70997ce1 100644 --- a/app/jobs/deploy_job.rb +++ b/app/jobs/deploy_job.rb @@ -5,13 +5,23 @@ class DeployJob < ApplicationJob class DeployException < StandardError; end # rubocop:disable Metrics/MethodLength - def perform(site, notify = true) + def perform(site, notify = true, time = Time.now) ActiveRecord::Base.connection_pool.with_connection do @site = Site.find(site) - # Si ya hay una tarea corriendo, aplazar esta + # Si ya hay una tarea corriendo, aplazar esta. Si estuvo + # esperando más de 10 minutos, recuperar el estado anterior. + # + # Como el trabajo actual se aplaza al siguiente, arrastrar la + # hora original para poder ir haciendo timeouts. if @site.building? - DeployJob.perform_in(60, site, notify) + if 10.minutes.ago >= time + @site.update status: 'waiting' + raise DeployException, + "#{@site.name} la tarea estuvo más de 10 minutos esperando, volviendo al estado original" + end + + DeployJob.perform_in(60, site, notify, time) return end @@ -29,8 +39,11 @@ class DeployJob < ApplicationJob end deploy_others - notify_usuaries if notify + + # Volver a la espera @site.update status: 'waiting' + + notify_usuaries if notify end end # rubocop:enable Metrics/MethodLength From 4c84389b3561f8b34831736f196a9729f96f9bbb Mon Sep 17 00:00:00 2001 From: Nulo <5151-Nulo@users.noreply.0xacab.org> Date: Mon, 2 Aug 2021 16:17:30 +0000 Subject: [PATCH 7/8] Apply 3 suggestion(s) to 1 file(s) --- Makefile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index 0bb5f582..03fd395d 100644 --- a/Makefile +++ b/Makefile @@ -62,13 +62,13 @@ serve-js: /etc/hosts node_modules ## Iniciar el servidor de desarrollo de Javasc serve: /etc/hosts postgresql Gemfile.lock ## Iniciar el servidor de desarrollo de Rails $(MAKE) rails args=server -rails: ## Tareas de Rails +rails: ## Corre rails dentro del entorno de desarrollo (pasar argumentos con args=). $(MAKE) bundle args="exec rails $(args)" -rake: ## Tareas de Rake +rake: ## Corre rake dentro del entorno de desarrollo (pasar argumentos con args=). $(MAKE) bundle args="exec rake $(args)" -bundle: ## Tareas de bundler +bundle: ## Corre bundle dentro del entorno de desarrollo (pasar argumentos con args=). $(hain) 'bundle $(args)' rubocop: ## Yutea el código que está por ser commiteado From 9f84c14a69e3102d96087f589d1fa1bc18b6a877 Mon Sep 17 00:00:00 2001 From: f Date: Sat, 7 Aug 2021 15:55:00 -0300 Subject: [PATCH 8/8] Soportar sitios sin yarn.lock MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Como el chequeo devuelve nil, un sitio sin yarn.lock nunca se compilaría. --- app/models/deploy_local.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/deploy_local.rb b/app/models/deploy_local.rb index 02b837f0..c063b7bc 100644 --- a/app/models/deploy_local.rb +++ b/app/models/deploy_local.rb @@ -80,7 +80,7 @@ class DeployLocal < Deploy # Corre yarn dentro del repositorio def yarn - return unless yarn_lock? + return true unless yarn_lock? run 'yarn' end