about summary refs log tree commit diff
diff options
context:
space:
mode:
authorYamagishi Kazutoshi <ykzts@desire.sh>2018-04-23 16:16:26 +0900
committerEugen Rochko <eugen@zeonfederated.com>2018-04-23 09:16:26 +0200
commit3bf6da1ffcf8208a0608de7bff6e2155c40e2871 (patch)
tree80b0709e1398aabe9142aacdf1dc918676fb7093
parent0758b00bfddf4a2c845d0d611e50717a268fd48a (diff)
Move precompile step to build stage (#7235)
-rw-r--r--.circleci/config.yml55
1 files changed, 40 insertions, 15 deletions
diff --git a/.circleci/config.yml b/.circleci/config.yml
index c5d6ec9d1..fbaf60aad 100644
--- a/.circleci/config.yml
+++ b/.circleci/config.yml
@@ -23,6 +23,13 @@ aliases:
       paths:
         - ./mastodon/
 
+  - &restore_ruby_dependencies
+    restore_cache:
+      keys:
+        - v2-ruby-dependencies-{{ checksum "/tmp/.ruby-version" }}-{{ checksum "Gemfile.lock" }}
+        - v2-ruby-dependencies-{{ checksum "/tmp/.ruby-version" }}-
+        - v2-ruby-dependencies--
+
   - &install_steps
     steps:
       - checkout
@@ -54,26 +61,14 @@ aliases:
         - *install_system_dependencies
 
         - run: ruby -e 'puts RUBY_VERSION' | tee /tmp/.ruby-version
-        - restore_cache:
-            keys:
-              - v1-ruby-dependencies-{{ checksum "/tmp/.ruby-version" }}-{{ checksum "Gemfile.lock" }}
-              - v1-ruby-dependencies-{{ checksum "/tmp/.ruby-version" }}-
-              - v1-ruby-dependencies--
+        - *restore_ruby_dependencies
         - run: bundle install --clean --jobs 16 --path ./vendor/bundle/ --retry 3 --with pam_authentication --without development production
         - save_cache:
-            key: v1-ruby-dependencies-{{ checksum "/tmp/.ruby-version" }}-{{ checksum "Gemfile.lock" }}
+            key: v2-ruby-dependencies-{{ checksum "/tmp/.ruby-version" }}-{{ checksum "Gemfile.lock" }}
             paths:
+              - ./.bundle/
               - ./vendor/bundle/
 
-        - run:
-            name: Precompile Assets
-            command: |
-              if [ ! -d ./public/assets/ -o ! -d ./public/packs-test/ ]; then
-                ./bin/rails assets:precompile
-              fi
-
-        - *persist_to_workspace
-
   - &test_steps
       steps:
         - *attach_workspace
@@ -81,6 +76,15 @@ aliases:
         - *install_system_dependencies
         - run: sudo apt-get install -y ffmpeg
 
+        - run: ruby -e 'puts RUBY_VERSION' | tee /tmp/.ruby-version
+        - *restore_ruby_dependencies
+
+        - restore_cache:
+            keys:
+              - precompiled-assets-{{ .Branch }}-{{ .Revision }}
+              - precompiled-assets-{{ .Branch }}-
+              - precompiled-assets--
+
         - run:
             name: Prepare Tests
             command: ./bin/rails parallel:create parallel:load_schema parallel:prepare
@@ -104,6 +108,20 @@ jobs:
         environment: *ruby_environment
     <<: *install_ruby_dependencies
 
+  build:
+    <<: *defaults
+    steps:
+      - *attach_workspace
+      - *install_system_dependencies
+      - run: ruby -e 'puts RUBY_VERSION' | tee /tmp/.ruby-version
+      - *restore_ruby_dependencies
+      - run: ./bin/rails assets:precompile
+      - save_cache:
+          key: precompiled-assets-{{ .Branch }}-{{ .Revision }}
+          paths:
+            - ./public/assets
+            - ./public/packs-test/
+
   test-ruby2.5:
     <<: *defaults
     docker:
@@ -138,6 +156,8 @@ jobs:
     <<: *defaults
     steps:
       - *attach_workspace
+      - run: ruby -e 'puts RUBY_VERSION' | tee /tmp/.ruby-version
+      - *restore_ruby_dependencies
       - run: bundle exec i18n-tasks check-normalized
       - run: bundle exec i18n-tasks unused
 
@@ -151,13 +171,18 @@ workflows:
             - install
       - install-ruby2.4:
           requires:
+            - install
+      - build:
+          requires:
             - install-ruby2.5
       - test-ruby2.5:
           requires:
             - install-ruby2.5
+            - build
       - test-ruby2.4:
           requires:
             - install-ruby2.4
+            - build
       - test-webui:
           requires:
             - install