From 11804d9555f10930a7fdf43b4ab25b920d829941 Mon Sep 17 00:00:00 2001 From: utyosu Date: Sat, 25 Jan 2020 11:08:33 +0900 Subject: [PATCH 01/10] a --- .github/workflows/test.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index ad625be..1ecf0bf 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -1,6 +1,6 @@ name: CI -on: [push] +on: [pull_request] jobs: build: @@ -12,5 +12,4 @@ jobs: steps: - run: | BRANCH_NAME=`echo "${GITHUB_REF}" | sed "s/^\(refs\/heads\/\|refs\/remotes\/\)//"` - echo ${BRANCH_NAME} /app/run.sh https://github.com/${GITHUB_REPOSITORY}.git ${BRANCH_NAME} tools/cloud_build/test.sh From 1cd9bb54b404e504e55c4a5b08eb446e2d228a58 Mon Sep 17 00:00:00 2001 From: utyosu Date: Sat, 25 Jan 2020 11:20:54 +0900 Subject: [PATCH 02/10] a --- .github/workflows/test.yml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 1ecf0bf..4205a67 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -11,5 +11,8 @@ jobs: steps: - run: | - BRANCH_NAME=`echo "${GITHUB_REF}" | sed "s/^\(refs\/heads\/\|refs\/remotes\/\)//"` - /app/run.sh https://github.com/${GITHUB_REPOSITORY}.git ${BRANCH_NAME} tools/cloud_build/test.sh + BRANCH=`curl -X GET -H "Authorization: token ${GITHUB_TOKEN}" ${API_ENDPOINT} | jq -r '.head.ref'` + echo $BRANCH + # - run: | + # BRANCH_NAME=`echo "${GITHUB_REF}" | sed "s/^\(refs\/heads\/\|refs\/remotes\/\)//"` + # /app/run.sh https://github.com/${GITHUB_REPOSITORY}.git ${BRANCH_NAME} tools/cloud_build/test.sh From 2e1ac4e6d5c30837f4b50d5960b67ebfd9fb2eaa Mon Sep 17 00:00:00 2001 From: utyosu Date: Sat, 25 Jan 2020 11:22:17 +0900 Subject: [PATCH 03/10] a --- .github/workflows/test.yml | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 4205a67..6586f66 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -6,11 +6,14 @@ jobs: build: runs-on: ubuntu-latest - container: - image: utyosu/build-rails:latest + # container: + # image: utyosu/build-rails:latest steps: - - run: | + - env: + API_ENDPOINT: ${{ github.event.issue.pull_request.url }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | BRANCH=`curl -X GET -H "Authorization: token ${GITHUB_TOKEN}" ${API_ENDPOINT} | jq -r '.head.ref'` echo $BRANCH # - run: | From b97f01b1d2c3a1e3c041b5e03eb0316f44e6bcba Mon Sep 17 00:00:00 2001 From: utyosu Date: Sat, 25 Jan 2020 11:24:30 +0900 Subject: [PATCH 04/10] a --- .github/workflows/test.yml | 18 +++++++----------- tools/cloud_build/run.sh | 8 -------- 2 files changed, 7 insertions(+), 19 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 6586f66..f079eb3 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -6,16 +6,12 @@ jobs: build: runs-on: ubuntu-latest - # container: - # image: utyosu/build-rails:latest + container: + image: utyosu/build-rails:latest steps: - - env: - API_ENDPOINT: ${{ github.event.issue.pull_request.url }} - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: | - BRANCH=`curl -X GET -H "Authorization: token ${GITHUB_TOKEN}" ${API_ENDPOINT} | jq -r '.head.ref'` - echo $BRANCH - # - run: | - # BRANCH_NAME=`echo "${GITHUB_REF}" | sed "s/^\(refs\/heads\/\|refs\/remotes\/\)//"` - # /app/run.sh https://github.com/${GITHUB_REPOSITORY}.git ${BRANCH_NAME} tools/cloud_build/test.sh + - uses: actions/checkout@master + - run: | + export PATH="/root/.rbenv/bin:/root/.rbenv/shims:$PATH" + find /var/lib/mysql -type f -exec touch {} \; + /app/run.sh https://github.com/${GITHUB_REPOSITORY}.git tools/cloud_build/test.sh diff --git a/tools/cloud_build/run.sh b/tools/cloud_build/run.sh index 916b654..5fc943c 100644 --- a/tools/cloud_build/run.sh +++ b/tools/cloud_build/run.sh @@ -6,12 +6,4 @@ export PATH="/root/.rbenv/bin:/root/.rbenv/shims:$PATH" # Dockerfileがマルチレイヤのとき、MySQLを起動する前に以下コマンドの実行が必要 find /var/lib/mysql -type f -exec touch {} \; -REPOSITORY=${1} -BRANCH=${2} -SCRIPT_PATH=${3} - -mkdir repository -git clone -b ${BRANCH} ${REPOSITORY} repository -cd repository - . ${SCRIPT_PATH} From 22b6034bf8f811cdf1d4fa0482c90972efbe0daf Mon Sep 17 00:00:00 2001 From: utyosu Date: Sat, 25 Jan 2020 11:26:09 +0900 Subject: [PATCH 05/10] a --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index f079eb3..a773914 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -14,4 +14,4 @@ jobs: - run: | export PATH="/root/.rbenv/bin:/root/.rbenv/shims:$PATH" find /var/lib/mysql -type f -exec touch {} \; - /app/run.sh https://github.com/${GITHUB_REPOSITORY}.git tools/cloud_build/test.sh + tools/cloud_build/test.sh From 01741de4f0b86db84f253701384e947c7c726a1f Mon Sep 17 00:00:00 2001 From: utyosu Date: Sat, 25 Jan 2020 11:27:19 +0900 Subject: [PATCH 06/10] a --- .github/workflows/test.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index a773914..2d59530 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -11,7 +11,8 @@ jobs: steps: - uses: actions/checkout@master - - run: | + - name: run test + run: | export PATH="/root/.rbenv/bin:/root/.rbenv/shims:$PATH" find /var/lib/mysql -type f -exec touch {} \; - tools/cloud_build/test.sh + . tools/cloud_build/test.sh From bf92fa19563571627b88bb60829cec2b9ba68c9e Mon Sep 17 00:00:00 2001 From: utyosu Date: Sat, 25 Jan 2020 11:28:59 +0900 Subject: [PATCH 07/10] a --- spec/lib/discord/extractor_spec.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/spec/lib/discord/extractor_spec.rb b/spec/lib/discord/extractor_spec.rb index d77b9c9..289254e 100644 --- a/spec/lib/discord/extractor_spec.rb +++ b/spec/lib/discord/extractor_spec.rb @@ -2,9 +2,9 @@ require './spec/spec_helper' describe Extractor do - around do |e| - travel_to('2018-3-10 8:00'.in_time_zone) {e.run} - end + # around do |e| + # travel_to('2018-3-10 8:00'.in_time_zone) {e.run} + # end describe '.extraction_time' do subject { Extractor.extraction_time(target) } From 21f563f8842aa7dbd87f01e217da4d5219665a36 Mon Sep 17 00:00:00 2001 From: utyosu Date: Sat, 25 Jan 2020 11:38:26 +0900 Subject: [PATCH 08/10] a --- .github/workflows/test.yml | 5 +- spec/lib/discord/extractor_spec.rb | 6 +-- tools/cloud_build/Dockerfile | 75 ++++++++++++++++-------------- 3 files changed, 46 insertions(+), 40 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 2d59530..5a0d5a4 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -7,12 +7,11 @@ jobs: runs-on: ubuntu-latest container: - image: utyosu/build-rails:latest + image: utyosu/build-rails-test:latest steps: - uses: actions/checkout@master - name: run test run: | - export PATH="/root/.rbenv/bin:/root/.rbenv/shims:$PATH" - find /var/lib/mysql -type f -exec touch {} \; + echo $PATH . tools/cloud_build/test.sh diff --git a/spec/lib/discord/extractor_spec.rb b/spec/lib/discord/extractor_spec.rb index 289254e..d77b9c9 100644 --- a/spec/lib/discord/extractor_spec.rb +++ b/spec/lib/discord/extractor_spec.rb @@ -2,9 +2,9 @@ require './spec/spec_helper' describe Extractor do - # around do |e| - # travel_to('2018-3-10 8:00'.in_time_zone) {e.run} - # end + around do |e| + travel_to('2018-3-10 8:00'.in_time_zone) {e.run} + end describe '.extraction_time' do subject { Extractor.extraction_time(target) } diff --git a/tools/cloud_build/Dockerfile b/tools/cloud_build/Dockerfile index 8391984..a878aa0 100644 --- a/tools/cloud_build/Dockerfile +++ b/tools/cloud_build/Dockerfile @@ -1,43 +1,50 @@ # ビルド方法 (プロジェクトルートで実行) # $ docker build -t build-rails . -f tools/cloud_build/Dockerfile -FROM ubuntu:16.04 +# FROM ubuntu:16.04 -SHELL ["/bin/bash", "-c"] +# SHELL ["/bin/bash", "-c"] -ENV DEBIAN_FRONTEND="noninteractive" -ENV RUBY_VERSION="2.5.1" -ENV BUNDLER_VERSION="2.1.4" +# ENV DEBIAN_FRONTEND="noninteractive" +# ENV RUBY_VERSION="2.5.1" +# ENV BUNDLER_VERSION="2.1.4" -WORKDIR /app +# WORKDIR /app -ADD Gemfile . -ADD Gemfile.lock . +# ADD Gemfile . +# ADD Gemfile.lock . + +# RUN set -x \ +# && apt update \ +# && apt install -y \ +# curl \ +# libssl-dev \ +# libreadline-dev \ +# zlib1g-dev \ +# build-essential \ +# git \ +# mysql-client \ +# libmysqlclient-dev \ +# tzdata \ +# mysql-server \ +# # Install rbenv and ruby +# && git clone https://github.com/sstephenson/rbenv.git ~/.rbenv \ +# && git clone https://github.com/sstephenson/ruby-build.git ~/.rbenv/plugins/ruby-build \ +# && CONFIGURE_OPTS='--disable-install-rdoc' /root/.rbenv/bin/rbenv install ${RUBY_VERSION} -s \ +# && /root/.rbenv/bin/rbenv global ${RUBY_VERSION} \ +# # Install bundler +# && echo 'gem: --no-rdoc --no-ri' > /root/.gemrc \ +# && /root/.rbenv/shims/gem install bundler -v ${BUNDLER_VERSION} \ +# # bundle install +# && /root/.rbenv/shims/bundle config set without development \ +# && /root/.rbenv/shims/bundle install \ +# && rm Gemfile Gemfile.lock + +# COPY /tools/cloud_build/run.sh . + +FROM build-rails RUN set -x \ - && apt update \ - && apt install -y \ - curl \ - libssl-dev \ - libreadline-dev \ - zlib1g-dev \ - build-essential \ - git \ - mysql-client \ - libmysqlclient-dev \ - tzdata \ - mysql-server \ - # Install rbenv and ruby - && git clone https://github.com/sstephenson/rbenv.git ~/.rbenv \ - && git clone https://github.com/sstephenson/ruby-build.git ~/.rbenv/plugins/ruby-build \ - && CONFIGURE_OPTS='--disable-install-rdoc' /root/.rbenv/bin/rbenv install ${RUBY_VERSION} -s \ - && /root/.rbenv/bin/rbenv global ${RUBY_VERSION} \ - # Install bundler - && echo 'gem: --no-rdoc --no-ri' > /root/.gemrc \ - && /root/.rbenv/shims/gem install bundler -v ${BUNDLER_VERSION} \ - # bundle install - && /root/.rbenv/shims/bundle config set without development \ - && /root/.rbenv/shims/bundle install \ - && rm Gemfile Gemfile.lock - -COPY /tools/cloud_build/run.sh . + && echo '' > /root/.bashrc \ + && echo 'export PATH="/root/.rbenv/bin:/root/.rbenv/shims:$PATH"' >> /root/.bashrc \ + && echo 'find /var/lib/mysql -type f -exec touch {} \;' >> /root/.bashrc From 9a4503e86ed737e37b04f2fea698c56f12978243 Mon Sep 17 00:00:00 2001 From: utyosu Date: Sat, 25 Jan 2020 11:48:16 +0900 Subject: [PATCH 09/10] a --- tools/cloud_build/Dockerfile | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/tools/cloud_build/Dockerfile b/tools/cloud_build/Dockerfile index a878aa0..0a71a67 100644 --- a/tools/cloud_build/Dockerfile +++ b/tools/cloud_build/Dockerfile @@ -44,7 +44,9 @@ FROM build-rails -RUN set -x \ - && echo '' > /root/.bashrc \ - && echo 'export PATH="/root/.rbenv/bin:/root/.rbenv/shims:$PATH"' >> /root/.bashrc \ - && echo 'find /var/lib/mysql -type f -exec touch {} \;' >> /root/.bashrc +ENV PATH /root/.rbenv/bin:/root/.rbenv/shims:$PATH + +# RUN set -x \ +# && echo '' > /root/.bashrc \ +# && echo 'export PATH="/root/.rbenv/bin:/root/.rbenv/shims:$PATH"' >> /root/.bashrc \ +# && echo 'find /var/lib/mysql -type f -exec touch {} \;' >> /root/.bashrc From eafe4d13c9305afe6d88075e1f2dc348f2e7e7ed Mon Sep 17 00:00:00 2001 From: utyosu Date: Sat, 25 Jan 2020 12:16:53 +0900 Subject: [PATCH 10/10] a --- .github/workflows/test.yml | 6 +-- tools/cloud_build/Dockerfile | 88 ++++++++++++++++-------------------- tools/cloud_build/run.sh | 9 ---- 3 files changed, 41 insertions(+), 62 deletions(-) delete mode 100644 tools/cloud_build/run.sh diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 5a0d5a4..f5fc008 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -7,11 +7,9 @@ jobs: runs-on: ubuntu-latest container: - image: utyosu/build-rails-test:latest + image: utyosu/build-rails:latest steps: - uses: actions/checkout@master - name: run test - run: | - echo $PATH - . tools/cloud_build/test.sh + run: . tools/cloud_build/test.sh diff --git a/tools/cloud_build/Dockerfile b/tools/cloud_build/Dockerfile index 0a71a67..f5c6b4b 100644 --- a/tools/cloud_build/Dockerfile +++ b/tools/cloud_build/Dockerfile @@ -1,52 +1,42 @@ # ビルド方法 (プロジェクトルートで実行) # $ docker build -t build-rails . -f tools/cloud_build/Dockerfile -# FROM ubuntu:16.04 - -# SHELL ["/bin/bash", "-c"] - -# ENV DEBIAN_FRONTEND="noninteractive" -# ENV RUBY_VERSION="2.5.1" -# ENV BUNDLER_VERSION="2.1.4" - -# WORKDIR /app - -# ADD Gemfile . -# ADD Gemfile.lock . - -# RUN set -x \ -# && apt update \ -# && apt install -y \ -# curl \ -# libssl-dev \ -# libreadline-dev \ -# zlib1g-dev \ -# build-essential \ -# git \ -# mysql-client \ -# libmysqlclient-dev \ -# tzdata \ -# mysql-server \ -# # Install rbenv and ruby -# && git clone https://github.com/sstephenson/rbenv.git ~/.rbenv \ -# && git clone https://github.com/sstephenson/ruby-build.git ~/.rbenv/plugins/ruby-build \ -# && CONFIGURE_OPTS='--disable-install-rdoc' /root/.rbenv/bin/rbenv install ${RUBY_VERSION} -s \ -# && /root/.rbenv/bin/rbenv global ${RUBY_VERSION} \ -# # Install bundler -# && echo 'gem: --no-rdoc --no-ri' > /root/.gemrc \ -# && /root/.rbenv/shims/gem install bundler -v ${BUNDLER_VERSION} \ -# # bundle install -# && /root/.rbenv/shims/bundle config set without development \ -# && /root/.rbenv/shims/bundle install \ -# && rm Gemfile Gemfile.lock - -# COPY /tools/cloud_build/run.sh . - -FROM build-rails - -ENV PATH /root/.rbenv/bin:/root/.rbenv/shims:$PATH - -# RUN set -x \ -# && echo '' > /root/.bashrc \ -# && echo 'export PATH="/root/.rbenv/bin:/root/.rbenv/shims:$PATH"' >> /root/.bashrc \ -# && echo 'find /var/lib/mysql -type f -exec touch {} \;' >> /root/.bashrc +FROM ubuntu:16.04 + +SHELL ["/bin/bash", "-c"] + +ENV RUBY_VERSION="2.5.1" +ENV BUNDLER_VERSION="2.1.4" +ENV DEBIAN_FRONTEND="noninteractive" +ENV PATH=/root/.rbenv/bin:/root/.rbenv/shims:$PATH + +WORKDIR /app + +ADD Gemfile . +ADD Gemfile.lock . + +RUN set -x \ + && apt update \ + && apt install -y \ + curl \ + libssl-dev \ + libreadline-dev \ + zlib1g-dev \ + build-essential \ + git \ + mysql-client \ + libmysqlclient-dev \ + tzdata \ + mysql-server \ + # Install rbenv and ruby + && git clone https://github.com/sstephenson/rbenv.git ~/.rbenv \ + && git clone https://github.com/sstephenson/ruby-build.git ~/.rbenv/plugins/ruby-build \ + && CONFIGURE_OPTS='--disable-install-rdoc' /root/.rbenv/bin/rbenv install ${RUBY_VERSION} -s \ + && /root/.rbenv/bin/rbenv global ${RUBY_VERSION} \ + # Install bundler + && echo 'gem: --no-rdoc --no-ri' > /root/.gemrc \ + && /root/.rbenv/shims/gem install bundler -v ${BUNDLER_VERSION} \ + # bundle install + && /root/.rbenv/shims/bundle config set without development \ + && /root/.rbenv/shims/bundle install \ + && rm Gemfile Gemfile.lock diff --git a/tools/cloud_build/run.sh b/tools/cloud_build/run.sh deleted file mode 100644 index 5fc943c..0000000 --- a/tools/cloud_build/run.sh +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/bash - -# Rubyにパスを通す -export PATH="/root/.rbenv/bin:/root/.rbenv/shims:$PATH" - -# Dockerfileがマルチレイヤのとき、MySQLを起動する前に以下コマンドの実行が必要 -find /var/lib/mysql -type f -exec touch {} \; - -. ${SCRIPT_PATH}