Yuki Takei 4 лет назад
Родитель
Сommit
2b6e911d43
1 измененных файлов с 93 добавлено и 54 удалено
  1. 93 54
      .github/workflows/ci.yml

+ 93 - 54
.github/workflows/ci.yml

@@ -13,12 +13,16 @@ jobs:
   lint:
     runs-on: ubuntu-latest
 
+    strategy:
+      matrix:
+        node-version: [14.x]
+
     steps:
     - uses: actions/checkout@v2
 
     - uses: actions/setup-node@v2
       with:
-        node-version: 14.x
+        node-version: ${{ matrix.node-version }}
         cache: 'yarn'
         cache-dependency-path: '**/yarn.lock'
 
@@ -28,9 +32,9 @@ jobs:
       with:
         path: |
           **/node_modules
-        key: ${{ runner.OS }}-node_modules-14.x-${{ hashFiles('**/yarn.lock') }}
+        key: node_modules-${{ runner.OS }}-node${{ matrix.node-version }}-${{ hashFiles('**/yarn.lock') }}
         restore-keys: |
-          ${{ runner.os }}-node_modules-14.x-
+          node_modules-${{ runner.OS }}-node${{ matrix.node-version }}-
 
     - name: lerna bootstrap
       run: |
@@ -48,7 +52,7 @@ jobs:
       if: failure()
       with:
         type: ${{ job.status }}
-        job_name: '*Node CI for growi - lint (14.x)*'
+        job_name: '*Node CI for growi - lint (${{ matrix.node-version }})*'
         channel: '#ci'
         isCompactMode: true
         url: ${{ secrets.SLACK_WEBHOOK_URL }}
@@ -57,6 +61,10 @@ jobs:
   test:
     runs-on: ubuntu-latest
 
+    strategy:
+      matrix:
+        node-version: [14.x]
+
     services:
       mongodb:
         image: mongo:4.4
@@ -72,7 +80,7 @@ jobs:
 
     - uses: actions/setup-node@v2
       with:
-        node-version: 14.x
+        node-version: ${{ matrix.node-version }}
         cache: 'yarn'
         cache-dependency-path: '**/yarn.lock'
 
@@ -82,9 +90,9 @@ jobs:
       with:
         path: |
           **/node_modules
-        key: ${{ runner.OS }}-node_modules-14.x-${{ hashFiles('**/yarn.lock') }}
+        key: node_modules-${{ runner.OS }}-node${{ matrix.node-version }}-${{ hashFiles('**/yarn.lock') }}
         restore-keys: |
-          ${{ runner.os }}-node_modules-14.x-
+          node_modules-${{ runner.OS }}-node${{ matrix.node-version }}-
 
     - name: lerna bootstrap
       run: |
@@ -114,7 +122,7 @@ jobs:
       if: failure()
       with:
         type: ${{ job.status }}
-        job_name: '*Node CI for growi - test (14.x)*'
+        job_name: '*Node CI for growi - test (${{ matrix.node-version }})*'
         channel: '#ci'
         isCompactMode: true
         url: ${{ secrets.SLACK_WEBHOOK_URL }}
@@ -123,6 +131,10 @@ jobs:
   launch-dev:
     runs-on: ubuntu-latest
 
+    strategy:
+      matrix:
+        node-version: [14.x]
+
     services:
       mongodb:
         image: mongo:4.4
@@ -134,7 +146,7 @@ jobs:
 
     - uses: actions/setup-node@v2
       with:
-        node-version: 14.x
+        node-version: ${{ matrix.node-version }}
         cache: 'yarn'
         cache-dependency-path: '**/yarn.lock'
 
@@ -144,9 +156,9 @@ jobs:
       with:
         path: |
           **/node_modules
-        key: ${{ runner.OS }}-node_modules-14.x-${{ hashFiles('**/yarn.lock') }}
+        key: node_modules-${{ runner.OS }}-node${{ matrix.node-version }}-${{ hashFiles('**/yarn.lock') }}
         restore-keys: |
-          ${{ runner.os }}-node_modules-14.x-
+          node_modules-${{ runner.OS }}-node${{ matrix.node-version }}-
 
     - name: lerna bootstrap
       run: |
@@ -165,20 +177,24 @@ jobs:
       if: failure()
       with:
         type: ${{ job.status }}
-        job_name: '*Node CI for growi - launch-dev (14.x)*'
+        job_name: '*Node CI for growi - launch-dev (${{ matrix.node-version }})*'
         channel: '#ci'
         isCompactMode: true
         url: ${{ secrets.SLACK_WEBHOOK_URL }}
 
-  install-prod:
+  install-prod-node14:
     runs-on: ubuntu-latest
 
+    strategy:
+      matrix:
+        node-version: [14.x]
+
     steps:
     - uses: actions/checkout@v2
 
     - uses: actions/setup-node@v2
       with:
-        node-version: 14.x
+        node-version: ${{ matrix.node-version }}
         cache: 'yarn'
         cache-dependency-path: '**/yarn.lock'
 
@@ -188,10 +204,10 @@ jobs:
       with:
         path: |
           **/node_modules
-        key: ${{ runner.OS }}-node_modules-14.x-launch-prod-${{ hashFiles('**/yarn.lock') }}
+        key: node_modules-prod-${{ runner.OS }}-node${{ matrix.node-version }}-${{ hashFiles('**/yarn.lock') }}
         restore-keys: |
-          ${{ runner.os }}-node_modules-14.x-launch-prod-
-          ${{ runner.os }}-node_modules-14.x-
+          node_modules-prod-${{ runner.OS }}-node${{ matrix.node-version }}-
+          node_modules-${{ runner.OS }}-node${{ matrix.node-version }}-
 
     - name: Remove unnecessary packages
       run: |
@@ -211,33 +227,40 @@ jobs:
       if: failure()
       with:
         type: ${{ job.status }}
-        job_name: '*Node CI for growi - install-prod-node14*'
+        job_name: '*Node CI for growi - install-prod (${{ matrix.node-version }})*'
         channel: '#ci'
         isCompactMode: true
         url: ${{ secrets.SLACK_WEBHOOK_URL }}
 
-  build-prod:
+  launch-prod-node14:
     runs-on: ubuntu-latest
 
+    strategy:
+      matrix:
+        node-version: [14.x]
+
+    outputs:
+      BUILT_PACKAGES: ${{ steps.archive-built-packages.outputs.file }}
+
     steps:
     - uses: actions/checkout@v2
 
     - uses: actions/setup-node@v2
       with:
-        node-version: 14.x
+        node-version: ${{ matrix.node-version }}
         cache: 'yarn'
         cache-dependency-path: '**/yarn.lock'
 
-    - name: Cache/Restore node_modules
+    - name: Cache/Restore node_modules for build
       id: cache-dependencies
       uses: actions/cache@v2
       with:
         path: |
           **/node_modules
-        key: ${{ runner.OS }}-node_modules-14.x-build-prod-${{ hashFiles('**/yarn.lock') }}
+        key: node_modules-build-prod-${{ runner.OS }}-node${{ matrix.node-version }}-${{ hashFiles('**/yarn.lock') }}
         restore-keys: |
-          ${{ runner.os }}-node_modules-14.x-build-prod-
-          ${{ runner.os }}-node_modules-14.x-
+          node_modules-build-prod-${{ runner.OS }}-node${{ matrix.node-version }}-
+          node_modules-${{ runner.OS }}-node${{ matrix.node-version }}-
 
     - name: Remove unnecessary packages
       run: |
@@ -245,19 +268,43 @@ jobs:
     - name: lerna bootstrap
       run: |
         npx lerna bootstrap
+
     - name: Build
       run: |
         yarn lerna run build
       env:
         ANALYZE_BUNDLE_SIZE: 1
 
-    - name: Upload built artifact
+    - name: lerna bootstrap --production
+      run: |
+        yarn lerna bootstrap -- --production
+
+    - name: yarn server:ci
+      working-directory: ./packages/app
+      run: |
+        cp config/ci/.env.local.for-ci .env.production.local
+        yarn server:ci
+      env:
+        MONGO_URI: mongodb://localhost:${{ job.services.mongodb.ports['27017'] }}/growi
+    - name: yarn server:ci with MongoDB 3.6
+      working-directory: ./packages/app
+      run: |
+        cp config/ci/.env.local.for-ci .env.production.local
+        yarn server:ci
+      env:
+        MONGO_URI: mongodb://localhost:${{ job.services.mongodb36.ports['27017'] }}/growi
+
+    - name: Archive built package files
+      id: archive-built-packages
+      run: |
+        tar -cf built-packages.tar packages/**/dist packages/app/public
+        echo ::set-output name=file::built-packages.tar
+
+    - name: Upload built packages as artifact
       uses: actions/upload-artifact@v2
       with:
         name: Built Packages
-        path: |
-          packages/**/dist
-          packages/app/public
+        path: ${{ steps.archive-built-artifact.outputs.file }}
 
     - name: Upload report as artifact
       uses: actions/upload-artifact@v2
@@ -270,45 +317,41 @@ jobs:
       if: failure()
       with:
         type: ${{ job.status }}
-        job_name: '*Node CI for growi - build-prod (14.x)*'
+        job_name: '*Node CI for growi - build-prod (${{ matrix.node-version }})*'
         channel: '#ci'
         isCompactMode: true
         url: ${{ secrets.SLACK_WEBHOOK_URL }}
 
-  launch-prod:
-    needs: [install-prod, build-prod]
+  run-cypress-node14:
+    needs: [install-prod, launch-prod]
 
     runs-on: ubuntu-latest
+    container: cypress/base:14.18.1
+
+    strategy:
+      fail-fast: false
+      matrix:
+        node-version: [14.x]
+        containers: [1, 2]
 
     services:
       mongodb:
         image: mongo:4.4
         ports:
         - 27017/tcp
-      mongodb36:
-        image: mongo:3.6
-        ports:
-        - 27017/tcp
 
     steps:
     - uses: actions/checkout@v2
 
-    - uses: actions/setup-node@v2
-      with:
-        node-version: 14.x
-        cache: 'yarn'
-        cache-dependency-path: '**/yarn.lock'
-
     - name: Cache/Restore node_modules
       id: cache-dependencies
       uses: actions/cache@v2
       with:
         path: |
           **/node_modules
-        key: ${{ runner.OS }}-node_modules-14.x-launch-prod-${{ hashFiles('**/yarn.lock') }}
+        key: node_modules-prod-${{ runner.OS }}-node${{ matrix.node-version }}-${{ hashFiles('**/yarn.lock') }}
         restore-keys: |
-          ${{ runner.os }}-node_modules-14.x-launch-prod-
-          ${{ runner.os }}-node_modules-14.x-
+          node_modules-prod-${{ runner.OS }}-node${{ matrix.node-version }}-
 
     - name: Remove unnecessary packages
       run: |
@@ -318,29 +361,25 @@ jobs:
       uses: actions/download-artifact@v2
       with:
         name: Built Packages
-        path: packages
 
-    - name: yarn server:ci
-      working-directory: ./packages/app
+    - name: Extract built artifact
       run: |
-        cp config/ci/.env.local.for-ci .env.production.local
-        yarn server:ci
-      env:
-        MONGO_URI: mongodb://localhost:${{ job.services.mongodb.ports['27017'] }}/growi
-    - name: yarn server:ci with MongoDB 3.6
+        tar xf ${{ needs.launch-prod.outputs.BUILT_PACKAGES }}
+
+    - name: yarn server:ci
       working-directory: ./packages/app
       run: |
         cp config/ci/.env.local.for-ci .env.production.local
         yarn server:ci
       env:
-        MONGO_URI: mongodb://localhost:${{ job.services.mongodb36.ports['27017'] }}/growi
+        MONGO_URI: mongodb://localhost:${{ job.services.mongodb.ports['27017'] }}/growi-vrt
 
     - name: Slack Notification
       uses: weseek/ghaction-slack-notification@master
       if: failure()
       with:
         type: ${{ job.status }}
-        job_name: '*Node CI for growi - build-prod (14.x)*'
+        job_name: '*Node CI for growi - run-cypress (${{ matrix.node-version }})*'
         channel: '#ci'
         isCompactMode: true
         url: ${{ secrets.SLACK_WEBHOOK_URL }}