From 75271571bb28f2117f502a25cd44f183f5e2bdc7 Mon Sep 17 00:00:00 2001 From: AsPulse Date: Mon, 11 Dec 2023 23:39:30 +0900 Subject: [PATCH] Add CI --- .github/actions/setup-node/action.yaml | 23 +++++++++++++++++++++++ .github/actions/setup-turbo/action.yaml | 19 ++++++++----------- .github/workflows/deps-check.yaml | 18 ++++++++++++++++++ .github/workflows/format-and-lint.yaml | 10 +++++++--- 4 files changed, 56 insertions(+), 14 deletions(-) create mode 100644 .github/actions/setup-node/action.yaml create mode 100644 .github/workflows/deps-check.yaml diff --git a/.github/actions/setup-node/action.yaml b/.github/actions/setup-node/action.yaml new file mode 100644 index 0000000..ef04608 --- /dev/null +++ b/.github/actions/setup-node/action.yaml @@ -0,0 +1,23 @@ +name: Setup node +description: "Setup pnpm, Node.js." +inputs: + node-version: + description: "Version of Node.js using setup." + default: "20" + required: false + +runs: + using: composite + steps: + - name: Setup pnpm + uses: pnpm/action-setup@v2 + - name: Setup Node.js + uses: actions/setup-node@v3 + with: + node-version: ${{ inputs.node-version }} + cache: pnpm + cache-dependency-path: pnpm-lock.yaml + - name: Install packages + shell: sh + run: pnpm install --frozen-lockfile + diff --git a/.github/actions/setup-turbo/action.yaml b/.github/actions/setup-turbo/action.yaml index 02be55e..5b947c5 100644 --- a/.github/actions/setup-turbo/action.yaml +++ b/.github/actions/setup-turbo/action.yaml @@ -2,24 +2,21 @@ name: Setup turbo description: "Setup pnpm, Node.js, turborepo and its own remote-caching server." inputs: node-version: - description: "version of Node.js using setup." + description: "Version of Node.js using setup. This is also used as a cache key for turbo-remote-cache-server." default: "20" required: false + turbo-cache-key: + description: "Cache key for turbo-remote-cache-server." + required: true runs: using: composite steps: - name: Launch Turbo Remote Cache Server uses: dtinth/setup-github-actions-caching-for-turbo@v1.1.0 - - name: Setup pnpm - uses: pnpm/action-setup@v2 - - name: Setup Node.js - uses: actions/setup-node@v3 + with: + cache-prefix: turbogha_${{ inputs.turbo-cache-key }}_node${{ inputs.node-version }} + - name: Setup node + uses: ./.github/actions/setup-node with: node-version: ${{ inputs.node-version }} - cache: pnpm - cache-dependency-path: pnpm-lock.yaml - - name: Install packages - shell: sh - run: pnpm install --frozen-lockfile - diff --git a/.github/workflows/deps-check.yaml b/.github/workflows/deps-check.yaml new file mode 100644 index 0000000..d11e808 --- /dev/null +++ b/.github/workflows/deps-check.yaml @@ -0,0 +1,18 @@ +name: deps-check + +on: + push: + branches: [main] + pull_request: + +permissions: read-all + +jobs: + manypkg: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Setup Node.js + uses: ./.github/actions/setup-node + - name: Run manypkg + run: pnpm manypkg check diff --git a/.github/workflows/format-and-lint.yaml b/.github/workflows/format-and-lint.yaml index 9750207..6573996 100644 --- a/.github/workflows/format-and-lint.yaml +++ b/.github/workflows/format-and-lint.yaml @@ -3,7 +3,7 @@ name: format-and-lint on: push: branches: [main] - pull_request_target: + pull_request: permissions: read-all @@ -12,7 +12,10 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - - uses: ./.github/actions/setup-turbo + - name: Setup turbo + uses: ./.github/actions/setup-turbo + with: + turbo-cache-key: prettier - name: Run Prettier run: pnpm run format:check @@ -20,7 +23,8 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - - uses: ./.github/actions/setup-turbo + - name: Setup Node.js + uses: ./.github/actions/setup-node - name: Run ESLint run: pnpm run lint