継続的インテグレーション (CI)
Frourio のテストに必要なコマンドは下記の 5 つです。 お好きな環境で実行してください。
- npm
- yarn
npm install
npm install --prefix server
npm run lint
npm run typecheck
npm test
yarn install
yarn install --cwd server
yarn lint
yarn typecheck
yarn test
GitHub Actions Workflow
参考までに、プロジェクト作成時の CI 設定で GItHub Actions を選択した場合、以下のような workflow が .github/workflows/test.yml
に生成されます。
Workflow は構成によって異なるため、create-frourio-app を使用して自分の構成に合った workflow を生成することをお勧めします。
- npm
- yarn
.github/workflows/test.yml
name: Test
on: push
jobs:
test:
name: Test
runs-on: ubuntu-latest
env:
API_SERVER_PORT: 8080
API_ORIGIN: http://localhost:8080
API_BASE_PATH: /api
steps:
- uses: actions/checkout@v2
- name: setup Node.js
uses: actions/setup-node@v1
with:
node-version: 14
- uses: actions/cache@v2
id: client-npm-cache
with:
path: 'node_modules'
key: client-npm-${{ hashFiles('package-lock.json') }}
- uses: actions/cache@v2
id: server-npm-cache
with:
path: 'server/node_modules'
key: server-npm-${{ hashFiles('server/package-lock.json') }}
- run: npm install
if: steps.client-npm-cache.outputs.cache-hit != 'true'
- run: npm install --prefix server
if: steps.server-npm-cache.outputs.cache-hit != 'true'
- run: npm run lint
- run: |
sudo systemctl start mysql.service
echo "DATABASE_URL=mysql://root:root@localhost:3306/test" > server/prisma/.env
- run: npm run typecheck
- run: |
npm run migrate:dev
npm test
env:
API_JWT_SECRET: test_secret
.github/workflows/test.yml
name: Test
on: push
jobs:
test:
name: Test
runs-on: ubuntu-latest
env:
API_SERVER_PORT: 8080
API_ORIGIN: http://localhost:8080
API_BASE_PATH: /api
steps:
- uses: actions/checkout@v2
- name: setup Node.js
uses: actions/setup-node@v1
with:
node-version: 14
- uses: actions/cache@v2
id: client-yarn-cache
with:
path: 'node_modules'
key: client-yarn-${{ hashFiles('yarn.lock') }}
- uses: actions/cache@v2
id: server-yarn-cache
with:
path: 'server/node_modules'
key: server-yarn-${{ hashFiles('server/yarn.lock') }}
- run: yarn install
if: steps.client-yarn-cache.outputs.cache-hit != 'true'
- run: yarn install --cwd server
if: steps.server-yarn-cache.outputs.cache-hit != 'true'
- run: yarn run lint
- run: |
sudo systemctl start mysql.service
echo "DATABASE_URL=mysql://root:root@localhost:3306/test" > server/prisma/.env
- run: yarn run typecheck
- run: |
yarn run migrate:dev
yarn test
env:
API_JWT_SECRET: test_secret