Skip to content

Commit

Permalink
Merge branch 'v2-dev' into refactor/preview-server
Browse files Browse the repository at this point in the history
  • Loading branch information
fu050409 authored Nov 5, 2024
2 parents edfdbe9 + 20ab467 commit 24dfd4b
Show file tree
Hide file tree
Showing 50 changed files with 638 additions and 536 deletions.
5 changes: 5 additions & 0 deletions .changeset/sharp-pugs-lie.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@farmfe/runtime-plugin-hmr": major
---

optimize runtime-hmr size
237 changes: 166 additions & 71 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -1,18 +1,153 @@
name: Nightly Release CI
name: E2E Tests
on:
push:
pull_request:
branches:
- main
- v2-dev

permissions:
contents: write
pull-requests: write
packages: write

jobs:
call-rust-build:
uses: ./.github/workflows/rust-build.yaml

examples-test:
name: Examples Test
runs-on: ${{ matrix.settings.os }}
needs: [call-rust-build]
strategy:
fail-fast: false
matrix:
settings:
- os: ubuntu-latest
abi: linux-x64-gnu
- os: macos-latest
abi: darwin-arm64
- os: macos-13
abi: darwin-x64
- os: windows-latest
abi: win32-x64-msvc
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 18
- name: Install Dependencies
run: npm install -g [email protected] && pnpm i --frozen-lockfile

- uses: actions/download-artifact@v4
id: download
with:
name: ${{ github.sha }}-${{ matrix.settings.abi }}
path: ./packages/core/binding

- uses: actions/download-artifact@v4
id: download-plugin-sass
with:
name: ${{ github.sha }}-${{ matrix.settings.abi }}-plugin-sass
path: ./rust-plugins/sass/npm/${{ matrix.settings.abi }}

- uses: actions/download-artifact@v4
id: download-plugin-react
with:
name: ${{ github.sha }}-${{ matrix.settings.abi }}-plugin-react
path: ./rust-plugins/react/npm/${{ matrix.settings.abi }}

- uses: actions/download-artifact@v4
id: download-plugin-replace-dirname
with:
name: ${{ github.sha }}-${{ matrix.settings.abi }}-plugin-replace-dirname
path: ./rust-plugins/replace-dirname/npm/${{ matrix.settings.abi }}

- uses: actions/download-artifact@v4
id: download-create-farm-rust
with:
name: ${{ github.sha }}-${{ matrix.settings.abi }}
path: ./packages/create-farm

- name: Build Examples - ${{ matrix.settings.abi }}
run: node scripts/test-examples.mjs

- name: E2E Test Examples - ${{ matrix.settings.abi }}
run: npm run test-e2e

# test create farm
- name: Build Create Farm
run: cd packages/create-farm && npm run build
- name: Test Create Farm React - ${{ matrix.settings.abi }}
run: cd .. && node farm/packages/create-farm/create-farm.js my-test-app-react --template react && cd my-test-app-react && pnpm i && pnpm build
- name: Test Create Farm Vue - ${{ matrix.settings.abi }}
run: cd .. && node farm/packages/create-farm/create-farm.js my-test-app-vue --template vue3 && cd my-test-app-vue && pnpm i && pnpm build
- name: Test Create Farm Solid - ${{ matrix.settings.abi }}
run: cd .. && node farm/packages/create-farm/create-farm.js my-test-app-solid --template solid && cd my-test-app-solid && pnpm i && pnpm build
- name: Test Create Farm Svelte - ${{ matrix.settings.abi }}
run: cd .. && node farm/packages/create-farm/create-farm.js my-test-app-svelte --template svelte && cd my-test-app-svelte && pnpm i && pnpm build
- name: Test Create Farm Lit - ${{ matrix.settings.abi }}
run: cd .. && node farm/packages/create-farm/create-farm.js my-test-app-lit --template lit && cd my-test-app-lit && pnpm i && pnpm build
- name: Test Create Farm Vanilla - ${{ matrix.settings.abi }}
run: cd .. && node farm/packages/create-farm/create-farm.js my-test-app-vanilla --template vanilla && cd my-test-app-vanilla && pnpm i && pnpm build
- name: Test Create Farm Preact - ${{ matrix.settings.abi }}
run: cd .. && node farm/packages/create-farm/create-farm.js my-test-app-preact --template preact && cd my-test-app-preact && pnpm i && pnpm build
- name: Test Create Farm Vue2 - ${{ matrix.settings.abi }}
run: cd .. && node farm/packages/create-farm/create-farm.js my-test-app-vue2 --template vue2 && cd my-test-app-vue2 && pnpm i && pnpm build

type-check:
name: Type Check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: actions/setup-node@v3
with:
node-version: 18
- name: Install Dependencies
run: npm install -g [email protected] && pnpm i --frozen-lockfile
- name: Build CLI and Core
run: pnpm --filter @farmfe/cli run build
- name: Type Check With Tsc
run: pnpm run --filter "@farmfe/*" type-check
- name: Changesets Check
run: npx changeset status --since=origin/main

ts-test:
name: Typescript Test
runs-on: ${{ matrix.settings.os }}
needs: call-rust-build
strategy:
fail-fast: false
matrix:
settings:
- os: ubuntu-latest
abi: linux-x64-gnu
- os: ubuntu-20.04
abi: linux-x64-gnu
- os: macos-13
abi: darwin-x64
- os: macos-latest
abi: darwin-arm64
- os: windows-latest
abi: win32-x64-msvc
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 18
- name: Install Dependencies
run: npm install -g [email protected] && pnpm i --frozen-lockfile
- name: Build CLI and Core
run: pnpm --filter @farmfe/cli run build
- uses: actions/download-artifact@v4
id: download
with:
name: ${{ github.sha }}-${{ matrix.settings.abi }}
path: ./packages/core/binding
- name: Build Core CJS
run: cd packages/core && pnpm run build:cjs
- name: Test - ${{ matrix.settings.abi }}
run: npm run test
# - name: Setup tmate session
# if: ${{ failure() }}
# uses: mxschmitt/action-tmate@v3

check-core-artifacts:
name: Check Core Artifacts
runs-on: ubuntu-latest
Expand Down Expand Up @@ -54,7 +189,6 @@ jobs:
settings:
- name: plugin-sass
- name: plugin-react
- name: plugin-replace-dirname
steps:
- uses: actions/download-artifact@v4
with:
Expand All @@ -66,72 +200,33 @@ jobs:
test -f /tmp/artifacts/${{ github.sha }}-${abi}-${{ matrix.settings.name }}/index.farm
done
nightly-release:
name: Nightly Release
benchmarks:
needs: [call-rust-build]
runs-on: ubuntu-latest
runs-on: ${{ matrix.settings.os }}
strategy:
fail-fast: false
matrix:
settings:
- os: ubuntu-latest
abi: linux-x64-gnu
steps:
- name: Checkout Repo
uses: actions/checkout@v3

- name: Setup Node.js 18.x
uses: actions/setup-node@v3
with:
node-version: 18.x

# batch download artifacts
- uses: actions/download-artifact@v4
- uses: "actions/checkout@v3"
- uses: actions/setup-node@v3
with:
path: /tmp/artifacts
- name: Copy Farm Core Binary
run: cp /tmp/artifacts/${{ github.sha }}-linux-x64-gnu/* ./packages/core/binding
- name: Move Artifacts
run: |
for abi in linux-x64-gnu linux-x64-musl darwin-x64 win32-x64-msvc linux-arm64-musl linux-arm64-gnu darwin-arm64 win32-ia32-msvc win32-arm64-msvc
do
mv /tmp/artifacts/${{ github.sha }}-${abi}/* ./packages/core/npm/${abi}
mv /tmp/artifacts/${{ github.sha }}-${abi}-plugin-react/* ./rust-plugins/react/npm/${abi}
mv /tmp/artifacts/${{ github.sha }}-${abi}-plugin-replace-dirname/* ./rust-plugins/replace-dirname/npm/${abi}
mv /tmp/artifacts/${{ github.sha }}-${abi}-plugin-sass/* ./rust-plugins/sass/npm/${abi}
mv /tmp/artifacts/${{ github.sha }}-${abi}-create-farm/* ./packages/create-farm/npm/${abi}
test -f ./packages/core/npm/${abi}/farm.${abi}.node
test -f ./packages/create-farm/npm/${abi}/create-farm.${abi}.node
test -f ./rust-plugins/react/npm/${abi}/index.farm
test -f ./rust-plugins/replace-dirname/npm/${abi}/index.farm
test -f ./rust-plugins/sass/npm/${abi}/index.farm
done
for abi in android-arm-eabi linux-arm-gnueabihf android-arm64
do
mv /tmp/artifacts/${{ github.sha }}-${abi}-create-farm/* ./packages/create-farm/npm/${abi}
test -f ./packages/create-farm/npm/${abi}/create-farm.${abi}.node
done
node-version: 18
- name: Install Dependencies
run: npm install -g [email protected] && pnpm i --frozen-lockfile
- name: Build Plugin Tools
run: pnpm --filter @farmfe/plugin-tools run build

- name: Create Nightly Release Pull Request or Publish Nightly Version to npm
id: changesets
uses: changesets/action@v1
run: npm install -g [email protected] && pnpm i --frozen-lockfile
- name: Build CLI and Core
run: pnpm --filter @farmfe/cli run build
- uses: actions/download-artifact@v4
id: download
with:
version: pnpm run bump:nightly
publish: npm run release:nightly
branch: v2-dev
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}

# - name: Comment PR
# uses: actions/github-script@v6
# if: success()
name: ${{ github.sha }}-${{ matrix.settings.abi }}
path: ./packages/core/binding
- name: Build Core CJS
run: cd packages/core && pnpm run build:cjs
# - name: Run benchmarks
# uses: CodSpeedHQ/action@v3
# with:
# github-token: ${{secrets.GITHUB_TOKEN}}
# script: |
# github.rest.issues.createComment({
# issue_number: context.issue.number,
# owner: context.repo.owner,
# repo: context.repo.repo,
# body: '🎉 Nightly version has been published to npm!'
# })
# run: npm exec vitest bench
# token: ${{ secrets.CODSPEED_TOKEN }}
2 changes: 1 addition & 1 deletion .github/workflows/code-spell-check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:

- uses: actions/setup-node@v3
with:
node-version: '18'
node-version: "18"
- name: Install pnpm
run: npm install -g [email protected]
- name: pnpm install
Expand Down
12 changes: 12 additions & 0 deletions .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,15 @@ jobs:
run: cargo fmt
- name: Run cargo clippy
run: cargo clippy
lint:
name: TS Code Lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 18
- name: Install Dependencies
run: npm install -g [email protected] && pnpm i --frozen-lockfile
- name: Run lint
run: npx biome check --no-errors-on-unmatched --files-ignore-unknown=true
9 changes: 5 additions & 4 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout Repo
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Setup Node.js 18.x
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: 18.x

Expand Down Expand Up @@ -58,8 +58,9 @@ jobs:
id: changesets
uses: changesets/action@v1
with:
version: pnpm run bump
publish: npm run release
version: ${{ github.ref_name == 'v2-dev' && 'pnpm run bump:nightly' || 'pnpm run bump' }}
publish: ${{ github.ref_name == 'v2-dev' && 'npm run release:nightly' || 'npm run release' }}
branch: ${{ github.ref_name == 'v2-dev' && 'v2-dev' || 'main' }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/rust-build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ jobs:
uses: actions/setup-node@v4
with:
node-version: 18
cache: 'pnpm'
cache: "pnpm"
- name: Install Dependencies
run: pnpm i --frozen-lockfile

Expand All @@ -137,7 +137,7 @@ jobs:
if: ${{ matrix.settings.osxcross }}
# This builds executables & sets env variables for rust to consume.
with:
osx-version: '12.3'
osx-version: "12.3"
- uses: goto-bus-stop/setup-zig@v2
if: ${{ matrix.settings.zig }}
with:
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/rust-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ on:
pull_request:
branches:
- main
- v2-dev

jobs:
cargo-check:
Expand Down
2 changes: 1 addition & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"biome.enabled": true,
"editor.defaultFormatter": "biomejs.biome",
"[typescript]": {
"editor.defaultFormatter": "vscode.typescript-language-features"
"editor.defaultFormatter": "biomejs.biome"
},
"[javascript]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
Expand Down
Loading

0 comments on commit 24dfd4b

Please sign in to comment.