Skip to content

Commit

Permalink
Merge pull request #7417 from weseek/support/use-turborepo
Browse files Browse the repository at this point in the history
support: Migrate to Turborepo
  • Loading branch information
yuki-takei committed Apr 14, 2023
2 parents 45b6206 + ac7096b commit 0fbfb5e
Show file tree
Hide file tree
Showing 1,550 changed files with 3,597 additions and 9,521 deletions.
9 changes: 4 additions & 5 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# Licensed under the MIT License. See https://go.microsoft.com/fwlink/?linkid=2090316 for license information.
#-------------------------------------------------------------------------------------------------------------

FROM mcr.microsoft.com/vscode/devcontainers/javascript-node:0-16
FROM mcr.microsoft.com/vscode/devcontainers/javascript-node:0-18

# The node image includes a non-root user with sudo access. Use the
# "remoteUser" property in devcontainer.json to use it. On Linux, update
Expand All @@ -14,9 +14,9 @@ ARG USER_UID=1000
ARG USER_GID=$USER_UID

RUN mkdir -p /workspace/growi/node_modules
RUN mkdir -p /workspace/growi/packages/app/node_modules
RUN mkdir -p /workspace/growi/packages/slackbot-proxy/node_modules
RUN mkdir -p /workspace/growi/packages/app/.next
RUN mkdir -p /workspace/growi/apps/app/node_modules
RUN mkdir -p /workspace/growi/apps/slackbot-proxy/node_modules
RUN mkdir -p /workspace/growi/apps/app/.next

# [Optional] Update UID/GID if needed
RUN if [ "$USER_GID" != "1000" ] || [ "$USER_UID" != "1000" ]; then \
Expand All @@ -42,7 +42,6 @@ RUN apt-get update \
google-chrome-stable \
# for Cypress
libgtk2.0-0 libgtk-3-0 libgbm-dev libnotify-dev libgconf-2-4 libnss3 libxss1 libasound2 libxtst6 xauth xvfb fonts-noto-cjk \

# Clean up
&& apt-get autoremove -y \
&& apt-get clean -y \
Expand Down
2 changes: 1 addition & 1 deletion .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
// "shutdownAction": "none",

// Use 'postCreateCommand' to run commands after the container is created.
// "postCreateCommand": "yarn install",
"postCreateCommand": "yarn global add turbo && yarn install",

// Uncomment to connect as a non-root user. See https://aka.ms/vscode-remote/containers/non-root.
"remoteUser": "node"
Expand Down
10 changes: 5 additions & 5 deletions .devcontainer/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ services:
volumes:
- ..:/workspace/growi:delegated
- node_modules:/workspace/growi/node_modules
- node_modules_app:/workspace/growi/packages/app/node_modules
- node_modules_slackbot-proxy:/workspace/growi/packages/slackbot-proxy/node_modules
- buildcache_app:/workspace/growi/packages/app/.next
- node_modules_app:/workspace/growi/apps/app/node_modules
- node_modules_slackbot-proxy:/workspace/growi/apps/slackbot-proxy/node_modules
- buildcache_app:/workspace/growi/apps/app/.next
- ../../growi-docker-compose:/workspace/growi-docker-compose:delegated

tty: true
Expand All @@ -49,7 +49,7 @@ services:
context: ../../growi-docker-compose/elasticsearch
dockerfile: ./Dockerfile
args:
- version=7.16.1
- version=7.17.9
restart: unless-stopped
ports:
- 9200:9200
Expand All @@ -67,7 +67,7 @@ services:

#need to adjust kibana version based on elasticsearch version (use same version as elasticsearch version)
kibana:
image: docker.elastic.co/kibana/kibana:7.16.1
image: docker.elastic.co/kibana/kibana:7.17.9
restart: unless-stopped
environment:
ELASTICSEARCH_HOSTS: 'http://elasticsearch:9200'
Expand Down
30 changes: 16 additions & 14 deletions .github/workflows/ci-app-prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@ on:
- .github/workflows/reusable-app-prod.yml
- .github/workflows/reusable-app-reg-suit.yml
- tsconfig.base.json
- turbo.json
- yarn.lock
- packages/app/**
- '!packages/app/docker/**'
- apps/app/**
- '!apps/app/docker/**'
- packages/codemirror-textlint/**
- packages/core/**
- packages/preset-themes/**
Expand All @@ -29,8 +30,9 @@ on:
- .github/workflows/reusable-app-reg-suit.yml
- tsconfig.base.json
- yarn.lock
- packages/app/**
- '!packages/app/docker/**'
- turbo.json
- apps/app/**
- '!apps/app/docker/**'
- packages/codemirror-textlint/**
- packages/core/**
- packages/preset-themes/**
Expand All @@ -51,35 +53,35 @@ concurrency:

jobs:

test-prod-node14:
uses: weseek/growi/.github/workflows/reusable-app-prod.yml@master
test-prod-node16:
uses: weseek/growi/.github/workflows/reusable-app-prod.yml@support/use-turborepo
with:
node-version: 14.x
node-version: 16.x
skip-cypress: true
secrets:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}


test-prod-node16:
uses: weseek/growi/.github/workflows/reusable-app-prod.yml@master
test-prod-node18:
uses: weseek/growi/.github/workflows/reusable-app-prod.yml@support/use-turborepo
with:
node-version: 16.x
node-version: 18.x
skip-cypress: ${{ contains( github.event.pull_request.labels.*.name, 'dependencies' ) }}
cypress-report-artifact-name: Cypress report
cypress-config-video: ${{ inputs.cypress-config-video || false }}
secrets:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}


run-reg-suit-node16:
needs: [test-prod-node16]
run-reg-suit-node18:
needs: [test-prod-node18]

uses: weseek/growi/.github/workflows/reusable-app-reg-suit.yml@master
uses: weseek/growi/.github/workflows/reusable-app-reg-suit.yml@support/use-turborepo

if: always()

with:
node-version: 16.x
node-version: 18.x
skip-reg-suit: ${{ contains( github.event.pull_request.labels.*.name, 'dependencies' ) }}
cypress-report-artifact-name: Cypress report
secrets:
Expand Down
126 changes: 88 additions & 38 deletions .github/workflows/ci-app.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,15 @@ on:
- .github/workflows/ci-app.yml
- .eslint*
- tsconfig.base.json
- turbo.json
- yarn.lock
- packages/app/**
- '!packages/app/docker/**'
- apps/app/**
- '!apps/app/docker/**'
- packages/codemirror-textlint/**
- packages/core/**
- packages/preset-themes/**
- packages/hackmd/**
- packages/presentation/**
- packages/preset-themes/**
- packages/remark-*/**
- packages/slack/**
- packages/ui/**
Expand All @@ -31,7 +33,7 @@ jobs:

strategy:
matrix:
node-version: [16.x]
node-version: [18.x]

steps:
- uses: actions/checkout@v3
Expand All @@ -43,29 +45,33 @@ jobs:
cache-dependency-path: '**/yarn.lock'

- name: Cache/Restore node_modules
id: cache-dependencies
uses: actions/cache@v3
with:
path: |
**/node_modules
key: node_modules-${{ runner.OS }}-node${{ matrix.node-version }}-${{ hashFiles('**/yarn.lock') }}-${{ hashFiles('packages/app/package.json') }}
key: node_modules-${{ runner.OS }}-node${{ matrix.node-version }}-${{ hashFiles('**/yarn.lock') }}-${{ hashFiles('apps/app/package.json') }}
restore-keys: |
node_modules-${{ runner.OS }}-node${{ matrix.node-version }}-${{ hashFiles('**/yarn.lock') }}-
node_modules-${{ runner.OS }}-node${{ matrix.node-version }}-
- name: lerna bootstrap
run: |
npx lerna bootstrap -- --frozen-lockfile
- name: Restore dist
uses: actions/cache/restore@v3
with:
path: |
**/.turbo
**/dist
key: dist-app-ci-${{ runner.OS }}-node${{ matrix.node-version }}-${{ hashFiles('node_modules/.cache/turbo/*-meta.json') }}
restore-keys: |
dist-app-ci-${{ runner.OS }}-node${{ matrix.node-version }}-
- name: lerna run lint for dependent packages
run: |
yarn lerna run lint --scope @growi/codemirror-textlint --scope @growi/core --scope @growi/hackmd --scope @growi/preset-themes --scope @growi/remark-* --scope @growi/slack --scope @growi/ui
- name: build dependent packages
- name: Install dependencies
run: |
yarn lerna run build --scope @growi/preset-themes
- name: lerna run lint for app
yarn global add turbo
yarn --frozen-lockfile
- name: Lint
run: |
yarn lerna run lint --scope @growi/app
turbo run lint --filter=!@growi/slackbot-proxy
- name: Slack Notification
uses: weseek/ghaction-slack-notification@master
Expand All @@ -77,12 +83,21 @@ jobs:
isCompactMode: true
url: ${{ secrets.SLACK_WEBHOOK_URL }}

- name: Cache dist
uses: actions/cache/save@v3
with:
path: |
**/.turbo
**/dist
key: dist-app-ci-${{ runner.OS }}-node${{ matrix.node-version }}-${{ hashFiles('node_modules/.cache/turbo/*-meta.json') }}


test:
runs-on: ubuntu-latest

strategy:
matrix:
node-version: [16.x]
node-version: [18.x]

services:
mongodb:
Expand All @@ -105,23 +120,29 @@ jobs:
with:
path: |
**/node_modules
key: node_modules-${{ runner.OS }}-node${{ matrix.node-version }}-${{ hashFiles('**/yarn.lock') }}-${{ hashFiles('packages/app/package.json') }}
key: node_modules-${{ runner.OS }}-node${{ matrix.node-version }}-${{ hashFiles('**/yarn.lock') }}-${{ hashFiles('apps/app/package.json') }}
restore-keys: |
node_modules-${{ runner.OS }}-node${{ matrix.node-version }}-${{ hashFiles('**/yarn.lock') }}-
node_modules-${{ runner.OS }}-node${{ matrix.node-version }}-
- name: lerna bootstrap
run: |
npx lerna bootstrap -- --frozen-lockfile
- name: Restore dist
uses: actions/cache/restore@v3
with:
path: |
**/.turbo
**/dist
key: dist-app-ci-${{ runner.OS }}-node${{ matrix.node-version }}-${{ hashFiles('node_modules/.cache/turbo/*-meta.json') }}
restore-keys: |
dist-app-ci-${{ runner.OS }}-node${{ matrix.node-version }}-
- name: lerna run test for plugins
- name: Install dependencies
run: |
yarn lerna run test --scope @growi/remark-*
yarn global add turbo
yarn --frozen-lockfile
- name: Test app
working-directory: ./packages/app
- name: Test
run: |
yarn test:ci --selectProjects unit server ; yarn test:ci --selectProjects server-v5
turbo run test --filter=!@growi/slackbot-proxy
env:
MONGO_URI: mongodb://localhost:${{ job.services.mongodb.ports['27017'] }}/growi_test

Expand All @@ -130,7 +151,7 @@ jobs:
with:
name: Coverage Report
path: |
packages/app/coverage
apps/app/coverage
packages/remark-growi-directive/coverage
- name: Slack Notification
Expand All @@ -143,12 +164,21 @@ jobs:
isCompactMode: true
url: ${{ secrets.SLACK_WEBHOOK_URL }}

- name: Cache dist
uses: actions/cache/save@v3
with:
path: |
**/.turbo
**/dist
key: dist-app-ci-${{ runner.OS }}-node${{ matrix.node-version }}-${{ hashFiles('node_modules/.cache/turbo/*-meta.json') }}


launch-dev:
runs-on: ubuntu-latest

strategy:
matrix:
node-version: [16.x]
node-version: [18.x]

services:
mongodb:
Expand All @@ -165,27 +195,38 @@ jobs:
cache: 'yarn'
cache-dependency-path: '**/yarn.lock'

- name: Cache/Restore node_modules and next cache files
- name: Cache/Restore node_modules
id: cache-dependencies
uses: actions/cache@v3
with:
path: |
**/node_modules
${{ github.workspace }}/packages/app/.next/cache
key: dev-${{ runner.OS }}-node${{ matrix.node-version }}-${{ hashFiles('**/yarn.lock') }}-${{ hashFiles('packages/app/package.json') }}
key: node_modules-${{ runner.OS }}-node${{ matrix.node-version }}-${{ hashFiles('**/yarn.lock') }}-${{ hashFiles('apps/app/package.json') }}
restore-keys: |
dev-${{ runner.OS }}-node${{ matrix.node-version }}-${{ hashFiles('**/yarn.lock') }}-
dev-${{ runner.OS }}-node${{ matrix.node-version }}-
node_modules-${{ runner.OS }}-node${{ matrix.node-version }}-${{ hashFiles('**/yarn.lock') }}-
node_modules-${{ runner.OS }}-node${{ matrix.node-version }}-
- name: lerna bootstrap
- name: Restore dist
uses: actions/cache/restore@v3
with:
path: |
**/.turbo
**/dist
${{ github.workspace }}/apps/app/.next
key: dist-app-dev-${{ runner.OS }}-node${{ matrix.node-version }}-${{ hashFiles('node_modules/.cache/turbo/*-meta.json') }}
restore-keys: |
dist-app-dev-${{ runner.OS }}-node${{ matrix.node-version }}-
- name: Install dependencies
run: |
npx lerna bootstrap -- --frozen-lockfile
yarn global add turbo
yarn --frozen-lockfile
- name: yarn dev:ci
working-directory: ./packages/app
- name: turbo run dev:ci
working-directory: ./apps/app
run: |
cp config/ci/.env.local.for-ci .env.development.local
yarn dev:ci
turbo run dev:ci
env:
MONGO_URI: mongodb://localhost:${{ job.services.mongodb.ports['27017'] }}/growi_dev

Expand All @@ -198,3 +239,12 @@ jobs:
channel: '#ci'
isCompactMode: true
url: ${{ secrets.SLACK_WEBHOOK_URL }}

- name: Cache dist
uses: actions/cache/save@v3
with:
path: |
**/.turbo
**/dist
${{ github.workspace }}/apps/app/.next
key: dist-app-dev-${{ runner.OS }}-node${{ matrix.node-version }}-${{ hashFiles('node_modules/.cache/turbo/*-meta.json') }}

0 comments on commit 0fbfb5e

Please sign in to comment.