From 3e22677e87effc6eb602efb1641e4c9a4ce8c5a4 Mon Sep 17 00:00:00 2001 From: Tsuyoshi HARA Date: Thu, 12 Dec 2024 14:07:42 +0900 Subject: [PATCH 1/3] ci: Rename --- .github/workflows/{nodejs.yml => ci.yml} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename .github/workflows/{nodejs.yml => ci.yml} (100%) diff --git a/.github/workflows/nodejs.yml b/.github/workflows/ci.yml similarity index 100% rename from .github/workflows/nodejs.yml rename to .github/workflows/ci.yml From 2915500dc7b7710483f81cc5bbe722fbad7f8d30 Mon Sep 17 00:00:00 2001 From: Tsuyoshi HARA Date: Thu, 12 Dec 2024 14:10:23 +0900 Subject: [PATCH 2/3] ci: Clean up --- .github/workflows/ci.yml | 83 +++++++++++++++++++++++++++++++++++++--- package.json | 1 + 2 files changed, 78 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 28117086..e162ec4b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,14 +1,14 @@ name: Node CI -on: [push] +on: [push, pull_request] jobs: - build: + lint: runs-on: ubuntu-latest strategy: matrix: - node-version: [18.x, 20.x] + node-version: [20.x, 22.x] steps: - uses: actions/checkout@v4.1.1 @@ -39,14 +39,85 @@ jobs: - name: Install dependencies run: yarn install --frozen-lockfile - - name: Build - run: yarn build - - name: Run ESLint run: | BASE_BRANCH=${GITHUB_BASE_REF:-master} BASE_COMMIT=$(git merge-base HEAD origin/${BASE_BRANCH}) yarn lint-staged --concurrent=false --diff="${BASE_COMMIT}..HEAD" --verbose + test: + runs-on: ubuntu-latest + + strategy: + matrix: + node-version: [20.x, 22.x] + + steps: + - uses: actions/checkout@v4.1.1 + + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v4.0.0 + with: + node-version: ${{ matrix.node-version }} + + - name: Get yarn cache directory path + id: yarn-cache-dir-path + run: echo "dir=$(yarn cache dir)" >> $GITHUB_OUTPUT + + - name: Restore cache for yarn and lerna + uses: actions/cache@v3.3.2 + id: yarn-cache + with: + path: | + ${{ steps.yarn-cache-dir-path.outputs.dir }} + node_modules + */*/node_modules + key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} + restore-keys: | + ${{ runner.os }}-yarn- + + - name: Install dependencies + run: yarn install --frozen-lockfile + + - name: Build + run: yarn build + - name: Test run: yarn test + + build: + runs-on: ubuntu-latest + + strategy: + matrix: + node-version: [20.x, 22.x] + + steps: + - uses: actions/checkout@v4.1.1 + + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v4.0.0 + with: + node-version: ${{ matrix.node-version }} + + - name: Get yarn cache directory path + id: yarn-cache-dir-path + run: echo "dir=$(yarn cache dir)" >> $GITHUB_OUTPUT + + - name: Restore cache for yarn and lerna + uses: actions/cache@v3.3.2 + id: yarn-cache + with: + path: | + ${{ steps.yarn-cache-dir-path.outputs.dir }} + node_modules + */*/node_modules + key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} + restore-keys: | + ${{ runner.os }}-yarn- + + - name: Install dependencies + run: yarn install --frozen-lockfile + + - name: Build + run: yarn build diff --git a/package.json b/package.json index 7ee6cab8..f93aa28a 100644 --- a/package.json +++ b/package.json @@ -31,6 +31,7 @@ }, "scripts": { "postinstall": "lerna bootstrap", + "pretest": "yarn build", "test": "FORCE_COLOR=1 lerna run --stream test", "test:watch": "FORCE_COLOR=1 lerna exec --stream --ignore prettier-config-wantedly -- npm run test -- --watch", "test:watch:frolint": "lerna exec \"npm run test -- --watch\" --scope frolint", From 82038379b1ff78cfbf81700a38ed6c937cff7c3f Mon Sep 17 00:00:00 2001 From: Tsuyoshi HARA Date: Thu, 12 Dec 2024 14:12:08 +0900 Subject: [PATCH 3/3] ci: Stop using matrix strategy on lint job --- .github/workflows/ci.yml | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e162ec4b..8f385bf7 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -6,19 +6,15 @@ jobs: lint: runs-on: ubuntu-latest - strategy: - matrix: - node-version: [20.x, 22.x] - steps: - uses: actions/checkout@v4.1.1 with: fetch-depth: 0 - - name: Use Node.js ${{ matrix.node-version }} + - name: Use Node.js uses: actions/setup-node@v4.0.0 with: - node-version: ${{ matrix.node-version }} + node-version: 22 - name: Get yarn cache directory path id: yarn-cache-dir-path