Skip to content

Commit

Permalink
feat(all): 🎸 增加 js-plugins
Browse files Browse the repository at this point in the history
  • Loading branch information
Maidang1 committed Sep 24, 2024
1 parent 298e851 commit b5e4446
Show file tree
Hide file tree
Showing 482 changed files with 3,366 additions and 2,011 deletions.
59 changes: 45 additions & 14 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ jobs:
build:
name: Build and Upload Artifacts - ${{ matrix.settings.abi }}
runs-on: ${{ matrix.settings.os }}
if: contains(github.event.head_commit.message, 'rust-plugins') || contains(github.event.head_commit.message, 'all')
strategy:
fail-fast: false
matrix:
Expand All @@ -17,7 +18,10 @@ jobs:
set -e &&
unset CC_x86_64_unknown_linux_gnu &&
unset CC &&
pnpm --filter "[HEAD^]" --sequential build --target x86_64-unknown-linux-gnu --abi linux-x64-gnu
for package in $rust_changed_packages; do
echo "@farmfe/plugin-$package"
pnpm --filter "@farmfe/plugin-$package" build --target x86_64-unknown-linux-gnu --abi linux-x64-gnu
done
- os: ubuntu-latest
docker: ghcr.io/napi-rs/napi-rs/nodejs-rust:lts-alpine
abi: linux-x64-musl
Expand All @@ -26,7 +30,10 @@ jobs:
set -e &&
unset CC_x86_64_unknown_linux_musl &&
unset CC &&
pnpm --filter "[HEAD^]" --sequential build --target x86_64-unknown-linux-musl --abi linux-x64-musl
for package in $rust_changed_packages; do
echo "@farmfe/plugin-$package"
pnpm --filter "@farmfe/plugin-$package" build --target x86_64-unknown-linux-musl --abi linux-x64-musl
done
- os: windows-latest
abi: win32-x64-msvc
- os: macos-latest
Expand All @@ -41,15 +48,21 @@ jobs:
build: |
export CARGO_PROFILE_RELEASE_LTO=false
cargo install cargo-xwin --locked
pnpm --filter "[HEAD^]" --sequential build --target i686-pc-windows-msvc --abi win32-ia32-msvc --cargo-flags="--no-default-features"
for package in $rust_changed_packages; do
echo "@farmfe/plugin-$package"
pnpm --filter "@farmfe/plugin-$package" build --target i686-pc-windows-msvc --abi win32-ia32-msvc --cargo-flags="--no-default-features"
done
- os: windows-latest
abi: win32-arm64-msvc
target: aarch64-pc-windows-msvc
build: |
export CARGO_PROFILE_RELEASE_CODEGEN_UNITS=256
export CARGO_PROFILE_RELEASE_LTO=false
cargo install cargo-xwin --locked
pnpm --filter "[HEAD^]" --sequential build --target aarch64-pc-windows-msvc --abi win32-arm64-msvc --cargo-flags="--no-default-features"
for package in $rust_changed_packages; do
echo "@farmfe/plugin-$package"
pnpm --filter "@farmfe/plugin-$package" build --target aarch64-pc-windows-msvc --abi win32-arm64-msvc --cargo-flags="--no-default-features"
done
# linux
- os: ubuntu-latest
abi: linux-arm64-musl
Expand All @@ -67,6 +80,21 @@ jobs:
uses: Swatinem/rust-cache@v2
with:
shared-key: rust-build-${{ matrix.settings.abi }}

- name: Get changed packages
id: get_changed_packages
run: |
if [ "${{ matrix.os }}" == "windows-latest" ]; then
$RUST_CHANGED_PACKAGES = git diff --name-only HEAD HEAD~1 | findstr /R /C:"^rust-plugins/" /C:"^packages/" | for /F "tokens=2 delims=/" %i in ('sort /unique') do @echo %i
$RUST_CHANGED_PACKAGES = echo %RUST_CHANGED_PACKAGES:~0,-1%
echo "rust_changed_packages=$RUST_CHANGED_PACKAGES" >> $env:GITHUB_ENV
else
RUST_ORIGIN_CHANGED_PACKAGES=$(git diff --name-only HEAD HEAD~1 | grep -E '^(rust-plugins|packages)/' | awk -F'/' '{print $2}' | sort -u)
RUST_CHANGED_PACKAGES=$(echo "$RUST_CHANGED_PACKAGES" | paste -sd " " -)
echo "rust_changed_packages=$RUST_CHANGED_PACKAGES" >> "$GITHUB_ENV"
fi
- uses: actions/setup-node@v3
with:
node-version: 18
Expand All @@ -92,7 +120,10 @@ jobs:
- name: Default Build
if: ${{ !matrix.settings.docker && !matrix.settings.build }}
run: >-
pnpm --filter "[HEAD^]" --sequential build --abi ${{ matrix.settings.abi }} ${{ matrix.settings.target && format('--target {0}', matrix.settings.target) || '' }} ${{ matrix.settings.zig && '--zig' || '' }}
for package in $rust_changed_packages; do
echo "@farmfe/plugin-$package"
pnpm --filter "@farmfe/plugin-$package" build --abi ${{ matrix.settings.abi }} ${{ matrix.settings.target && format('--target {0}', matrix.settings.target) || '' }} ${{ matrix.settings.zig && '--zig' || '' }}
done
shell: bash
- name: Build
if: ${{ !matrix.settings.docker && matrix.settings.build }}
Expand All @@ -102,53 +133,53 @@ jobs:
uses: actions/upload-artifact@v3
with:
name: ${{ github.sha }}-${{ matrix.settings.abi }}-dsv
path: ./packages/dsv/npm/${{ matrix.settings.abi }}/index.farm
path: ./rust-plugins/dsv/npm/${{ matrix.settings.abi }}/index.farm
if-no-files-found: ignore
- name: Upload Plugin react-components
uses: actions/upload-artifact@v3
with:
name: ${{ github.sha }}-${{ matrix.settings.abi }}-react-components
path: ./packages/react-components/npm/${{ matrix.settings.abi }}/index.farm
path: ./rust-plugins/react-components/npm/${{ matrix.settings.abi }}/index.farm
if-no-files-found: ignore
- name: Upload Plugin virtual
uses: actions/upload-artifact@v3
with:
name: ${{ github.sha }}-${{ matrix.settings.abi }}-virtual
path: ./packages/virtual/npm/${{ matrix.settings.abi }}/index.farm
path: ./rust-plugins/virtual/npm/${{ matrix.settings.abi }}/index.farm
if-no-files-found: ignore
- name: Upload Plugin yaml
uses: actions/upload-artifact@v3
with:
name: ${{ github.sha }}-${{ matrix.settings.abi }}-yaml
path: ./packages/yaml/npm/${{ matrix.settings.abi }}/index.farm
path: ./rust-plugins/yaml/npm/${{ matrix.settings.abi }}/index.farm
if-no-files-found: ignore
- name: Upload Plugin strip
uses: actions/upload-artifact@v3
with:
name: ${{ github.sha }}-${{ matrix.settings.abi }}-strip
path: ./packages/strip/npm/${{ matrix.settings.abi }}/index.farm
path: ./rust-plugins/strip/npm/${{ matrix.settings.abi }}/index.farm
if-no-files-found: ignore
- name: Upload Plugin image
uses: actions/upload-artifact@v3
with:
name: ${{ github.sha }}-${{ matrix.settings.abi }}-image
path: ./packages/image/npm/${{ matrix.settings.abi }}/index.farm
path: ./rust-plugins/image/npm/${{ matrix.settings.abi }}/index.farm
if-no-files-found: ignore
- name: Upload Plugin url
uses: actions/upload-artifact@v3
with:
name: ${{ github.sha }}-${{ matrix.settings.abi }}-url
path: ./packages/url/npm/${{ matrix.settings.abi }}/index.farm
path: ./rust-plugins/url/npm/${{ matrix.settings.abi }}/index.farm
if-no-files-found: ignore
- name: Upload Plugin icons
uses: actions/upload-artifact@v3
with:
name: ${{ github.sha }}-${{ matrix.settings.abi }}-icons
path: ./packages/icons/npm/${{ matrix.settings.abi }}/index.farm
path: ./rust-plugins/icons/npm/${{ matrix.settings.abi }}/index.farm
if-no-files-found: ignore
- name: Upload Plugin auto-import
uses: actions/upload-artifact@v3
with:
name: ${{ github.sha }}-${{ matrix.settings.abi }}-auto-import
path: ./packages/auto-import/npm/${{ matrix.settings.abi }}/index.farm
path: ./rust-plugins/auto-import/npm/${{ matrix.settings.abi }}/index.farm
if-no-files-found: ignore
2 changes: 2 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,5 @@ on:
jobs:
call-rust-build:
uses: ./.github/workflows/plugin-build.yaml
call-js-build:
uses: ./.github/workflows/js-plugin-build.yaml
29 changes: 0 additions & 29 deletions .github/workflows/commit-lint.yaml

This file was deleted.

42 changes: 42 additions & 0 deletions .github/workflows/js-plugin-build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: PR build plugins
on: workflow_call

jobs:
build:
if: github.event_name == 'pull_request' && (contains(github.event.pull_request.title, 'js-plugins') || contains(github.event.pull_request.title, 'all'))
runs-on: ubuntu-latest
name: release
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 2
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: 20
registry-url: https://registry.npmjs.org/

- name: Enable Corepack
id: pnpm-setup
run: |
corepack enable
- name: Initliaze .npmrc
run: >
echo -e "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}\n$(cat .npmrc)" > .npmrc
&& cat -n .npmrc
- name: pnpm install
run: pnpm install --frozen-lockfile

- name: Get changed packages
id: get_changed_packages
run: |
JS_CHANGED_PACKAGES=$(git diff --name-only HEAD HEAD~1 | grep -E '^(js-plugins)/' | awk -F'/' '{print $2}' | sort -u)
echo "js_changed_packages=$JS_CHANGED_PACKAGES" >> "$GITHUB_ENV"
- name: Build Packages
run: |
for package in $js_changed_packages; do
pnpm --filter "@farmfe/js-plugin-$package" build
done
83 changes: 78 additions & 5 deletions .github/workflows/plugin-build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ jobs:
build:
name: Build and Upload Artifacts - ${{ matrix.settings.abi }}
runs-on: ${{ matrix.settings.os }}
if: github.event_name == 'pull_request' && contains(github.event.pull_request.title, 'rust-plugins') || contains(github.event.pull_request.title, 'all')
strategy:
fail-fast: false
matrix:
Expand All @@ -17,7 +18,9 @@ jobs:
set -e &&
unset CC_x86_64_unknown_linux_gnu &&
unset CC &&
pnpm --filter "[HEAD^]" --sequential build --target x86_64-unknown-linux-gnu --abi linux-x64-gnu
for package in $rust_changed_packages; do
pnpm --filter "@farmfe/plugin-$package" build --target x86_64-unknown-linux-gnu --abi linux-x64-gnu
done
- os: ubuntu-latest
docker: ghcr.io/napi-rs/napi-rs/nodejs-rust:lts-alpine
abi: linux-x64-musl
Expand All @@ -26,7 +29,9 @@ jobs:
set -e &&
unset CC_x86_64_unknown_linux_musl &&
unset CC &&
pnpm --filter "[HEAD^]" --sequential build --target x86_64-unknown-linux-musl --abi linux-x64-musl
for package in $rust_changed_packages; do
pnpm --filter "@farmfe/plugin-$package" build --target x86_64-unknown-linux-musl --abi linux-x64-musl
done
- os: windows-latest
abi: win32-x64-msvc
- os: macos-latest
Expand All @@ -41,15 +46,19 @@ jobs:
build: |
export CARGO_PROFILE_RELEASE_LTO=false
cargo install cargo-xwin --locked
pnpm --filter "[HEAD^]" --sequential build --target i686-pc-windows-msvc --abi win32-ia32-msvc --cargo-flags="--no-default-features"
for package in $rust_changed_packages; do
pnpm --filter "@farmfe/plugin-$package" build --target i686-pc-windows-msvc --abi win32-ia32-msvc --cargo-flags="--no-default-features"
done
- os: windows-latest
abi: win32-arm64-msvc
target: aarch64-pc-windows-msvc
build: |
export CARGO_PROFILE_RELEASE_CODEGEN_UNITS=256
export CARGO_PROFILE_RELEASE_LTO=false
cargo install cargo-xwin --locked
pnpm --filter "[HEAD^]" --sequential build --target aarch64-pc-windows-msvc --abi win32-arm64-msvc --cargo-flags="--no-default-features"
for package in $rust_changed_packages; do
pnpm --filter "@farmfe/plugin-$package" build --target aarch64-pc-windows-msvc --abi win32-arm64-msvc --cargo-flags="--no-default-features"
done
# linux
- os: ubuntu-latest
abi: linux-arm64-musl
Expand All @@ -67,6 +76,14 @@ jobs:
uses: Swatinem/rust-cache@v2
with:
shared-key: rust-build-${{ matrix.settings.abi }}

- name: Get changed packages
id: get_rust_changed_packages
run: |
RUST_ORIGIN_CHANGED_PACKAGES=$(git diff --name-only HEAD HEAD~1 | grep -E '^(rust-plugins|packages)/' | awk -F'/' '{print $2}' | sort -u)
RUST_CHANGED_PACKAGES=$(echo "$RUST_CHANGED_PACKAGES" | paste -sd " " -)
echo "rust_changed_packages=$RUST_CHANGED_PACKAGES" >> "$GITHUB_ENV"
- uses: actions/setup-node@v3
with:
node-version: 18
Expand All @@ -92,9 +109,65 @@ jobs:
- name: Default Build
if: ${{ !matrix.settings.docker && !matrix.settings.build }}
run: >-
pnpm --filter "[HEAD^]" --sequential build --abi ${{ matrix.settings.abi }} ${{ matrix.settings.target && format('--target {0}', matrix.settings.target) || '' }} ${{ matrix.settings.zig && '--zig' || '' }}
for package in $rust_changed_packages; do
pnpm --filter "@farmfe/plugin-$package" build --abi ${{ matrix.settings.abi }} ${{ matrix.settings.target && format('--target {0}', matrix.settings.target) || '' }} ${{ matrix.settings.zig && '--zig' || '' }}
done
shell: bash
- name: Build
if: ${{ !matrix.settings.docker && matrix.settings.build }}
run: ${{ matrix.settings.build }}
shell: bash
- name: Upload Plugin dsv
uses: actions/upload-artifact@v3
with:
name: ${{ github.sha }}-${{ matrix.settings.abi }}-dsv
path: ./rust-plugins/dsv/npm/${{ matrix.settings.abi }}/index.farm
if-no-files-found: ignore
- name: Upload Plugin react-components
uses: actions/upload-artifact@v3
with:
name: ${{ github.sha }}-${{ matrix.settings.abi }}-react-components
path: ./rust-plugins/react-components/npm/${{ matrix.settings.abi }}/index.farm
if-no-files-found: ignore
- name: Upload Plugin virtual
uses: actions/upload-artifact@v3
with:
name: ${{ github.sha }}-${{ matrix.settings.abi }}-virtual
path: ./rust-plugins/virtual/npm/${{ matrix.settings.abi }}/index.farm
if-no-files-found: ignore
- name: Upload Plugin yaml
uses: actions/upload-artifact@v3
with:
name: ${{ github.sha }}-${{ matrix.settings.abi }}-yaml
path: ./rust-plugins/yaml/npm/${{ matrix.settings.abi }}/index.farm
if-no-files-found: ignore
- name: Upload Plugin strip
uses: actions/upload-artifact@v3
with:
name: ${{ github.sha }}-${{ matrix.settings.abi }}-strip
path: ./rust-plugins/strip/npm/${{ matrix.settings.abi }}/index.farm
if-no-files-found: ignore
- name: Upload Plugin image
uses: actions/upload-artifact@v3
with:
name: ${{ github.sha }}-${{ matrix.settings.abi }}-image
path: ./rust-plugins/image/npm/${{ matrix.settings.abi }}/index.farm
if-no-files-found: ignore
- name: Upload Plugin url
uses: actions/upload-artifact@v3
with:
name: ${{ github.sha }}-${{ matrix.settings.abi }}-url
path: ./rust-plugins/url/npm/${{ matrix.settings.abi }}/index.farm
if-no-files-found: ignore
- name: Upload Plugin icons
uses: actions/upload-artifact@v3
with:
name: ${{ github.sha }}-${{ matrix.settings.abi }}-icons
path: ./rust-plugins/icons/npm/${{ matrix.settings.abi }}/index.farm
if-no-files-found: ignore
- name: Upload Plugin auto-import
uses: actions/upload-artifact@v3
with:
name: ${{ github.sha }}-${{ matrix.settings.abi }}-auto-import
path: ./rust-plugins/auto-import/npm/${{ matrix.settings.abi }}/index.farm
if-no-files-found: ignore
Loading

0 comments on commit b5e4446

Please sign in to comment.