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" },