replace yarn with pnpm (#85)

* 🐳 chore: replace yarn with pnpm
This commit is contained in:
m1m1sha
2024-05-07 22:40:09 +08:00
committed by GitHub
parent 8440eb842b
commit 1280e1dde2
5 changed files with 2223 additions and 1848 deletions
+214 -182
View File
@@ -2,9 +2,9 @@ name: Rust
on: on:
push: push:
branches: [ "develop", "main" ] branches: ["develop", "main"]
pull_request: pull_request:
branches: [ "develop", "main" ] branches: ["develop", "main"]
env: env:
CARGO_TERM_COLOR: always CARGO_TERM_COLOR: always
@@ -32,12 +32,14 @@ jobs:
- TARGET: mipsel-unknown-linux-musl - TARGET: mipsel-unknown-linux-musl
OS: ubuntu-latest OS: ubuntu-latest
GUI_TARGET: GUI_TARGET:
- TARGET: x86_64-apple-darwin - TARGET: x86_64-apple-darwin
OS: macos-latest OS: macos-latest
GUI_TARGET: x86_64-apple-darwin GUI_TARGET: x86_64-apple-darwin
- TARGET: aarch64-apple-darwin - TARGET: aarch64-apple-darwin
OS: macos-latest OS: macos-latest
GUI_TARGET: aarch64-apple-darwin GUI_TARGET: aarch64-apple-darwin
- TARGET: x86_64-pc-windows-msvc - TARGET: x86_64-pc-windows-msvc
OS: windows-latest OS: windows-latest
GUI_TARGET: x86_64-pc-windows-msvc GUI_TARGET: x86_64-pc-windows-msvc
@@ -49,103 +51,131 @@ jobs:
GUI_TARGET: ${{ matrix.GUI_TARGET }} GUI_TARGET: ${{ matrix.GUI_TARGET }}
OSS_BUCKET: ${{ secrets.ALIYUN_OSS_BUCKET }} OSS_BUCKET: ${{ secrets.ALIYUN_OSS_BUCKET }}
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v3
- name: Setup protoc
uses: arduino/setup-protoc@v2 - uses: actions/setup-node@v4
with: with:
# GitHub repo token to use to avoid rate limiter node-version: 21
repo-token: ${{ secrets.GITHUB_TOKEN }}
- uses: actions/setup-node@v4 - name: Install pnpm
with: uses: pnpm/action-setup@v3
node-version: 21 with:
cache: 'yarn' version: 9
cache-dependency-path: easytier-gui/yarn.lock run_install: false
- name: Install Yarn
run: npm install -g yarn - name: Get pnpm store directory
- name: Cargo cache shell: bash
uses: actions/cache@v4.0.0 run: |
with: echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
path: |
~/.cargo - name: Setup pnpm cache
./target uses: actions/cache@v4
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} with:
- name: Install rust target path: ${{ env.STORE_PATH }}
run: | key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
# dependencies are only needed on ubuntu as that's the only place where restore-keys: |
# we make cross-compilation ${{ runner.os }}-pnpm-store-
if [[ $OS =~ ^ubuntu.*$ ]]; then
sudo apt-get update && sudo apt-get install -qq crossbuild-essential-arm64 crossbuild-essential-armhf musl-tools - name: Install frontend dependencies
# for easytier-gui run: |
sudo apt install libwebkit2gtk-4.0-dev \ cd easytier-gui
build-essential \ pnpm install
curl \
wget \ - name: Cargo cache
file \ uses: actions/cache@v4
libssl-dev \ with:
libgtk-3-dev \ path: |
libayatana-appindicator3-dev \ ~/.cargo
librsvg2-dev ./target
# curl -s musl.cc | grep mipsel key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
case $TARGET in
mipsel-unknown-linux-musl) - name: Install rust target
MUSL_URI=mipsel-linux-muslsf run: |
;; # dependencies are only needed on ubuntu as that's the only place where
aarch64-unknown-linux-musl) # we make cross-compilation
MUSL_URI=aarch64-linux-musl if [[ $OS =~ ^ubuntu.*$ ]]; then
;; sudo apt-get update && sudo apt-get install -qq crossbuild-essential-arm64 crossbuild-essential-armhf musl-tools
armv7-unknown-linux-musleabihf) # for easytier-gui
MUSL_URI=armv7l-linux-musleabihf if [[ $GUI_TARGET != '' ]]; then
;; sudo apt install libwebkit2gtk-4.0-dev \
arm-unknown-linux-musleabihf) build-essential \
MUSL_URI=arm-linux-musleabihf curl \
;; wget \
mips-unknown-linux-musl) file \
MUSL_URI=mips-linux-muslsf libssl-dev \
;; libgtk-3-dev \
esac libayatana-appindicator3-dev \
librsvg2-dev \
if [ -n "$MUSL_URI" ]; then patchelf
mkdir -p ./musl_gcc fi
wget -c https://musl.cc/${MUSL_URI}-cross.tgz -P ./musl_gcc/ # curl -s musl.cc | grep mipsel
tar zxf ./musl_gcc/${MUSL_URI}-cross.tgz -C ./musl_gcc/ case $TARGET in
sudo ln -s $(pwd)/musl_gcc/${MUSL_URI}-cross/bin/*gcc /usr/bin/ mipsel-unknown-linux-musl)
MUSL_URI=mipsel-linux-muslsf
;;
aarch64-unknown-linux-musl)
MUSL_URI=aarch64-linux-musl
;;
armv7-unknown-linux-musleabihf)
MUSL_URI=armv7l-linux-musleabihf
;;
arm-unknown-linux-musleabihf)
MUSL_URI=arm-linux-musleabihf
;;
mips-unknown-linux-musl)
MUSL_URI=mips-linux-muslsf
;;
esac
if [ -n "$MUSL_URI" ]; then
mkdir -p ./musl_gcc
wget -c https://musl.cc/${MUSL_URI}-cross.tgz -P ./musl_gcc/
tar zxf ./musl_gcc/${MUSL_URI}-cross.tgz -C ./musl_gcc/
sudo ln -s $(pwd)/musl_gcc/${MUSL_URI}-cross/bin/*gcc /usr/bin/
fi
fi fi
fi
# see https://github.com/rust-lang/rustup/issues/3709
rustup set auto-self-update disable
rustup install 1.75
rustup default 1.75
# mips/mipsel cannot add target from rustup, need compile by ourselves # see https://github.com/rust-lang/rustup/issues/3709
if [[ $OS =~ ^ubuntu.*$ && $TARGET =~ ^mips.*$ ]]; then rustup set auto-self-update disable
cd "$PWD/musl_gcc/${MUSL_URI}-cross/lib/gcc/${MUSL_URI}/11.2.1" || exit 255 rustup install 1.75
# for panic-abort rustup default 1.75
cp libgcc_eh.a libunwind.a
# for mimalloc # mips/mipsel cannot add target from rustup, need compile by ourselves
ar x libgcc.a _ctzsi2.o _clz.o if [[ $OS =~ ^ubuntu.*$ && $TARGET =~ ^mips.*$ ]]; then
ar rcs libctz.a _ctzsi2.o _clz.o cd "$PWD/musl_gcc/${MUSL_URI}-cross/lib/gcc/${MUSL_URI}/11.2.1" || exit 255
# for panic-abort
cp libgcc_eh.a libunwind.a
rustup toolchain install nightly-x86_64-unknown-linux-gnu # for mimalloc
rustup component add rust-src --toolchain nightly-x86_64-unknown-linux-gnu ar x libgcc.a _ctzsi2.o _clz.o
cd - ar rcs libctz.a _ctzsi2.o _clz.o
else
rustup target add $TARGET
rustup target add $GUI_TARGET
fi
- name: Run build
run: |
if [[ $OS =~ ^ubuntu.*$ && $TARGET =~ ^mips.*$ ]]; then
cargo +nightly build -r --verbose --target $TARGET -Z build-std --no-default-features --features mips
else
cargo build --release --verbose --target $TARGET
fi
- name: Install for aarch64 gui cross compile
run: |
# see https://tauri.app/v1/guides/building/linux/
if [[ $TARGET == "aarch64-unknown-linux-musl" ]]; then
rustup toolchain install nightly-x86_64-unknown-linux-gnu
rustup component add rust-src --toolchain nightly-x86_64-unknown-linux-gnu
cd -
else
rustup target add $TARGET
rustup target add $GUI_TARGET
fi
- name: Setup protoc
uses: arduino/setup-protoc@v2
with:
# GitHub repo token to use to avoid rate limiter
repo-token: ${{ secrets.GITHUB_TOKEN }}
- name: Build Core & Cli
run: |
if [[ $OS =~ ^ubuntu.*$ && $TARGET =~ ^mips.*$ ]]; then
cargo +nightly build -r --verbose --target $TARGET -Z build-std --no-default-features --features mips
else
cargo build --release --verbose --target $TARGET
fi
- name: Install GUI cross compile (aarch64 only)
if: ${{ matrix.TARGET == 'aarch64-unknown-linux-musl' }}
run: |
# see https://tauri.app/v1/guides/building/linux/
echo "deb [arch=amd64] http://archive.ubuntu.com/ubuntu/ jammy main restricted" | sudo tee /etc/apt/sources.list echo "deb [arch=amd64] http://archive.ubuntu.com/ubuntu/ jammy main restricted" | sudo tee /etc/apt/sources.list
echo "deb [arch=amd64] http://archive.ubuntu.com/ubuntu/ jammy-updates main restricted" | sudo tee -a /etc/apt/sources.list echo "deb [arch=amd64] http://archive.ubuntu.com/ubuntu/ jammy-updates main restricted" | sudo tee -a /etc/apt/sources.list
echo "deb [arch=amd64] http://archive.ubuntu.com/ubuntu/ jammy universe" | sudo tee -a /etc/apt/sources.list echo "deb [arch=amd64] http://archive.ubuntu.com/ubuntu/ jammy universe" | sudo tee -a /etc/apt/sources.list
@@ -173,96 +203,98 @@ jobs:
sudo apt install libwebkit2gtk-4.0-dev:arm64 sudo apt install libwebkit2gtk-4.0-dev:arm64
sudo apt install libssl-dev:arm64 sudo apt install libssl-dev:arm64
echo "PKG_CONFIG_SYSROOT_DIR=/usr/aarch64-linux-gnu/" >> "$GITHUB_ENV" echo "PKG_CONFIG_SYSROOT_DIR=/usr/aarch64-linux-gnu/" >> "$GITHUB_ENV"
fi
- name: Run build GUI
run: |
if [ ! -n "$GUI_TARGET" ]; then
exit 0
fi
cd easytier-gui
yarn install
if [[ $OS =~ ^ubuntu.*$ && ! $GUI_TARGET =~ ^x86_64.*$ ]]; then
# only build deb for non-x86_64 linux
yarn tauri build -- --target $GUI_TARGET --verbose --bundles deb
else
yarn tauri build -- --target $GUI_TARGET --verbose
fi
- name: Compress
run: |
mkdir -p ./artifacts/objects/
# windows is the only OS using a different convention for executable file name
if [[ $OS =~ ^windows.*$ ]]; then
SUFFIX=.exe
cp easytier/third_party/Packet.dll ./artifacts/objects/
cp easytier/third_party/wintun.dll ./artifacts/objects/
fi
if [[ $GITHUB_REF_TYPE =~ ^tag$ ]]; then
TAG=$GITHUB_REF_NAME
else
TAG=$GITHUB_SHA
fi
mv ./target/$TARGET/release/easytier-core"$SUFFIX" ./artifacts/objects/
mv ./target/$TARGET/release/easytier-cli"$SUFFIX" ./artifacts/objects/
# copy gui bundle, gui is built without specific target - name: Build GUI
if [[ $OS =~ ^windows.*$ ]]; then if: ${{ matrix.GUI_TARGET != '' }}
mv ./target/$GUI_TARGET/release/bundle/nsis/*.exe ./artifacts/objects/ uses: tauri-apps/tauri-action@v0
elif [[ $OS =~ ^macos.*$ ]]; then with:
mv ./target/$GUI_TARGET/release/bundle/dmg/*.dmg ./artifacts/objects/ projectPath: ./easytier-gui
elif [[ $OS =~ ^ubuntu.*$ && ! $TARGET =~ ^mips.*$ ]]; then # https://tauri.app/v1/guides/building/linux/#cross-compiling-tauri-applications-for-arm-based-devices
mv ./target/$GUI_TARGET/release/bundle/deb/*.deb ./artifacts/objects/ args: --verbose --target ${{ matrix.GUI_TARGET }} ${{ matrix.OS == 'ubuntu-latest' && contains(matrix.TARGET, 'aarch64') && '--bundles deb' || '' }}
if [[ $GUI_TARGET =~ ^x86_64.*$ ]]; then
# currently only x86 appimage is supported
mv ./target/$GUI_TARGET/release/bundle/appimage/*.AppImage ./artifacts/objects/
fi
fi
tar -cvf ./artifacts/$NAME-$TARGET-$TAG.tar -C ./artifacts/objects/ . - name: Compress
rm -rf ./artifacts/objects/ run: |
- name: Archive artifact mkdir -p ./artifacts/objects/
uses: actions/upload-artifact@v4 # windows is the only OS using a different convention for executable file name
with: if [[ $OS =~ ^windows.*$ ]]; then
name: easytier-${{ matrix.OS }}-${{ matrix.TARGET }} SUFFIX=.exe
path: | cp easytier/third_party/Packet.dll ./artifacts/objects/
./artifacts/* cp easytier/third_party/wintun.dll ./artifacts/objects/
- name: Upload OSS fi
if: ${{ env.OSS_BUCKET != '' }} if [[ $GITHUB_REF_TYPE =~ ^tag$ ]]; then
uses: Menci/upload-to-oss@main TAG=$GITHUB_REF_NAME
with: else
access-key-id: ${{ secrets.ALIYUN_OSS_ACCESS_ID }} TAG=$GITHUB_SHA
access-key-secret: ${{ secrets.ALIYUN_OSS_ACCESS_KEY }} fi
endpoint: ${{ secrets.ALIYUN_OSS_ENDPOINT }} mv ./target/$TARGET/release/easytier-core"$SUFFIX" ./artifacts/objects/
bucket: ${{ secrets.ALIYUN_OSS_BUCKET }} mv ./target/$TARGET/release/easytier-cli"$SUFFIX" ./artifacts/objects/
local-path: ./artifacts/
remote-path: /easytier-releases/${{ github.sha }}/ # copy gui bundle, gui is built without specific target
no-delete-remote-files: true if [[ $OS =~ ^windows.*$ ]]; then
retry: 5 mv ./target/$GUI_TARGET/release/bundle/nsis/*.exe ./artifacts/objects/
elif [[ $OS =~ ^macos.*$ ]]; then
mv ./target/$GUI_TARGET/release/bundle/dmg/*.dmg ./artifacts/objects/
elif [[ $OS =~ ^ubuntu.*$ && ! $TARGET =~ ^mips.*$ ]]; then
mv ./target/$GUI_TARGET/release/bundle/deb/*.deb ./artifacts/objects/
if [[ $GUI_TARGET =~ ^x86_64.*$ ]]; then
# currently only x86 appimage is supported
mv ./target/$GUI_TARGET/release/bundle/appimage/*.AppImage ./artifacts/objects/
fi
fi
tar -cvf ./artifacts/$NAME-$TARGET-$TAG.tar -C ./artifacts/objects/ .
rm -rf ./artifacts/objects/
- name: Archive artifact
uses: actions/upload-artifact@v4
with:
name: easytier-${{ matrix.OS }}-${{ matrix.TARGET }}
path: |
./artifacts/*
- name: Upload OSS
if: ${{ env.OSS_BUCKET != '' }}
uses: Menci/upload-to-oss@main
with:
access-key-id: ${{ secrets.ALIYUN_OSS_ACCESS_ID }}
access-key-secret: ${{ secrets.ALIYUN_OSS_ACCESS_KEY }}
endpoint: ${{ secrets.ALIYUN_OSS_ENDPOINT }}
bucket: ${{ secrets.ALIYUN_OSS_BUCKET }}
local-path: ./artifacts/
remote-path: /easytier-releases/${{ github.sha }}/
no-delete-remote-files: true
retry: 5
test: test:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v3
- name: Setup protoc
uses: arduino/setup-protoc@v2 - name: Setup protoc
with: uses: arduino/setup-protoc@v2
# GitHub repo token to use to avoid rate limiter with:
repo-token: ${{ secrets.GITHUB_TOKEN }} # GitHub repo token to use to avoid rate limiter
- name: Setup tools for test repo-token: ${{ secrets.GITHUB_TOKEN }}
run: sudo apt install bridge-utils
- name: Setup system for test - name: Setup tools for test
run: | run: sudo apt install bridge-utils
sudo sysctl net.bridge.bridge-nf-call-iptables=0
sudo sysctl net.bridge.bridge-nf-call-ip6tables=0 - name: Setup system for test
sudo sysctl net.ipv6.conf.lo.disable_ipv6=0 run: |
sudo ip addr add 2001:db8::2/64 dev lo sudo sysctl net.bridge.bridge-nf-call-iptables=0
- name: Cargo cache sudo sysctl net.bridge.bridge-nf-call-ip6tables=0
uses: actions/cache@v4.0.0 sudo sysctl net.ipv6.conf.lo.disable_ipv6=0
with: sudo ip addr add 2001:db8::2/64 dev lo
path: |
~/.cargo - name: Cargo cache
./target uses: actions/cache@v4
key: ${{ runner.os }}-cargo-test-${{ hashFiles('**/Cargo.lock') }} with:
- name: Run tests path: |
run: | ~/.cargo
sudo -E env "PATH=$PATH" cargo test --verbose ./target
sudo chown -R $USER:$USER ./target key: ${{ runner.os }}-cargo-test-${{ hashFiles('**/Cargo.lock') }}
sudo chown -R $USER:$USER ~/.cargo
- name: Run tests
run: |
sudo -E env "PATH=$PATH" cargo test --verbose
sudo chown -R $USER:$USER ./target
sudo chown -R $USER:$USER ~/.cargo
+2
View File
@@ -0,0 +1,2 @@
shamefully-hoist=true
strict-peer-dependencies=false
+2004
View File
File diff suppressed because it is too large Load Diff
+3 -3
View File
@@ -1,7 +1,7 @@
{ {
"build": { "build": {
"beforeDevCommand": "yarn dev", "beforeDevCommand": "pnpm dev",
"beforeBuildCommand": "yarn build", "beforeBuildCommand": "pnpm build",
"devPath": "http://localhost:1420", "devPath": "http://localhost:1420",
"distDir": "../dist" "distDir": "../dist"
}, },
@@ -46,4 +46,4 @@
] ]
} }
} }
} }
File diff suppressed because it is too large Load Diff