From 9cffe84f7fedfc579767f1ba2ba306c254c28073 Mon Sep 17 00:00:00 2001 From: na2na-p Date: Tue, 14 Nov 2023 00:05:43 +0900 Subject: [PATCH] =?UTF-8?q?CI=E4=BB=98=E3=81=91=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/cd-for-pr.yml | 30 +++++++++++++ .github/workflows/ci.yml | 75 +++++++++++++++++++++++++++++++++ package.json | 5 ++- 3 files changed, 109 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/cd-for-pr.yml create mode 100644 .github/workflows/ci.yml diff --git a/.github/workflows/cd-for-pr.yml b/.github/workflows/cd-for-pr.yml new file mode 100644 index 00000000..b71778b7 --- /dev/null +++ b/.github/workflows/cd-for-pr.yml @@ -0,0 +1,30 @@ +name: CD for PR +on: + pull_request: + branches: + - main + - v3 + types: + - opened + - reopened + - synchronize + - ready_for_review + - labeled + - unlabeled + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + prepare: + if: github.event.pull_request.draft == false + timeout-minutes: 60 + runs-on: + - ubuntu-latest + steps: + - uses: actions/checkout@v3 + ci: + uses: ./.github/workflows/ci.yml + secrets: inherit + needs: prepare diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 00000000..ec8a1730 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,75 @@ +name: CI +on: workflow_call + +jobs: + Build: + timeout-minutes: 60 + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v4 + - name: Setup asdf + uses: asdf-vm/actions/setup@v3.0.2 + # 2回目以降エラーが出るが問題なし + continue-on-error: true + - name: asdf install + uses: asdf-vm/actions/install@v3.0.2 + - name: Install dependencies + run: pnpm install --frozen-lockfile + - name: Build + run: pnpm build + + TypeCheck: + timeout-minutes: 60 + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v4 + - name: Setup asdf + uses: asdf-vm/actions/setup@v3.0.2 + # 2回目以降エラーが出るが問題なし + continue-on-error: true + - name: asdf install + uses: asdf-vm/actions/install@v3.0.2 + - name: Install dependencies + run: pnpm install --frozen-lockfile + - name: typecheck + run: pnpm tsc --noEmit + + Lint: + timeout-minutes: 60 + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v4 + - name: Setup asdf + uses: asdf-vm/actions/setup@v3.0.2 + # 2回目以降エラーが出るが問題なし + continue-on-error: true + - name: asdf install + uses: asdf-vm/actions/install@v3.0.2 + - name: Install dependencies + run: pnpm install --frozen-lockfile + - name: fmt + run: pnpm fmt + - name: lint + run: pnpm lint + + Test: + timeout-minutes: 60 + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v3 + - name: Setup asdf + uses: asdf-vm/actions/setup@v3.0.2 + # 2回目以降エラーが出るが問題なし + continue-on-error: true + - name: asdf install + uses: asdf-vm/actions/install@v3.0.2 + - name: Install dependencies + run: pnpm install --frozen-lockfile + - name: test + run: pnpm test:coverage + env: + TZ: Asia/Tokyo diff --git a/package.json b/package.json index 39b7461b..f761332f 100644 --- a/package.json +++ b/package.json @@ -8,7 +8,10 @@ "start": "node --import 'data:text/javascript,import { register } from \"node:module\"; import { pathToFileURL } from \"node:url\"; register(\"./loader.mjs\", pathToFileURL(\"./\"));' dist/index.js", "build": "swc ./src -s -d ./dist", "dev": "tsx src/index.ts --watch", - "lint": "eslint --ext .js,.ts \"./src/**/*.{js,ts}\"", + "lint": "eslint --ext .js,.ts,.tsx \"./src/**/*.{js,ts,tsx}\"", + "lint:fix": "yarn lint --fix", + "fmt": "prettier --config ./.prettierrc --list-different \"src/**/*.{js,json,ts,tsx,css,md}\"", + "fmt:fix": "yarn fmt --write", "test": "node --experimental-vm-modules ./node_modules/jest/bin/jest.js --coverage --silent", "test:watch": "node --experimental-vm-modules ./node_modules/jest/bin/jest.js --watch" },