From 92f8bc8f0314ffbf0246d159dca5b9a786e40ea6 Mon Sep 17 00:00:00 2001 From: Osamu Takiya Date: Sat, 18 Jun 2022 07:29:23 +0900 Subject: [PATCH 01/12] =?UTF-8?q?ci:=20=F0=9F=8E=A1=20PostgreSQL=20?= =?UTF-8?q?=E3=82=92=E5=B0=8E=E5=85=A5=E3=81=97=E3=81=9F=20GitHub=20Action?= =?UTF-8?q?s=20=E3=82=92=E4=BD=9C=E6=88=90=20(#47)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/gss2020_backend.yml | 71 +++++++++++++-------------- .rspec | 2 +- spec/misc/foo_spec.rb | 7 --- 3 files changed, 34 insertions(+), 46 deletions(-) delete mode 100644 spec/misc/foo_spec.rb diff --git a/.github/workflows/gss2020_backend.yml b/.github/workflows/gss2020_backend.yml index 3ed96d68..c21cb62f 100644 --- a/.github/workflows/gss2020_backend.yml +++ b/.github/workflows/gss2020_backend.yml @@ -12,29 +12,27 @@ jobs: matrix: node-version: ["18.x"] ruby-version: ["3.1"] + services: + postgres: + image: postgres + ports: + - 5432:5432 + env: + POSTGRES_USER: postgres + POSTGRES_PASSWORD: postgres + POSTGRES_DB: suikoden_election_2022_test + options: >- + --health-cmd pg_isready + --health-interval 10s + --health-timeout 5s + --health-retries 5 + env: + RAILS_ENV: test + POSTGRES_HOST_TEST: 127.0.0.1 + POSTGRES_PORT_TEST: 5432 + POSTGRES_USERNAME_TEST: postgres + POSTGRES_PASSWORD_TEST: postgres steps: - # - name: MySQL のセットアップを行う - # # https://github.com/mirromutth/mysql-action - # uses: mirromutth/mysql-action@v1.1 - # with: - # host port: 3306 - # container port: 3306 - # character set server: utf8mb4 - # collation server: utf8mb4_unicode_ci - # mysql version: '8.0' - # # mysql database: some_test - # mysql root password: root - # # mysql user: 'developer' - # # mysql password: ${{ secrets.DatabasePassword }} - # - name: MySQL の疎通を待つ - # run: | - # while ! mysqladmin ping --host=127.0.0.1 --password=root --silent; do - # sleep 1 - # done - # - name: MySQL の文字コードおよびバージョンを確認する - # run: | - # mysql -h 127.0.0.1 --port 3306 -uroot -proot -e "show variables like 'chara%'" - # mysql -h 127.0.0.1 --port 3306 -uroot -proot -e "select version()" - name: コードをチェックアウトする uses: actions/checkout@v3 - name: Ruby のセットアップを行う @@ -42,19 +40,16 @@ jobs: with: ruby-version: ${{ matrix.ruby-version }} bundler-cache: true - # - name: Node.js のセットアップを行う - # uses: actions/setup-node@v3 - # with: - # node-version: ${{ matrix.node-version }} - # cache: "yarn" - # - name: db:create db:migrate する - # run: | - # bin/rails db:create db:migrate - # env: - # RAILS_ENV: test - # DATABASE_HOST: 127.0.0.1 - # - name: RSpec を実行する - # run: | - # bundle exec rspec - # env: - # DATABASE_HOST: 127.0.0.1 + - name: (予定地)Node.js のセットアップを行う + run: | + echo 'Node.js を使うことがあれば "actions/setup-node" を用いる' + # uses: actions/setup-node@v3 + # with: + # node-version: ${{ matrix.node-version }} + # cache: "yarn" + - name: db:create db:migrate する + run: | + bin/rails db:create db:migrate + - name: RSpec を実行する + run: | + bundle exec rspec diff --git a/.rspec b/.rspec index aae9b46f..8dbc462c 100644 --- a/.rspec +++ b/.rspec @@ -1 +1 @@ ---require spec_helper --format documentation +--require spec_helper --format documentation --force-color --backtrace diff --git a/spec/misc/foo_spec.rb b/spec/misc/foo_spec.rb deleted file mode 100644 index 40fe5591..00000000 --- a/spec/misc/foo_spec.rb +++ /dev/null @@ -1,7 +0,0 @@ -require 'rails_helper' - -RSpec.describe do - it 'Bar' do - expect(1 + 1).to eq 2 - end -end From c92c1d3f741c9489b437aca5bfa18782cd6e1f7c Mon Sep 17 00:00:00 2001 From: Osamu Takiya Date: Sat, 18 Jun 2022 15:28:45 +0900 Subject: [PATCH 02/12] =?UTF-8?q?docs:=20=E2=9C=8F=EF=B8=8F=20GitHub=20Act?= =?UTF-8?q?ions=20=E3=81=AE=E3=83=90=E3=83=83=E3=82=B8=E3=82=92=20README?= =?UTF-8?q?=20=E3=81=AB=E8=BF=BD=E5=8A=A0=E3=81=97=E3=81=9F=20(#50)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 5897995a..aee9e014 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,4 @@ +[![幻水総選挙2022 バックエンド](https://github.com/true-runes/suikoden-election-2022-backend/actions/workflows/gss2020_backend.yml/badge.svg)](https://github.com/true-runes/suikoden-election-2022-backend/actions/workflows/gss2020_backend.yml) + # 幻水総選挙2022(バックエンド) - いつもの From 6288e2ae5f557dadc7e23c5252b65df35914bbaf Mon Sep 17 00:00:00 2001 From: Osamu Takiya Date: Sat, 18 Jun 2022 20:38:58 +0900 Subject: [PATCH 03/12] =?UTF-8?q?ci:=20=F0=9F=8E=A1=20CI=20=E3=81=AE?= =?UTF-8?q?=E9=9A=9B=E3=81=AB=20DB=E6=8E=A5=E7=B6=9A=E3=82=A8=E3=83=A9?= =?UTF-8?q?=E3=83=BC=20=E3=82=92=E9=81=BF=E3=81=91=E3=82=8B=E3=81=9F?= =?UTF-8?q?=E3=82=81=E3=81=AB=E5=A4=96=E9=83=A8DB=E5=88=A9=E7=94=A8?= =?UTF-8?q?=E3=81=AE=E8=A8=98=E8=BF=B0=E3=81=AB=E8=BF=BD=E8=A8=98=E3=81=97?= =?UTF-8?q?=E3=81=9F=20(#55)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/tweet_on_tweet_storage.rb | 2 +- app/models/user_on_tweet_storage.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/models/tweet_on_tweet_storage.rb b/app/models/tweet_on_tweet_storage.rb index edaa6385..91510bd6 100644 --- a/app/models/tweet_on_tweet_storage.rb +++ b/app/models/tweet_on_tweet_storage.rb @@ -1,5 +1,5 @@ class TweetOnTweetStorage < ApplicationRecord - establish_connection :tweet_storage + establish_connection :tweet_storage unless ENV['CI'] == 'true' self.table_name = :tweets diff --git a/app/models/user_on_tweet_storage.rb b/app/models/user_on_tweet_storage.rb index 38520d82..3d0374b2 100644 --- a/app/models/user_on_tweet_storage.rb +++ b/app/models/user_on_tweet_storage.rb @@ -1,5 +1,5 @@ class UserOnTweetStorage < ApplicationRecord - establish_connection :tweet_storage + establish_connection :tweet_storage unless ENV['CI'] == 'true' self.table_name = :users From b3c5b95b74fd7780ad3a768613fa93d977908928 Mon Sep 17 00:00:00 2001 From: Osamu Takiya Date: Sat, 18 Jun 2022 20:39:59 +0900 Subject: [PATCH 04/12] =?UTF-8?q?style:=20=F0=9F=92=84=20=E3=83=95?= =?UTF-8?q?=E3=82=A1=E3=82=A4=E3=83=AB=E5=90=8D=E3=82=92=E3=82=88=E3=82=8A?= =?UTF-8?q?=E3=82=8F=E3=81=8B=E3=82=8A=E3=82=84=E3=81=99=E3=81=8F=E6=AD=A3?= =?UTF-8?q?=E7=A2=BA=E3=81=AB=E3=81=97=E3=81=9F=20(#56)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...s2020_backend.yml => gss2022_backend_on_postgres_services.yml} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename .github/workflows/{gss2020_backend.yml => gss2022_backend_on_postgres_services.yml} (100%) diff --git a/.github/workflows/gss2020_backend.yml b/.github/workflows/gss2022_backend_on_postgres_services.yml similarity index 100% rename from .github/workflows/gss2020_backend.yml rename to .github/workflows/gss2022_backend_on_postgres_services.yml From da568d0ec1f7072c551cc69d0189b2c28185999d Mon Sep 17 00:00:00 2001 From: Osamu Takiya Date: Sat, 18 Jun 2022 20:53:55 +0900 Subject: [PATCH 05/12] =?UTF-8?q?test:=20=F0=9F=92=8D=20Spec=20=E3=82=92?= =?UTF-8?q?=E8=BF=BD=E5=8A=A0=E3=81=97=E3=81=A6=20CI=20=E3=82=92=E4=BD=B5?= =?UTF-8?q?=E3=81=9B=E3=81=A6=E6=95=B4=E5=82=99=E3=81=97=E3=81=9F=20(#57)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../gss2022_backend_on_postgres_services.yml | 27 ++++++++++++------- spec/factories/user.rb | 9 +++++++ spec/models/user_spec.rb | 15 +++++++++++ spec/rails_helper.rb | 1 + 4 files changed, 42 insertions(+), 10 deletions(-) create mode 100644 spec/factories/user.rb create mode 100644 spec/models/user_spec.rb diff --git a/.github/workflows/gss2022_backend_on_postgres_services.yml b/.github/workflows/gss2022_backend_on_postgres_services.yml index c21cb62f..797b4785 100644 --- a/.github/workflows/gss2022_backend_on_postgres_services.yml +++ b/.github/workflows/gss2022_backend_on_postgres_services.yml @@ -6,7 +6,7 @@ on: jobs: gss2022_backend: - name: 継続的インテグレーション + name: (pg on services) 継続的インテグレーション runs-on: ubuntu-latest strategy: matrix: @@ -14,24 +14,24 @@ jobs: ruby-version: ["3.1"] services: postgres: - image: postgres + image: postgres:14.3 ports: - 5432:5432 env: - POSTGRES_USER: postgres - POSTGRES_PASSWORD: postgres - POSTGRES_DB: suikoden_election_2022_test + POSTGRES_USER: postgres_user + POSTGRES_PASSWORD: postgres_password options: >- --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5 env: + CI: true RAILS_ENV: test - POSTGRES_HOST_TEST: 127.0.0.1 + POSTGRES_HOST_TEST: localhost POSTGRES_PORT_TEST: 5432 - POSTGRES_USERNAME_TEST: postgres - POSTGRES_PASSWORD_TEST: postgres + POSTGRES_USERNAME_TEST: postgres_user + POSTGRES_PASSWORD_TEST: postgres_password steps: - name: コードをチェックアウトする uses: actions/checkout@v3 @@ -40,6 +40,13 @@ jobs: with: ruby-version: ${{ matrix.ruby-version }} bundler-cache: true + - name: $ bundle install を行う + uses: actions/cache@v1 + with: + path: vendor/bundle + key: ${{ runner.os }}-gem-${{ hashFiles('**/Gemfile.lock') }} + restore-keys: | + ${{ runner.os }}-gem- - name: (予定地)Node.js のセットアップを行う run: | echo 'Node.js を使うことがあれば "actions/setup-node" を用いる' @@ -47,9 +54,9 @@ jobs: # with: # node-version: ${{ matrix.node-version }} # cache: "yarn" - - name: db:create db:migrate する + - name: データベースをセットアップする run: | - bin/rails db:create db:migrate + bin/rails db:prepare - name: RSpec を実行する run: | bundle exec rspec diff --git a/spec/factories/user.rb b/spec/factories/user.rb new file mode 100644 index 00000000..d4ebaeeb --- /dev/null +++ b/spec/factories/user.rb @@ -0,0 +1,9 @@ +FactoryBot.define do + factory :user do + id_number { 192789663528910849 } + name { 'My name is test' } + screen_name { 'test_screen_name' } + profile_image_url_https { 'https://pbs.twimg.com/profile_images/1123471964058914816/a8sXngWB_400x400.png' } + is_protected { false } + end +end diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb new file mode 100644 index 00000000..e43ae647 --- /dev/null +++ b/spec/models/user_spec.rb @@ -0,0 +1,15 @@ +require 'rails_helper' + +RSpec.describe User, type: :model do + let(:user) { create(:user) } + + it 'User名が期待どおりに等しくあること' do + # expect(user.name).to eq 'My name is test' + # expect(User.count).to eq 1 + end + + it 'User名が期待どおりに等しくないこと' do + # expect(user.name).not_to eq 'Your name is test' + # expect(User.count).to eq 1 + end +end diff --git a/spec/rails_helper.rb b/spec/rails_helper.rb index ef5891fc..2e4152fb 100644 --- a/spec/rails_helper.rb +++ b/spec/rails_helper.rb @@ -17,4 +17,5 @@ config.use_transactional_fixtures = true config.infer_spec_type_from_file_location! config.filter_rails_from_backtrace! + config.include FactoryBot::Syntax::Methods end From 4f7c6ca3d9a177a2ce7200822753596e5300c1d1 Mon Sep 17 00:00:00 2001 From: Osamu Takiya Date: Sat, 18 Jun 2022 21:06:44 +0900 Subject: [PATCH 06/12] =?UTF-8?q?ci:=20=F0=9F=8E=A1=20ubuntu-latest=20?= =?UTF-8?q?=E3=81=AB=E3=83=93=E3=83=AB=E3=83=88=E3=82=A4=E3=83=B3=E3=81=AE?= =?UTF-8?q?=20PostgreSQL=20=E3=81=A7=20CI=20=E3=82=92=E5=9B=9E=E3=81=99=20?= =?UTF-8?q?(#58)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../gss2022_backend_on_built_in_postgres.yml | 72 +++++++++++++++++++ 1 file changed, 72 insertions(+) create mode 100644 .github/workflows/gss2022_backend_on_built_in_postgres.yml diff --git a/.github/workflows/gss2022_backend_on_built_in_postgres.yml b/.github/workflows/gss2022_backend_on_built_in_postgres.yml new file mode 100644 index 00000000..f92b3528 --- /dev/null +++ b/.github/workflows/gss2022_backend_on_built_in_postgres.yml @@ -0,0 +1,72 @@ +name: 幻水総選挙2022 バックエンド + +on: + push: + workflow_dispatch: + +jobs: + gss2022_backend: + name: (pg on built-in) 継続的インテグレーション + runs-on: ubuntu-latest + strategy: + matrix: + node-version: ["18.x"] + ruby-version: ["3.1"] + env: + CI: true + RAILS_ENV: test + POSTGRES_HOST_TEST: localhost + POSTGRES_PORT_TEST: 5432 + POSTGRES_USERNAME_TEST: postgres_user + POSTGRES_PASSWORD_TEST: postgres_password + steps: + # https://github.com/actions/virtual-environments/blob/main/images/linux/Ubuntu2004-Readme.md + - name: PostgreSQL を起動する + run: | + sudo systemctl start postgresql.service + - name: PostgreSQL の起動待ち(ヘルスチェック)をする + run: | + until : > /dev/tcp/localhost/5432; do + echo -n . + sleep 1 + done + + echo 'PostgreSQL の起動が確認できました' + - name: PostgreSQL のユーザー(ロール)のセットアップを行う + # NOTE: バージョン番号が埋め込みになっているのが良くない + run: | + sudo bash -c "echo \"local all all md5\" >> /etc/postgresql/14/main/pg_hba.conf" + + sudo su postgres -c "psql postgres -c 'create role $username;'" + sudo su postgres -c "psql postgres -c \"alter role $username with login password '$password';\"" + sudo su postgres -c "psql postgres -c \"alter role $username with superuser\"" + env: + username: postgres_user + password: postgres_password + - name: コードをチェックアウトする + uses: actions/checkout@v3 + - name: Ruby のセットアップを行う + uses: ruby/setup-ruby@v1 + with: + ruby-version: ${{ matrix.ruby-version }} + bundler-cache: true + - name: $ bundle install を行う + uses: actions/cache@v1 + with: + path: vendor/bundle + key: ${{ runner.os }}-gem-${{ hashFiles('**/Gemfile.lock') }} + restore-keys: | + ${{ runner.os }}-gem- + - name: (予定地)Node.js のセットアップを行う + run: | + echo 'Node.js を使うことがあれば "actions/setup-node" を用いる' + # uses: actions/setup-node@v3 + # with: + # node-version: ${{ matrix.node-version }} + # cache: "yarn" + - name: データベースをセットアップする + run: | + bin/rails db:prepare + - name: RSpec を実行する + run: | + bundle exec rspec From f027869024fd5991e500a05f76cb7462df22ccad Mon Sep 17 00:00:00 2001 From: Osamu Takiya Date: Sat, 18 Jun 2022 21:27:06 +0900 Subject: [PATCH 07/12] =?UTF-8?q?fix:=20=F0=9F=90=9B=20Fix=20a=20typo=20(#?= =?UTF-8?q?59)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/gss2022_backend_on_built_in_postgres.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/gss2022_backend_on_built_in_postgres.yml b/.github/workflows/gss2022_backend_on_built_in_postgres.yml index f92b3528..e010c200 100644 --- a/.github/workflows/gss2022_backend_on_built_in_postgres.yml +++ b/.github/workflows/gss2022_backend_on_built_in_postgres.yml @@ -38,7 +38,7 @@ jobs: sudo bash -c "echo \"local all all md5\" >> /etc/postgresql/14/main/pg_hba.conf" sudo su postgres -c "psql postgres -c 'create role $username;'" - sudo su postgres -c "psql postgres -c \"alter role $username with login password '$password';\"" + sudo su postgres -c "psql postgres -c \"alter role $username with login password '$password';\"" sudo su postgres -c "psql postgres -c \"alter role $username with superuser\"" env: username: postgres_user From 95f9011dc477d055fe2ac4f5b520c34a3408db80 Mon Sep 17 00:00:00 2001 From: Osamu Takiya Date: Sun, 19 Jun 2022 11:11:06 +0900 Subject: [PATCH 08/12] =?UTF-8?q?ci:=20=F0=9F=8E=A1=20CI=20=E3=81=AE?= =?UTF-8?q?=E8=A8=AD=E5=AE=9A=E3=83=95=E3=82=A1=E3=82=A4=E3=83=AB=E3=82=92?= =?UTF-8?q?=E3=83=AA=E3=83=95=E3=82=A1=E3=82=AF=E3=82=BF=E3=83=AA=E3=83=B3?= =?UTF-8?q?=E3=82=B0=E3=81=97=E3=81=9F=20(#63)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../gss2022_backend_on_built_in_postgres.yml | 11 ++++++----- .../gss2022_backend_on_postgres_services.yml | 8 ++++---- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/.github/workflows/gss2022_backend_on_built_in_postgres.yml b/.github/workflows/gss2022_backend_on_built_in_postgres.yml index e010c200..ae25c2c8 100644 --- a/.github/workflows/gss2022_backend_on_built_in_postgres.yml +++ b/.github/workflows/gss2022_backend_on_built_in_postgres.yml @@ -35,12 +35,13 @@ jobs: - name: PostgreSQL のユーザー(ロール)のセットアップを行う # NOTE: バージョン番号が埋め込みになっているのが良くない run: | - sudo bash -c "echo \"local all all md5\" >> /etc/postgresql/14/main/pg_hba.conf" + sudo bash -c "echo \"local all all md5\" >> /etc/postgresql/$major_version_number/main/pg_hba.conf" sudo su postgres -c "psql postgres -c 'create role $username;'" sudo su postgres -c "psql postgres -c \"alter role $username with login password '$password';\"" sudo su postgres -c "psql postgres -c \"alter role $username with superuser\"" env: + major_version_number: 14 username: postgres_user password: postgres_password - name: コードをチェックアウトする @@ -60,10 +61,10 @@ jobs: - name: (予定地)Node.js のセットアップを行う run: | echo 'Node.js を使うことがあれば "actions/setup-node" を用いる' - # uses: actions/setup-node@v3 - # with: - # node-version: ${{ matrix.node-version }} - # cache: "yarn" + echo 'uses: actions/setup-node@v3' + echo 'with:' + echo 'node-version: ${{ matrix.node-version }}' + echo 'cache: "yarn"' - name: データベースをセットアップする run: | bin/rails db:prepare diff --git a/.github/workflows/gss2022_backend_on_postgres_services.yml b/.github/workflows/gss2022_backend_on_postgres_services.yml index 797b4785..082ee4ee 100644 --- a/.github/workflows/gss2022_backend_on_postgres_services.yml +++ b/.github/workflows/gss2022_backend_on_postgres_services.yml @@ -50,10 +50,10 @@ jobs: - name: (予定地)Node.js のセットアップを行う run: | echo 'Node.js を使うことがあれば "actions/setup-node" を用いる' - # uses: actions/setup-node@v3 - # with: - # node-version: ${{ matrix.node-version }} - # cache: "yarn" + echo 'uses: actions/setup-node@v3' + echo 'with:' + echo 'node-version: ${{ matrix.node-version }}' + echo 'cache: "yarn"' - name: データベースをセットアップする run: | bin/rails db:prepare From 3fe61c81996b7eac625237f222616d60902cd8a0 Mon Sep 17 00:00:00 2001 From: Osamu Takiya Date: Sun, 19 Jun 2022 11:15:12 +0900 Subject: [PATCH 09/12] =?UTF-8?q?refactor:=20=F0=9F=92=A1=20TwitterRestApi?= =?UTF-8?q?=20=E3=82=AF=E3=83=A9=E3=82=B9=E3=81=AE=E3=83=A1=E3=82=BD?= =?UTF-8?q?=E3=83=83=E3=83=89=E3=82=92=E3=83=AA=E3=83=95=E3=82=A1=E3=82=AF?= =?UTF-8?q?=E3=82=BF=E3=83=AA=E3=83=B3=E3=82=B0=E3=81=97=E3=81=9F=20(#64)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/lib/twitter_rest_api.rb | 51 +++++++++++++++++++++++++++++++++---- 1 file changed, 46 insertions(+), 5 deletions(-) diff --git a/app/lib/twitter_rest_api.rb b/app/lib/twitter_rest_api.rb index 5f0a1fcf..71267111 100644 --- a/app/lib/twitter_rest_api.rb +++ b/app/lib/twitter_rest_api.rb @@ -1,10 +1,51 @@ class TwitterRestApi - def self.client(consumer_key: nil, consumer_secret: nil, access_token: nil, access_secret: nil) + # account_key は シンボル で指定する + def self.client(account_key: nil) + return if account_key.nil? + + credentials = convert_account_key_to_credentials(account_key) + return if credentials.nil? + Twitter::REST::Client.new do |config| - config.consumer_key = consumer_key || ENV.fetch('TWITTER_CONSUMER_KEY', nil) - config.consumer_secret = consumer_secret || ENV.fetch('TWITTER_CONSUMER_SECRET', nil) - config.access_token = access_token || ENV.fetch('TWITTER_ACCESS_TOKEN', nil) - config.access_token_secret = access_secret || ENV.fetch('TWITTER_ACCESS_SECRET', nil) + config.consumer_key = credentials[:consumer_key] + config.consumer_secret = credentials[:consumer_secret] + config.access_token = credentials[:access_token] + config.access_token_secret = credentials[:access_token_secret] end end + + def self.convert_account_key_to_credentials(account_key) + { + gensosenkyo: { + consumer_key: ENV.fetch('TWITTER_CONSUMER_KEY_GENSOSENKYO', nil), + consumer_secret: ENV.fetch('TWITTER_CONSUMER_SECRET_GENSOSENKYO', nil), + access_token: ENV.fetch('TWITTER_ACCESS_TOKEN_GENSOSENKYO', nil), + access_token_secret: ENV.fetch('TWITTER_ACCESS_SECRET_GENSOSENKYO', nil) + }, + sub_gensosenkyo: { + consumer_key: ENV.fetch('TWITTER_CONSUMER_KEY_SUB_GENSOSENKYO', nil), + consumer_secret: ENV.fetch('TWITTER_CONSUMER_SECRET_SUB_GENSOSENKYO', nil), + access_token: ENV.fetch('TWITTER_ACCESS_TOKEN_SUB_GENSOSENKYO', nil), + access_token_secret: ENV.fetch('TWITTER_ACCESS_SECRET_SUB_GENSOSENKYO', nil) + }, + tmytn: { + consumer_key: ENV.fetch('TWITTER_CONSUMER_KEY_TMYTN', nil), + consumer_secret: ENV.fetch('TWITTER_CONSUMER_SECRET_TMYTN', nil), + access_token: ENV.fetch('TWITTER_ACCESS_TOKEN_TMYTN', nil), + access_token_secret: ENV.fetch('TWITTER_ACCESS_SECRET_TMYTN', nil) + }, + tmychan: { + consumer_key: ENV.fetch('TWITTER_CONSUMER_KEY_TMYCHAN', nil), + consumer_secret: ENV.fetch('TWITTER_CONSUMER_SECRET_TMYCHAN', nil), + access_token: ENV.fetch('TWITTER_ACCESS_TOKEN_TMYCHAN', nil), + access_token_secret: ENV.fetch('TWITTER_ACCESS_SECRET_TMYCHAN', nil) + }, + ayy: { + consumer_key: ENV.fetch('TWITTER_CONSUMER_KEY_AYY', nil), + consumer_secret: ENV.fetch('TWITTER_CONSUMER_SECRET_AYY', nil), + access_token: ENV.fetch('TWITTER_ACCESS_TOKEN_AYY', nil), + access_token_secret: ENV.fetch('TWITTER_ACCESS_SECRET_AYY', nil) + } + }[account_key] + end end From 1ecfeef62d0f0e5cb18b28232190d9fc4c229345 Mon Sep 17 00:00:00 2001 From: Osamu Takiya Date: Sun, 19 Jun 2022 11:17:22 +0900 Subject: [PATCH 10/12] =?UTF-8?q?docs:=20=E2=9C=8F=EF=B8=8F=20YAML?= =?UTF-8?q?=E3=81=AE=E3=83=95=E3=82=A1=E3=82=A4=E3=83=AB=E5=90=8D=E5=A4=89?= =?UTF-8?q?=E6=9B=B4=E3=81=AB=E4=BC=B4=E3=81=84=20README=20=E3=81=AE=20?= =?UTF-8?q?=E3=83=90=E3=83=83=E3=82=B8=20=E3=81=AE=E8=A8=98=E8=BF=B0?= =?UTF-8?q?=E3=82=92=E5=A4=89=E6=9B=B4=E3=81=97=E3=81=9F=20(#65)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index aee9e014..d627b71e 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,8 @@ -[![幻水総選挙2022 バックエンド](https://github.com/true-runes/suikoden-election-2022-backend/actions/workflows/gss2020_backend.yml/badge.svg)](https://github.com/true-runes/suikoden-election-2022-backend/actions/workflows/gss2020_backend.yml) +On PostgreSQL Services +[![幻水総選挙2022 バックエンド](https://github.com/true-runes/suikoden-election-2022-backend/actions/workflows/gss2022_backend_on_postgres_services.yml/badge.svg)](https://github.com/true-runes/suikoden-election-2022-backend/actions/workflows/gss2022_backend_on_postgres_services.yml) + +On Built-In PostgreSQL +[![幻水総選挙2022 バックエンド](https://github.com/true-runes/suikoden-election-2022-backend/actions/workflows/gss2022_backend_on_built_in_postgres.yml/badge.svg)](https://github.com/true-runes/suikoden-election-2022-backend/actions/workflows/gss2022_backend_on_built_in_postgres.yml) # 幻水総選挙2022(バックエンド) - いつもの From c9f648225eef29ef7b44fd0f17684d0366552b9d Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Sun, 19 Jun 2022 11:18:24 +0900 Subject: [PATCH 11/12] chore(deps): add renovate.json (#60) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- renovate.json | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 renovate.json diff --git a/renovate.json b/renovate.json new file mode 100644 index 00000000..f45d8f11 --- /dev/null +++ b/renovate.json @@ -0,0 +1,5 @@ +{ + "extends": [ + "config:base" + ] +} From 7c3c77e43b7774e49b48562787cd8d7fc59c3555 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Sun, 19 Jun 2022 11:20:15 +0900 Subject: [PATCH 12/12] chore(deps): update actions/cache action to v3 (#66) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- .github/workflows/gss2022_backend_on_built_in_postgres.yml | 2 +- .github/workflows/gss2022_backend_on_postgres_services.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/gss2022_backend_on_built_in_postgres.yml b/.github/workflows/gss2022_backend_on_built_in_postgres.yml index ae25c2c8..ce4cf348 100644 --- a/.github/workflows/gss2022_backend_on_built_in_postgres.yml +++ b/.github/workflows/gss2022_backend_on_built_in_postgres.yml @@ -52,7 +52,7 @@ jobs: ruby-version: ${{ matrix.ruby-version }} bundler-cache: true - name: $ bundle install を行う - uses: actions/cache@v1 + uses: actions/cache@v3 with: path: vendor/bundle key: ${{ runner.os }}-gem-${{ hashFiles('**/Gemfile.lock') }} diff --git a/.github/workflows/gss2022_backend_on_postgres_services.yml b/.github/workflows/gss2022_backend_on_postgres_services.yml index 082ee4ee..5246b1b3 100644 --- a/.github/workflows/gss2022_backend_on_postgres_services.yml +++ b/.github/workflows/gss2022_backend_on_postgres_services.yml @@ -41,7 +41,7 @@ jobs: ruby-version: ${{ matrix.ruby-version }} bundler-cache: true - name: $ bundle install を行う - uses: actions/cache@v1 + uses: actions/cache@v3 with: path: vendor/bundle key: ${{ runner.os }}-gem-${{ hashFiles('**/Gemfile.lock') }}