Bladeren bron

optimize ci.yml

Yuki Takei 6 jaren geleden
bovenliggende
commit
a19242bb68
2 gewijzigde bestanden met toevoegingen van 71 en 42 verwijderingen
  1. 70 42
      .github/workflows/ci.yml
  2. 1 0
      package.json

+ 70 - 42
.github/workflows/ci.yml

@@ -8,7 +8,7 @@ on:
 
 jobs:
 
-  resolve-dependencies:
+  test:
     runs-on: ubuntu-latest
 
     strategy:
@@ -26,26 +26,40 @@ jobs:
       uses: actions/cache@v1
       with:
         path: node_modules
-        key: ${{ runner.OS }}-node_modules-${{ matrix.node-version }}-${{ hashFiles('**/yarn.lock') }}
+        key: ${{ runner.OS }}-node_modules-dev-${{ matrix.node-version }}-${{ hashFiles('**/yarn.lock') }}
     - name: Install dependencies
       if: steps.cache.outputs.cache-hit != 'true'
       run: |
         yarn
-    - name: Install plugins
-      if: steps.cache.outputs.cache-hit != 'true'
-      run: |
-        yarn add growi-plugin-lsx growi-plugin-pukiwiki-like-linker growi-plugin-attachment-refs
-        yarn add -D react-images react-motion
     - name: Print dependencies
       run: |
         echo -n "node " && node -v
         echo -n "npm " && npm -v
         yarn list --depth=0
+    - name: yarn lint
+      run: |
+        yarn lint
+    - name: Launch MongoDB
+      uses: wbari/start-mongoDB@v0.2
+      with:
+        mongoDBVersion: 3.6
+    - name: yarn test
+      run: |
+        yarn test
+      env:
+        MONGO_URI: mongodb://localhost:27017/growi_test
 
+    - name: Slack Notification
+      uses: homoluctus/slatify@master
+      if: failure()
+      with:
+        type: ${{ job.status }}
+        job_name: '*test (${{ matrix.node-version }})*'
+        channel: '#ci'
+        url: ${{ secrets.SLACK_WEBHOOK_URL }}
 
-  test:
+  build-dev:
     runs-on: ubuntu-latest
-    needs: resolve-dependencies
 
     strategy:
       matrix:
@@ -58,35 +72,36 @@ jobs:
       with:
         node-version: ${{ matrix.node-version }}
     - name: Cache/Restore node_modules
+      id: cache
       uses: actions/cache@v1
       with:
         path: node_modules
-        key: ${{ runner.OS }}-node_modules-${{ matrix.node-version }}-${{ hashFiles('**/yarn.lock') }}
-    - name: yarn lint
+        key: ${{ runner.OS }}-node_modules-dev-${{ matrix.node-version }}-${{ hashFiles('**/yarn.lock') }}
+    - name: Install dependencies
+      if: steps.cache.outputs.cache-hit != 'true'
       run: |
-        yarn lint
-    - name: Launch MongoDB
-      uses: wbari/start-mongoDB@v0.2
-      with:
-        mongoDBVersion: 3.6
-    - name: yarn test
+        yarn
+    - name: Print dependencies
       run: |
-        yarn test
-      env:
-        MONGO_URI: mongodb://localhost:27017/growi_test
+        echo -n "node " && node -v
+        echo -n "npm " && npm -v
+        yarn list --depth=0
+    - name: yarn build:dev
+      run: |
+        yarn build:dev
 
     - name: Slack Notification
       uses: homoluctus/slatify@master
       if: failure()
       with:
         type: ${{ job.status }}
-        job_name: '*test (${{ matrix.node-version }})*'
+        job_name: '*build-dev (${{ matrix.node-version }})*'
         channel: '#ci'
         url: ${{ secrets.SLACK_WEBHOOK_URL }}
 
-  build-dev:
+
+  build-prod:
     runs-on: ubuntu-latest
-    needs: resolve-dependencies
 
     strategy:
       matrix:
@@ -99,27 +114,43 @@ jobs:
       with:
         node-version: ${{ matrix.node-version }}
     - name: Cache/Restore node_modules
+      id: cache
       uses: actions/cache@v1
       with:
         path: node_modules
-        key: ${{ runner.OS }}-node_modules-${{ matrix.node-version }}-${{ hashFiles('**/yarn.lock') }}
-    - name: yarn build:dev
+        key: ${{ runner.OS }}-node_modules-dev-with-plugins-${{ matrix.node-version }}-${{ hashFiles('**/yarn.lock') }}
+    - name: Install dependencies
+      if: steps.cache.outputs.cache-hit != 'true'
       run: |
-        yarn build:dev
+        yarn add growi-plugin-lsx growi-plugin-pukiwiki-like-linker growi-plugin-attachment-refs react-images react-motion
+    - name: Print dependencies
+      run: |
+        echo -n "node " && node -v
+        echo -n "npm " && npm -v
+        yarn list --depth=0
+    - name: yarn build:prod:analyze
+      run: |
+        yarn build:prod:analyze
+
+    - name: Upload reports
+      uses: actions/upload-artifact@v1
+      if: success()
+      with:
+        name: report
+        path: report
 
     - name: Slack Notification
       uses: homoluctus/slatify@master
       if: failure()
       with:
         type: ${{ job.status }}
-        job_name: '*build-dev (${{ matrix.node-version }})*'
+        job_name: '*build-prod (${{ matrix.node-version }})*'
         channel: '#ci'
         url: ${{ secrets.SLACK_WEBHOOK_URL }}
 
 
-  build-prod:
+  server-prod:
     runs-on: ubuntu-latest
-    needs: resolve-dependencies
 
     strategy:
       matrix:
@@ -132,32 +163,29 @@ jobs:
       with:
         node-version: ${{ matrix.node-version }}
     - name: Cache/Restore node_modules
+      id: cache
       uses: actions/cache@v1
       with:
         path: node_modules
-        key: ${{ runner.OS }}-node_modules-${{ matrix.node-version }}-${{ hashFiles('**/yarn.lock') }}
+        key: ${{ runner.OS }}-node_modules-prod-${{ matrix.node-version }}-${{ hashFiles('**/yarn.lock') }}
+    - name: Install dependencies
+      if: steps.cache.outputs.cache-hit != 'true'
+        yarn add growi-plugin-lsx growi-plugin-pukiwiki-like-linker growi-plugin-attachment-refs
+    - name: Print dependencies
+      run: |
+        echo -n "node " && node -v
+        echo -n "npm " && npm -v
+        yarn list --depth=0
     - name: Launch MongoDB
       uses: wbari/start-mongoDB@v0.2
       with:
         mongoDBVersion: 3.6
-    - name: yarn build:prod:analyze
-      run: |
-        yarn build:prod:analyze
-    - name: Shrink dependencies for production
-      run: |
-        yarn install --production
     - name: yarn server:prod:ci
       run: |
         yarn server:prod:ci
       env:
         MONGO_URI: mongodb://localhost:27017/growi
 
-    - name: Upload reports
-      uses: actions/upload-artifact@v1
-      if: success()
-      with:
-        name: report
-        path: report
     - name: Slack Notification
       uses: homoluctus/slatify@master
       if: failure()

+ 1 - 0
package.json

@@ -48,6 +48,7 @@
     "prebuild:dev:watch": "npm run prebuild:dev",
     "prebuild:dev": "npm run clean:app && env-cmd -f config/env.dev.js npm run plugin:def && env-cmd -f config/env.dev.js npm run resource",
     "prebuild:prod": "npm run clean && env-cmd -f config/env.prod.js npm run plugin:def && env-cmd -f config/env.prod.js npm run resource",
+    "preserver:prod:ci": "npm run clean && env-cmd -f config/env.prod.js npm run plugin:def",
     "prelint:swagger2openapi": "npm run build:apiv3:jsdoc",
     "preserver:prod": "npm run migrate",
     "prestart": "npm run build:prod",