From f1fb6c911140f03b4f6d6aa210a501df321e7e9b Mon Sep 17 00:00:00 2001 From: Caspian Zhao Date: Fri, 4 Oct 2024 21:25:51 +0800 Subject: [PATCH 1/5] ci: add new CI job for testing --- .github/workflows/ci.yml | 44 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 .github/workflows/ci.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 00000000..b5c02247 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,44 @@ +name: CI + +on: + push: + branches: ["main"] + pull_request: + branches: ["main"] + workflow_dispatch: + +jobs: + test: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Setup Node.js + uses: actions/setup-node@v3 + with: + node-version: '18.x' + + - name: Get yarn cache directory path + id: yarn-cache-dir-path + run: echo "dir=$(yarn cache dir)" >> $GITHUB_OUTPUT + + - name: Cache yarn dependencies + uses: actions/cache@v3 + with: + path: ${{ steps.yarn-cache-dir-path.outputs.dir }} + key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} + restore-keys: | + ${{ runner.os }}-yarn- + + - name: Install dependencies + run: yarn install + + - name: Run tests + run: yarn test + + - name: Run linter + run: yarn lint + + - name: Check types + run: yarn types \ No newline at end of file From 009d5a9939ce540b6ad00a9b5c14398fe15b9d74 Mon Sep 17 00:00:00 2001 From: Caspian Zhao Date: Fri, 4 Oct 2024 21:28:13 +0800 Subject: [PATCH 2/5] chore: remove unused linting before commit --- package.json | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/package.json b/package.json index 773ac2a3..666f1046 100644 --- a/package.json +++ b/package.json @@ -93,8 +93,7 @@ }, "husky": { "hooks": { - "commit-msg": "commitlint -E HUSKY_GIT_PARAMS", - "pre-commit": "yarn test && yarn lint && yarn types" + "commit-msg": "commitlint -E HUSKY_GIT_PARAMS" } }, "commitlint": { From 5e7cb9c8be6543c608f6b41fc8b0924892ce79cf Mon Sep 17 00:00:00 2001 From: Caspian Zhao Date: Fri, 4 Oct 2024 21:40:05 +0800 Subject: [PATCH 3/5] ci: update testing CI --- .github/workflows/ci.yml | 22 ++++++++++++---------- .github/workflows/release.yml | 8 +++++--- 2 files changed, 17 insertions(+), 13 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b5c02247..1744b3a1 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -11,25 +11,27 @@ jobs: test: runs-on: ubuntu-latest steps: - - name: Checkout + - name: checkout code repository uses: actions/checkout@v3 + with: + fetch-depth: 0 - - name: Setup Node.js + - name: setup node.js uses: actions/setup-node@v3 with: - node-version: '18.x' + node-version: 18 - name: Get yarn cache directory path id: yarn-cache-dir-path - run: echo "dir=$(yarn cache dir)" >> $GITHUB_OUTPUT + run: echo "::set-output name=dir::$(yarn cache dir)" - - name: Cache yarn dependencies - uses: actions/cache@v3 + - uses: actions/cache@v1 + id: yarn-cache with: - path: ${{ steps.yarn-cache-dir-path.outputs.dir }} - key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} - restore-keys: | - ${{ runner.os }}-yarn- + path: ${{ steps.yarn-cache-dir-path.outputs.dir }} + key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} + restore-keys: | + ${{ runner.os }}-yarn- - name: Install dependencies run: yarn install diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 31bb4939..d2ce020f 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -26,16 +26,18 @@ jobs: run: echo "::set-output name=dir::$(yarn cache dir)" - uses: actions/cache@v1 - id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`) + id: yarn-cache with: path: ${{ steps.yarn-cache-dir-path.outputs.dir }} key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} restore-keys: | ${{ runner.os }}-yarn- - - name: install dependencies - run: yarn install && yarn clean && yarn prepare + - name: Install dependencies + run: yarn install + - name: build + run: yarn prepare - name: Create Release Pull Request or Publish to npm id: changesets From b9e542ed2b76da65df3039f0bd7feaf429d7a017 Mon Sep 17 00:00:00 2001 From: Caspian Zhao Date: Fri, 4 Oct 2024 21:49:47 +0800 Subject: [PATCH 4/5] ci: update yarn caching logic --- .github/workflows/ci.yml | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1744b3a1..1760a9a7 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -16,22 +16,11 @@ jobs: with: fetch-depth: 0 - - name: setup node.js + - name: Setup Node uses: actions/setup-node@v3 with: - node-version: 18 - - - name: Get yarn cache directory path - id: yarn-cache-dir-path - run: echo "::set-output name=dir::$(yarn cache dir)" - - - uses: actions/cache@v1 - id: yarn-cache - with: - path: ${{ steps.yarn-cache-dir-path.outputs.dir }} - key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} - restore-keys: | - ${{ runner.os }}-yarn- + node-version: 18.x + cache: yarn - name: Install dependencies run: yarn install From 45751a43072ba4dcf9f106dcb46c278f36fbfc61 Mon Sep 17 00:00:00 2001 From: Caspian Zhao Date: Fri, 4 Oct 2024 22:01:01 +0800 Subject: [PATCH 5/5] ci: refacor dependency caching logic in ci files --- .github/workflows/ci.yml | 2 +- .github/workflows/release.yml | 19 ++++--------------- .github/workflows/static.yml | 24 ++++++++++-------------- 3 files changed, 15 insertions(+), 30 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1760a9a7..fd127692 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -11,7 +11,7 @@ jobs: test: runs-on: ubuntu-latest steps: - - name: checkout code repository + - name: Checkout uses: actions/checkout@v3 with: fetch-depth: 0 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index d2ce020f..73427de1 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -11,27 +11,16 @@ jobs: timeout-minutes: 15 runs-on: ubuntu-latest steps: - - name: checkout code repository + - name: Checkout uses: actions/checkout@v3 with: fetch-depth: 0 - - name: setup node.js + - name: Setup Node uses: actions/setup-node@v3 with: - node-version: 18 - - - name: Get yarn cache directory path - id: yarn-cache-dir-path - run: echo "::set-output name=dir::$(yarn cache dir)" - - - uses: actions/cache@v1 - id: yarn-cache - with: - path: ${{ steps.yarn-cache-dir-path.outputs.dir }} - key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} - restore-keys: | - ${{ runner.os }}-yarn- + node-version: 18.x + cache: yarn - name: Install dependencies run: yarn install diff --git a/.github/workflows/static.yml b/.github/workflows/static.yml index e4277e4d..afc4e5e9 100644 --- a/.github/workflows/static.yml +++ b/.github/workflows/static.yml @@ -31,27 +31,23 @@ jobs: steps: - name: Checkout uses: actions/checkout@v3 + with: + fetch-depth: 0 - name: Setup Pages uses: actions/configure-pages@v3 - - uses: actions/setup-node@v3 + - name: Setup Node + uses: actions/setup-node@v3 with: - node-version: '18.x' - - - name: Get yarn cache directory path - id: yarn-cache-dir-path - run: echo "::set-output name=dir::$(yarn cache dir)" + node-version: 18.x + cache: yarn - - uses: actions/cache@v1 - id: yarn-cache - with: - path: ${{ steps.yarn-cache-dir-path.outputs.dir }} - key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} - restore-keys: | - ${{ runner.os }}-yarn- + - name: Install dependencies + run: yarn install - - run: yarn install && yarn clean && yarn prepare + - name: build + run: yarn prepare - run: cd ./example/app && yarn install && yarn build:web