From 40f1fea8b9ed2abf9690444c7df11dab2417d1ed Mon Sep 17 00:00:00 2001 From: h-takeyeah <61489178+h-takeyeah@users.noreply.github.com> Date: Wed, 6 Mar 2024 23:42:32 +0900 Subject: [PATCH 01/16] ci[typing-app]: new workflow --- .github/workflows/nodejsci.yml | 57 ++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 .github/workflows/nodejsci.yml diff --git a/.github/workflows/nodejsci.yml b/.github/workflows/nodejsci.yml new file mode 100644 index 0000000..7a95639 --- /dev/null +++ b/.github/workflows/nodejsci.yml @@ -0,0 +1,57 @@ +name: CI (typing-app) + +on: + push: + branches: + - develop + - main + pull_request: + branches: + - develop + - main + paths: + - "typing-app/**" + +defaults: + run: + working-directory: ./typing-app + +jobs: + build: + name: Build + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/cache@v4 + id: cache + with: + path: | + ${{ github.workspace }}/typing-app/node_modules + ${{ github.workspace }}/typing-app/.next/cache + key: ${{ runner.os }}-bun-cache-${{ hashFiles('typing-app/bun.lockb') }} + restore-keys: ${{ runner.os }}-bun-cache- + - uses: oven-sh/setup-bun@v1 + if: steps.cache.outputs.cache-hit != 'true' + with: + bun-version: latest + - name: Install dependencies + if: steps.cache.outputs.cache-hit != 'true' + run: bun install + - name: Try to build + run: npm run build + + lint: + name: Lint + runs-on: ubuntu-latest + needs: build + steps: + - uses: actions/checkout@v4 + - uses: actions/cache/restore@v4 + with: + path: | + ${{ github.workspace }}/typing-app/node_modules + ${{ github.workspace }}/typing-app/.next/cache + key: ${{ runner.os }}-bun-cache-${{ hashFiles('typing-app/bun.lockb') }} + fail-on-cache-miss: true + - name: Run lint + run: npm run lint From 3d192e84ee9b3fbdc5074ac965ce8d1a0e685ed6 Mon Sep 17 00:00:00 2001 From: h-takeyeah <61489178+h-takeyeah@users.noreply.github.com> Date: Thu, 7 Mar 2024 00:20:10 +0900 Subject: [PATCH 02/16] chore: add workflow_dispatch trigger --- .github/workflows/nodejsci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/nodejsci.yml b/.github/workflows/nodejsci.yml index 7a95639..da5d123 100644 --- a/.github/workflows/nodejsci.yml +++ b/.github/workflows/nodejsci.yml @@ -9,6 +9,7 @@ on: branches: - develop - main + workflow_dispatch: paths: - "typing-app/**" From a9b9dce4f95ef8286109ec66e40f4f4c7670461b Mon Sep 17 00:00:00 2001 From: h-takeyeah <61489178+h-takeyeah@users.noreply.github.com> Date: Thu, 7 Mar 2024 00:38:27 +0900 Subject: [PATCH 03/16] ci: fix paths --- .github/workflows/nodejsci.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/nodejsci.yml b/.github/workflows/nodejsci.yml index da5d123..ca47afd 100644 --- a/.github/workflows/nodejsci.yml +++ b/.github/workflows/nodejsci.yml @@ -5,13 +5,15 @@ on: branches: - develop - main + paths: + - "typing-app/**" pull_request: branches: - develop - main + paths: + - "typing-app/**" workflow_dispatch: - paths: - - "typing-app/**" defaults: run: From 414ab59ceff4c8e11db68b8c50bf17ad58b5b81b Mon Sep 17 00:00:00 2001 From: h-takeyeah <61489178+h-takeyeah@users.noreply.github.com> Date: Thu, 7 Mar 2024 00:53:37 +0900 Subject: [PATCH 04/16] chore: add workflow files for dispatch condition --- .github/workflows/nodejsci.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/nodejsci.yml b/.github/workflows/nodejsci.yml index ca47afd..16a86f1 100644 --- a/.github/workflows/nodejsci.yml +++ b/.github/workflows/nodejsci.yml @@ -3,15 +3,19 @@ name: CI (typing-app) on: push: branches: + - "ci/**" - develop - main paths: + - .github/workflows/nodejsci.yml - "typing-app/**" pull_request: branches: + - "ci/**" - develop - main paths: + - .github/workflows/nodejsci.yml - "typing-app/**" workflow_dispatch: From 11063391606e7b5be2fe84488255201877d221c0 Mon Sep 17 00:00:00 2001 From: h-takeyeah <61489178+h-takeyeah@users.noreply.github.com> Date: Fri, 8 Mar 2024 20:14:05 +0900 Subject: [PATCH 05/16] ci: compoiste steps to remove duplicated code --- .../actions/prepare-nodemodules/action.yml | 31 +++++++++++++++++++ .github/workflows/nodejsci.yml | 16 ++-------- 2 files changed, 33 insertions(+), 14 deletions(-) create mode 100644 .github/actions/prepare-nodemodules/action.yml diff --git a/.github/actions/prepare-nodemodules/action.yml b/.github/actions/prepare-nodemodules/action.yml new file mode 100644 index 0000000..deb29a6 --- /dev/null +++ b/.github/actions/prepare-nodemodules/action.yml @@ -0,0 +1,31 @@ +name: Prepare node_modules + +description: Install Dependencies using Bun. If cache hit, do nothing. + +inputs: + root: + description: |- + An absolute path to the directory where contains package.json. + Required + required: true + +runs: + using: composite + steps: + - uses: actions/cache@v4 + id: cache + working-directory: ${{ inputs.root }} + with: + path: | + ~/.bun/install/cache + ${{ inputs.root }}/.next/cache + key: ${{ runner.os }}-bun-cache-${{ hashFiles('bun.lockb') }} + restore-keys: ${{ runner.os }}-bun-cache- + - uses: oven-sh/setup-bun@v1 + if: steps.cache.outputs.cache-hit != 'true' + with: + bun-version: latest + - name: Install dependencies + if: steps.cache.outputs.cache-hit != 'true' + working-directory: ${{ inputs.root }} + run: bun install diff --git a/.github/workflows/nodejsci.yml b/.github/workflows/nodejsci.yml index 16a86f1..15744f1 100644 --- a/.github/workflows/nodejsci.yml +++ b/.github/workflows/nodejsci.yml @@ -29,21 +29,9 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - uses: actions/cache@v4 - id: cache + - uses: ./.github/actions/prepare-nodemodules with: - path: | - ${{ github.workspace }}/typing-app/node_modules - ${{ github.workspace }}/typing-app/.next/cache - key: ${{ runner.os }}-bun-cache-${{ hashFiles('typing-app/bun.lockb') }} - restore-keys: ${{ runner.os }}-bun-cache- - - uses: oven-sh/setup-bun@v1 - if: steps.cache.outputs.cache-hit != 'true' - with: - bun-version: latest - - name: Install dependencies - if: steps.cache.outputs.cache-hit != 'true' - run: bun install + root: ${{ github.workspace }}/typing-app - name: Try to build run: npm run build From be6be447899419f99f5cb0f57aadeb163c0266f6 Mon Sep 17 00:00:00 2001 From: h-takeyeah <61489178+h-takeyeah@users.noreply.github.com> Date: Fri, 8 Mar 2024 20:15:44 +0900 Subject: [PATCH 06/16] ci: remove lint job --- .github/workflows/nodejsci.yml | 17 ----------------- 1 file changed, 17 deletions(-) diff --git a/.github/workflows/nodejsci.yml b/.github/workflows/nodejsci.yml index 15744f1..d0b9daa 100644 --- a/.github/workflows/nodejsci.yml +++ b/.github/workflows/nodejsci.yml @@ -11,7 +11,6 @@ on: - "typing-app/**" pull_request: branches: - - "ci/**" - develop - main paths: @@ -34,19 +33,3 @@ jobs: root: ${{ github.workspace }}/typing-app - name: Try to build run: npm run build - - lint: - name: Lint - runs-on: ubuntu-latest - needs: build - steps: - - uses: actions/checkout@v4 - - uses: actions/cache/restore@v4 - with: - path: | - ${{ github.workspace }}/typing-app/node_modules - ${{ github.workspace }}/typing-app/.next/cache - key: ${{ runner.os }}-bun-cache-${{ hashFiles('typing-app/bun.lockb') }} - fail-on-cache-miss: true - - name: Run lint - run: npm run lint From 22599b00334214621315882d84cc97fa5daa68de Mon Sep 17 00:00:00 2001 From: h-takeyeah <61489178+h-takeyeah@users.noreply.github.com> Date: Fri, 8 Mar 2024 20:22:55 +0900 Subject: [PATCH 07/16] ci: fix properties --- .github/actions/prepare-nodemodules/action.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/actions/prepare-nodemodules/action.yml b/.github/actions/prepare-nodemodules/action.yml index deb29a6..04aa81b 100644 --- a/.github/actions/prepare-nodemodules/action.yml +++ b/.github/actions/prepare-nodemodules/action.yml @@ -14,7 +14,7 @@ runs: steps: - uses: actions/cache@v4 id: cache - working-directory: ${{ inputs.root }} + shell: bash with: path: | ~/.bun/install/cache @@ -26,6 +26,7 @@ runs: with: bun-version: latest - name: Install dependencies + shell: bash if: steps.cache.outputs.cache-hit != 'true' working-directory: ${{ inputs.root }} run: bun install From dc7d95c45b1c1399baf19b9b9cc37306da189b8b Mon Sep 17 00:00:00 2001 From: h-takeyeah <61489178+h-takeyeah@users.noreply.github.com> Date: Fri, 8 Mar 2024 20:25:26 +0900 Subject: [PATCH 08/16] ci: remove unexpected property --- .github/actions/prepare-nodemodules/action.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/actions/prepare-nodemodules/action.yml b/.github/actions/prepare-nodemodules/action.yml index 04aa81b..c9abd29 100644 --- a/.github/actions/prepare-nodemodules/action.yml +++ b/.github/actions/prepare-nodemodules/action.yml @@ -14,7 +14,6 @@ runs: steps: - uses: actions/cache@v4 id: cache - shell: bash with: path: | ~/.bun/install/cache From aaf85f358c1c585cc30eb4bdcef9f641871020dc Mon Sep 17 00:00:00 2001 From: h-takeyeah <61489178+h-takeyeah@users.noreply.github.com> Date: Fri, 8 Mar 2024 20:55:32 +0900 Subject: [PATCH 09/16] ci: set concurrency and permissions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit concurrency 連続pushしたときに前のを止めるやつ --- .github/workflows/nodejsci.yml | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/.github/workflows/nodejsci.yml b/.github/workflows/nodejsci.yml index d0b9daa..5428ac8 100644 --- a/.github/workflows/nodejsci.yml +++ b/.github/workflows/nodejsci.yml @@ -18,9 +18,16 @@ on: - "typing-app/**" workflow_dispatch: +permissions: + contents: read + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + defaults: run: - working-directory: ./typing-app + working-directory: typing-app jobs: build: @@ -28,7 +35,7 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - uses: ./.github/actions/prepare-nodemodules + - uses: .github/actions/prepare-nodemodules with: root: ${{ github.workspace }}/typing-app - name: Try to build From 4f2d0dbc02b467c1cfc14b0c03fc82e21e26cd7d Mon Sep 17 00:00:00 2001 From: h-takeyeah <61489178+h-takeyeah@users.noreply.github.com> Date: Fri, 8 Mar 2024 21:00:15 +0900 Subject: [PATCH 10/16] =?UTF-8?q?ci:=20golangci-lint.yml=E3=81=AB=E5=90=88?= =?UTF-8?q?=E3=82=8F=E3=81=9B=E3=81=A6=E6=94=B9=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/nodejsci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/nodejsci.yml b/.github/workflows/nodejsci.yml index 5428ac8..4c682eb 100644 --- a/.github/workflows/nodejsci.yml +++ b/.github/workflows/nodejsci.yml @@ -1,4 +1,4 @@ -name: CI (typing-app) +name: nodejsci on: push: From ccdbd9265e8bb88d38eff12c035401f5e1684aed Mon Sep 17 00:00:00 2001 From: h-takeyeah <61489178+h-takeyeah@users.noreply.github.com> Date: Fri, 8 Mar 2024 21:26:40 +0900 Subject: [PATCH 11/16] ci: fix --- .github/workflows/nodejsci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/nodejsci.yml b/.github/workflows/nodejsci.yml index 4c682eb..3bc9c45 100644 --- a/.github/workflows/nodejsci.yml +++ b/.github/workflows/nodejsci.yml @@ -35,7 +35,7 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - uses: .github/actions/prepare-nodemodules + - uses: ./.github/actions/prepare-nodemodules with: root: ${{ github.workspace }}/typing-app - name: Try to build From f29630ac1a279de612ab1f8f99b9df7834d855df Mon Sep 17 00:00:00 2001 From: h-takeyeah <61489178+h-takeyeah@users.noreply.github.com> Date: Fri, 8 Mar 2024 21:29:49 +0900 Subject: [PATCH 12/16] ci: fix cache path --- .github/actions/prepare-nodemodules/action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/actions/prepare-nodemodules/action.yml b/.github/actions/prepare-nodemodules/action.yml index c9abd29..6cc4a9b 100644 --- a/.github/actions/prepare-nodemodules/action.yml +++ b/.github/actions/prepare-nodemodules/action.yml @@ -16,7 +16,7 @@ runs: id: cache with: path: | - ~/.bun/install/cache + ${{ inputs.root }}/node_modules ${{ inputs.root }}/.next/cache key: ${{ runner.os }}-bun-cache-${{ hashFiles('bun.lockb') }} restore-keys: ${{ runner.os }}-bun-cache- From 4d8b8db8b862b7ba1aaef891e9124a68ebbe6c79 Mon Sep 17 00:00:00 2001 From: h-takeyeah <61489178+h-takeyeah@users.noreply.github.com> Date: Fri, 8 Mar 2024 21:33:21 +0900 Subject: [PATCH 13/16] ci: do not run on push to ci branches MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit on.push.branches に "ci/**" が含まれていると base=main, head=ci/hoge な PR を作った時に2重に 回ってしまうのを避けるため --- .github/workflows/nodejsci.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/nodejsci.yml b/.github/workflows/nodejsci.yml index 3bc9c45..d355fe9 100644 --- a/.github/workflows/nodejsci.yml +++ b/.github/workflows/nodejsci.yml @@ -3,7 +3,6 @@ name: nodejsci on: push: branches: - - "ci/**" - develop - main paths: From 0a4c4a4882f9c899509f55b7af3e14e1aea67825 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Y=C5=8Dtaku?= <61489178+h-takeyeah@users.noreply.github.com> Date: Sat, 9 Mar 2024 17:14:59 +0900 Subject: [PATCH 14/16] ci: do not fire on `on.push` nodejsci.yml --- .github/workflows/nodejsci.yml | 7 ------- 1 file changed, 7 deletions(-) diff --git a/.github/workflows/nodejsci.yml b/.github/workflows/nodejsci.yml index d355fe9..159367a 100644 --- a/.github/workflows/nodejsci.yml +++ b/.github/workflows/nodejsci.yml @@ -1,13 +1,6 @@ name: nodejsci on: - push: - branches: - - develop - - main - paths: - - .github/workflows/nodejsci.yml - - "typing-app/**" pull_request: branches: - develop From a263a7979a3f97d6d4f44c7672559094baf23061 Mon Sep 17 00:00:00 2001 From: h-takeyeah <61489178+h-takeyeah@users.noreply.github.com> Date: Sat, 9 Mar 2024 18:06:45 +0900 Subject: [PATCH 15/16] ci: renamed nodeci to build-app --- .github/workflows/{nodejsci.yml => build-app.yml} | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) rename .github/workflows/{nodejsci.yml => build-app.yml} (79%) diff --git a/.github/workflows/nodejsci.yml b/.github/workflows/build-app.yml similarity index 79% rename from .github/workflows/nodejsci.yml rename to .github/workflows/build-app.yml index 159367a..a461aa7 100644 --- a/.github/workflows/nodejsci.yml +++ b/.github/workflows/build-app.yml @@ -1,4 +1,4 @@ -name: nodejsci +name: build-app on: pull_request: @@ -6,13 +6,10 @@ on: - develop - main paths: - - .github/workflows/nodejsci.yml + - .github/workflows/build-app.yml - "typing-app/**" workflow_dispatch: -permissions: - contents: read - concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true @@ -25,10 +22,12 @@ jobs: build: name: Build runs-on: ubuntu-latest + permissions: + contents: read steps: - uses: actions/checkout@v4 - uses: ./.github/actions/prepare-nodemodules with: root: ${{ github.workspace }}/typing-app - - name: Try to build + - name: Build Next.js Project run: npm run build From c5bc37bd7b024c728d58880c9a9fa1cc5ac35f37 Mon Sep 17 00:00:00 2001 From: h-takeyeah <61489178+h-takeyeah@users.noreply.github.com> Date: Sat, 9 Mar 2024 18:16:43 +0900 Subject: [PATCH 16/16] ci: fix cache key error --- .github/actions/prepare-nodemodules/action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/actions/prepare-nodemodules/action.yml b/.github/actions/prepare-nodemodules/action.yml index 6cc4a9b..a8804d4 100644 --- a/.github/actions/prepare-nodemodules/action.yml +++ b/.github/actions/prepare-nodemodules/action.yml @@ -18,7 +18,7 @@ runs: path: | ${{ inputs.root }}/node_modules ${{ inputs.root }}/.next/cache - key: ${{ runner.os }}-bun-cache-${{ hashFiles('bun.lockb') }} + key: ${{ runner.os }}-bun-cache-${{ hashFiles('**/bun.lockb') }} restore-keys: ${{ runner.os }}-bun-cache- - uses: oven-sh/setup-bun@v1 if: steps.cache.outputs.cache-hit != 'true'