From 690ece07295962cf53d3a76c258f47f5fc00d9a3 Mon Sep 17 00:00:00 2001 From: fi3ework Date: Thu, 10 Oct 2024 14:16:05 +0800 Subject: [PATCH] ci: clean up and lock benchmark node version --- .github/workflows/lint.yml | 4 +- .github/workflows/release-pull-request.yml | 2 +- .github/workflows/release.yml | 2 +- .github/workflows/test-ubuntu.yml | 87 ++++++++++++++++------ .github/workflows/test-windows.yml | 62 ++++++++------- 5 files changed, 102 insertions(+), 55 deletions(-) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 54b52a4be..9b51c54a8 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -30,10 +30,10 @@ jobs: - name: Install Pnpm run: corepack enable - - name: Setup Node.js 18.x + - name: Setup Node.js 18 uses: actions/setup-node@v4 with: - node-version: 18.x + node-version: 18 cache: 'pnpm' - name: Install Dependencies diff --git a/.github/workflows/release-pull-request.yml b/.github/workflows/release-pull-request.yml index e7c76daac..dff433f5c 100644 --- a/.github/workflows/release-pull-request.yml +++ b/.github/workflows/release-pull-request.yml @@ -32,7 +32,7 @@ jobs: - name: Setup Node.js 18 uses: actions/setup-node@v4 with: - node-version: '18' + node-version: 18 cache: 'pnpm' - name: Install Dependencies diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 73e4046e7..a695ecc20 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -40,7 +40,7 @@ jobs: - name: Setup Node.js 18 uses: actions/setup-node@v4 with: - node-version: '18' + node-version: 18 cache: 'pnpm' - name: Install Dependencies diff --git a/.github/workflows/test-ubuntu.yml b/.github/workflows/test-ubuntu.yml index d7dab8e3c..739736ae3 100644 --- a/.github/workflows/test-ubuntu.yml +++ b/.github/workflows/test-ubuntu.yml @@ -16,12 +16,14 @@ on: # A workflow run is made up of one or more jobs that can run sequentially or in parallel jobs: - # ======== ut ======== - ut-ubuntu: + # ======== caculate changes ======== + changes: runs-on: ubuntu-latest + outputs: + changed: ${{ steps.changes.outputs.changed }} strategy: matrix: - node-version: [18.x] + node-version: [18] # Steps represent a sequence of tasks that will be executed as part of the job steps: @@ -44,27 +46,45 @@ jobs: - "!**/_meta.json" - "!**/dictionary.txt" + # ======== ut ======== + ut-ubuntu: + runs-on: ubuntu-latest + needs: changes + if: ${{ needs.changes.outputs.changed == 'true' }} + strategy: + matrix: + node-version: [18, 20, 22] + + # Steps represent a sequence of tasks that will be executed as part of the job + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 10 + + - name: Install Pnpm + run: corepack enable + - name: Setup Node.js ${{ matrix.node-version }} - if: steps.changes.outputs.changed == 'true' uses: actions/setup-node@v4 with: node-version: ${{ matrix.node-version }} cache: 'pnpm' - name: Install Dependencies - if: steps.changes.outputs.changed == 'true' run: pnpm install - name: Unit Test - if: steps.changes.outputs.changed == 'true' run: pnpm run test:unit # ======== integration && e2e ======== integration-e2e-ubuntu: runs-on: ubuntu-latest + needs: changes + if: ${{ needs.changes.outputs.changed == 'true' }} strategy: matrix: - node-version: [18.x] + node-version: [18, 20, 22] # Steps represent a sequence of tasks that will be executed as part of the job steps: @@ -76,40 +96,61 @@ jobs: - name: Install Pnpm run: corepack enable - - uses: dorny/paths-filter@v3 - id: changes - with: - predicate-quantifier: 'every' - filters: | - changed: - - "!**/*.md" - - "!**/*.mdx" - - "!**/_meta.json" - - "!**/dictionary.txt" - - name: Setup Node.js ${{ matrix.node-version }} - if: steps.changes.outputs.changed == 'true' uses: actions/setup-node@v4 with: node-version: ${{ matrix.node-version }} cache: 'pnpm' - name: Install Dependencies - if: steps.changes.outputs.changed == 'true' run: pnpm install && cd ./tests && npx playwright install - name: Integration Test (Vitest) - if: steps.changes.outputs.changed == 'true' run: pnpm run test:integration - name: E2E Test (Playwright) - if: steps.changes.outputs.changed == 'true' run: pnpm run test:e2e # only run benchmark in Ubuntu - name: Benchmarks (Vitest) uses: CodSpeedHQ/action@v3 - if: steps.changes.outputs.changed == 'true' + with: + run: pnpm run test:benchmark + # token retrieved from the CodSpeed app at the previous step + token: ${{ secrets.CODSPEED_TOKEN }} + + # ======== benchmark ======== + benchemark-ubuntu: + runs-on: ubuntu-latest + needs: [integration-e2e-ubuntu] + strategy: + matrix: + # Only Ubuntu 20.04 and 22.04 are supported at the moment. + # See https://github.com/CodSpeedHQ/action/blob/016456b513677f9d4a1c509c7f8a38d8dd55b2b0/.github/workflows/ci.yml#L19. + node-version: [20.04] + + # Steps represent a sequence of tasks that will be executed as part of the job + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 10 + + - name: Install Pnpm + run: corepack enable + + - name: Setup Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v4 + with: + node-version: ${{ matrix.node-version }} + cache: 'pnpm' + + - name: Install Dependencies + run: pnpm install && cd ./tests && npx playwright install + + # only run benchmark in Ubuntu + - name: Benchmarks (Vitest) + uses: CodSpeedHQ/action@v3 with: run: pnpm run test:benchmark # token retrieved from the CodSpeed app at the previous step diff --git a/.github/workflows/test-windows.yml b/.github/workflows/test-windows.yml index 32a5cc547..9438a7bb8 100644 --- a/.github/workflows/test-windows.yml +++ b/.github/workflows/test-windows.yml @@ -16,20 +16,17 @@ on: # A workflow run is made up of one or more jobs that can run sequentially or in parallel jobs: - # ======== ut ======== - ut-windows: + # ======== caculate changes ======== + changes: runs-on: windows-latest + outputs: + changed: ${{ steps.changes.outputs.changed }} strategy: matrix: - node-version: [18.x] + node-version: [18] # Steps represent a sequence of tasks that will be executed as part of the job steps: - - name: Git config - shell: bash - run: | - git config --system core.longpaths true - - name: Checkout uses: actions/checkout@v4 with: @@ -49,27 +46,50 @@ jobs: - "!**/_meta.json" - "!**/dictionary.txt" + # ======== ut ======== + ut-windows: + runs-on: windows-latest + needs: changes + if: ${{ needs.changes.outputs.changed == 'true' }} + strategy: + matrix: + node-version: [18] + + # Steps represent a sequence of tasks that will be executed as part of the job + steps: + - name: Git config + shell: bash + run: | + git config --system core.longpaths true + + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 10 + + - name: Install Pnpm + run: corepack enable + - name: Setup Node.js ${{ matrix.node-version }} - if: steps.changes.outputs.changed == 'true' uses: actions/setup-node@v4 with: node-version: ${{ matrix.node-version }} cache: 'pnpm' - name: Install Dependencies - if: steps.changes.outputs.changed == 'true' run: pnpm install - name: Unit Test - if: steps.changes.outputs.changed == 'true' run: pnpm run test:unit - # # ======== integration && e2e ======== + # ======== integration && e2e ======== integration-e2e-windows: runs-on: windows-latest + needs: changes + if: ${{ needs.changes.outputs.changed == 'true' }} strategy: matrix: - node-version: [18.x] + node-version: [18] # Steps represent a sequence of tasks that will be executed as part of the job steps: @@ -86,31 +106,17 @@ jobs: - name: Install Pnpm run: corepack enable - - uses: dorny/paths-filter@v3 - id: changes - with: - predicate-quantifier: 'every' - filters: | - changed: - - "!**/*.md" - - "!**/*.mdx" - - "!**/_meta.json" - - "!**/dictionary.txt" - - name: Setup Node.js ${{ matrix.node-version }} - if: steps.changes.outputs.changed == 'true' uses: actions/setup-node@v4 with: node-version: ${{ matrix.node-version }} cache: 'pnpm' + - name: Install Dependencies - if: steps.changes.outputs.changed == 'true' run: pnpm install && cd ./tests && npx playwright install - name: Integration Test (Vitest) - if: steps.changes.outputs.changed == 'true' run: pnpm run test:integration - name: E2E Test (Playwright) - if: steps.changes.outputs.changed == 'true' run: pnpm run test:e2e