Skip to content

Commit

Permalink
test: fix wasm mocker
Browse files Browse the repository at this point in the history
Signed-off-by: Zxilly <[email protected]>
  • Loading branch information
Zxilly committed Sep 16, 2024
1 parent a07a517 commit 2e8f610
Show file tree
Hide file tree
Showing 7 changed files with 399 additions and 530 deletions.
44 changes: 44 additions & 0 deletions .github/actions/setup-ui-deps/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: Setup UI dependencies
description: 'Setup UI dependencies for linting and testing'
runs:
using: 'composite'
steps:
- name: Set up Node.js
uses: actions/setup-node@1e60f620b9541d16bece96c5465dc8ee9832be0b # v4.0.3
with:
node-version: '22'

- name: Set up pnpm
uses: pnpm/action-setup@fe02b34f77f8bc703788d5817da081398fad5dd2 # v4.0.0
with:
package_json_file: 'ui/package.json'
version: latest

- name: Print pnpm version
shell: bash
run: pnpm --version

- name: Get pnpm store directory
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
- uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2
name: Setup pnpm cache
with:
path: ${{ env.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
- name: Upload lockfile
uses: actions/upload-artifact@50769540e7f4bd5e21e526ee35c689e35e0d6874 # v4.4.0
with:
name: pnpm-lock
path: ui/pnpm-lock.yaml

- name: Install node dependencies
shell: bash
working-directory: ./ui
run: |
pnpm install --frozen-lockfile
29 changes: 1 addition & 28 deletions .github/workflows/build-webui.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,34 +25,7 @@ jobs:
with:
fetch-depth: 0

- name: Set up Node.js
uses: actions/setup-node@1e60f620b9541d16bece96c5465dc8ee9832be0b # v4.0.3
with:
node-version: '21'

- name: Set up pnpm
uses: pnpm/action-setup@fe02b34f77f8bc703788d5817da081398fad5dd2 # v4.0.0
with:
standalone: true
package_json_file: 'ui/package.json'
version: latest

- name: Get pnpm store directory
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
- uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2
name: Setup pnpm cache
with:
path: ${{ env.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
- name: Install dependencies
working-directory: ./ui
run: pnpm install
- uses: ./.github/actions/setup-ui-deps

- name: Build
working-directory: ./ui
Expand Down
55 changes: 2 additions & 53 deletions .github/workflows/built-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -183,30 +183,7 @@ jobs:
with:
fetch-depth: 0

- name: Set up Node.js
uses: actions/setup-node@1e60f620b9541d16bece96c5465dc8ee9832be0b # v4.0.3
with:
node-version: '22'

- name: Set up pnpm
uses: pnpm/action-setup@fe02b34f77f8bc703788d5817da081398fad5dd2 # v4.0.0
with:
standalone: true
package_json_file: 'ui/package.json'
version: latest

- name: Get pnpm store directory
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
- uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2
name: Setup pnpm cache
with:
path: ${{ env.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
- uses: ./.github/actions/setup-ui-deps

- name: Install dependencies
working-directory: ./ui
Expand Down Expand Up @@ -254,35 +231,7 @@ jobs:
with:
fetch-depth: 0

- name: Set up Node.js
uses: actions/setup-node@1e60f620b9541d16bece96c5465dc8ee9832be0b # v4.0.3
with:
node-version: '21'

- name: Set up pnpm
uses: pnpm/action-setup@fe02b34f77f8bc703788d5817da081398fad5dd2 # v4.0.0
with:
standalone: true
package_json_file: 'ui/package.json'
version: latest

- name: Get pnpm store directory
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
- uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2
name: Setup pnpm cache
with:
path: ${{ env.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
- name: Install node dependencies
working-directory: ./ui
run: |
pnpm install
- uses: ./.github/actions/setup-ui-deps

- name: Download WASM
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8
Expand Down
29 changes: 1 addition & 28 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,34 +22,7 @@ jobs:
- name: Checkout code
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7

- name: Set up Node.js
uses: actions/setup-node@1e60f620b9541d16bece96c5465dc8ee9832be0b # v4.0.3
with:
node-version: '21'

- name: Set up pnpm
uses: pnpm/action-setup@fe02b34f77f8bc703788d5817da081398fad5dd2 # v4.0.0
with:
standalone: true
package_json_file: 'ui/package.json'
version: latest

- name: Get pnpm store directory
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
- uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2
name: Setup pnpm cache
with:
path: ${{ env.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
- name: Install dependencies
working-directory: ./ui
run: pnpm install
- uses: ./.github/actions/setup-ui-deps

- name: Run ESLint
working-directory: ./ui
Expand Down
4 changes: 3 additions & 1 deletion ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
"devDependencies": {
"@antfu/eslint-config": "^3.6.2",
"@codecov/vite-plugin": "1.0.1",
"@eslint-react/eslint-plugin": "^1.14.1",
"@microsoft/eslint-formatter-sarif": "^3.1.0",
"@testing-library/dom": "^10.4.0",
"@testing-library/jest-dom": "^6.5.0",
Expand Down Expand Up @@ -59,7 +60,8 @@
"vite": "^5.4.5",
"vite-plugin-html": "^3.2.2",
"vite-plugin-singlefile": "^2.0.2",
"vitest": "^2.1.1"
"vitest": "^2.1.1",
"vitest-fetch-mock": "^0.3.0"
},
"pnpm": {
"peerDependencyRules": {
Expand Down
Loading

0 comments on commit 2e8f610

Please sign in to comment.