-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #67 from true-runes/development
v0.7.0
Showing
13 changed files
with
220 additions
and
75 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
73 changes: 73 additions & 0 deletions
73
.github/workflows/gss2022_backend_on_built_in_postgres.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
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/$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: コードをチェックアウトする | ||
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@v3 | ||
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" を用いる' | ||
echo 'uses: actions/setup-node@v3' | ||
echo 'with:' | ||
echo 'node-version: ${{ matrix.node-version }}' | ||
echo 'cache: "yarn"' | ||
- name: データベースをセットアップする | ||
run: | | ||
bin/rails db:prepare | ||
- name: RSpec を実行する | ||
run: | | ||
bundle exec rspec |
62 changes: 62 additions & 0 deletions
62
.github/workflows/gss2022_backend_on_postgres_services.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
name: 幻水総選挙2022 バックエンド | ||
|
||
on: | ||
push: | ||
workflow_dispatch: | ||
|
||
jobs: | ||
gss2022_backend: | ||
name: (pg on services) 継続的インテグレーション | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
node-version: ["18.x"] | ||
ruby-version: ["3.1"] | ||
services: | ||
postgres: | ||
image: postgres:14.3 | ||
ports: | ||
- 5432:5432 | ||
env: | ||
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: localhost | ||
POSTGRES_PORT_TEST: 5432 | ||
POSTGRES_USERNAME_TEST: postgres_user | ||
POSTGRES_PASSWORD_TEST: postgres_password | ||
steps: | ||
- 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@v3 | ||
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" を用いる' | ||
echo 'uses: actions/setup-node@v3' | ||
echo 'with:' | ||
echo 'node-version: ${{ matrix.node-version }}' | ||
echo 'cache: "yarn"' | ||
- name: データベースをセットアップする | ||
run: | | ||
bin/rails db:prepare | ||
- name: RSpec を実行する | ||
run: | | ||
bundle exec rspec |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
--require spec_helper --format documentation | ||
--require spec_helper --format documentation --force-color --backtrace |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,8 @@ | ||
On PostgreSQL Services | ||
[](https://github.com/true-runes/suikoden-election-2022-backend/actions/workflows/gss2022_backend_on_postgres_services.yml) | ||
|
||
On Built-In PostgreSQL | ||
[](https://github.com/true-runes/suikoden-election-2022-backend/actions/workflows/gss2022_backend_on_built_in_postgres.yml) | ||
|
||
# 幻水総選挙2022(バックエンド) | ||
- いつもの |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"extends": [ | ||
"config:base" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters