From 95f3a07d0f5ef68b2c1f5b9bcff6bc98f601c6d7 Mon Sep 17 00:00:00 2001 From: "benjamin.747" Date: Fri, 6 Sep 2024 16:32:31 +0800 Subject: [PATCH 1/2] [action] update workflow file --- .github/workflows/base.yml | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/.github/workflows/base.yml b/.github/workflows/base.yml index 18cf1eebb..a3ec7eb10 100644 --- a/.github/workflows/base.yml +++ b/.github/workflows/base.yml @@ -54,7 +54,8 @@ jobs: libgtk-3-dev \ libayatana-appindicator3-dev \ librsvg2-dev - - run: cargo build + - run: cargo build --bin mega + - run: cargo build --bin libra - run: rustup component add clippy - uses: actions-rs/cargo@v1 with: @@ -118,3 +119,30 @@ jobs: submodules: recursive - run: sudo apt-get update && sudo apt-get install -y fuse3 libfuse3-dev - run: cd ./scorpio && cargo clippy --all-targets --all-features -- -D warnings + + moon-lint-and-build: + name: MOON Lint & Build + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + - name: Set up Node.js + uses: actions/setup-node@v3 + with: + node-version: '22' + cache: 'npm' + cache-dependency-path: ./moon/package.json + + - name: Install dependencies + working-directory: ./moon + run: npm install + + - name: Run ESLint + working-directory: ./moon + run: npm run lint + + - name: Build Next.js application + working-directory: ./moon + run: npm run build From 66fe8665513f09227ea3efdeeb92a1746a63ef5f Mon Sep 17 00:00:00 2001 From: "benjamin.747" Date: Fri, 6 Sep 2024 17:20:41 +0800 Subject: [PATCH 2/2] [action] opimize workflow --- .github/workflows/base.yml | 58 ++++++++----------- moon/src/app/api/user/route.ts | 2 +- .../src/app/api/user/ssh/[id]/delete/route.ts | 2 +- moon/src/app/api/user/ssh/route.ts | 4 +- 4 files changed, 28 insertions(+), 38 deletions(-) diff --git a/.github/workflows/base.yml b/.github/workflows/base.yml index a3ec7eb10..3d25c1d1d 100644 --- a/.github/workflows/base.yml +++ b/.github/workflows/base.yml @@ -11,20 +11,28 @@ on: [push, pull_request] name: Base GitHub Action for Check, Test and Lints jobs: - # - check: - name: Check + setup: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 with: submodules: recursive + - uses: actions-rs/toolchain@v1 with: profile: minimal toolchain: stable override: true - uses: Swatinem/rust-cache@v2 + # + check: + name: Check + runs-on: ubuntu-latest + needs: setup + steps: + - uses: actions/checkout@v3 + with: + submodules: recursive - uses: actions-rs/cargo@v1 with: command: check @@ -33,16 +41,11 @@ jobs: clippy: name: Clippy runs-on: ubuntu-latest + needs: setup steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 with: submodules: recursive - - uses: actions-rs/toolchain@v1 - with: - profile: minimal - toolchain: stable - override: true - - uses: Swatinem/rust-cache@v2 - run: | sudo apt update sudo apt install -y libwebkit2gtk-4.0-dev \ @@ -54,8 +57,10 @@ jobs: libgtk-3-dev \ libayatana-appindicator3-dev \ librsvg2-dev - - run: cargo build --bin mega - - run: cargo build --bin libra + - uses: actions-rs/cargo@v1 + with: + command: build + args: --bin mega --bin libra - run: rustup component add clippy - uses: actions-rs/cargo@v1 with: @@ -66,18 +71,12 @@ jobs: test: name: Tests runs-on: ubuntu-latest + needs: setup steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 with: submodules: recursive - - uses: actions-rs/toolchain@v1 - with: - profile: minimal - toolchain: stable - override: true - - uses: Swatinem/rust-cache@v2 - run: | - sudo apt-get update sudo apt-get install -y git-lfs git lfs install git config --global user.email "mega@github.com" @@ -92,15 +91,11 @@ jobs: doc: name: Doc runs-on: ubuntu-latest + needs: setup steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 with: submodules: recursive - - uses: actions-rs/toolchain@v1 - with: - profile: minimal - toolchain: stable - override: true - uses: actions-rs/cargo@v1 with: command: doc @@ -109,14 +104,9 @@ jobs: fuse: name: Fuse Lints runs-on: ubuntu-latest + needs: setup steps: - - uses: actions/checkout@v2 - - uses: actions-rs/toolchain@v1 - with: - profile: minimal - toolchain: stable - override: true - submodules: recursive + - uses: actions/checkout@v3 - run: sudo apt-get update && sudo apt-get install -y fuse3 libfuse3-dev - run: cd ./scorpio && cargo clippy --all-targets --all-features -- -D warnings diff --git a/moon/src/app/api/user/route.ts b/moon/src/app/api/user/route.ts index 776ec8ba5..ce1dc17fe 100644 --- a/moon/src/app/api/user/route.ts +++ b/moon/src/app/api/user/route.ts @@ -5,7 +5,7 @@ export const dynamic = 'force-dynamic' // defaults to auto export async function GET(request: NextRequest) { const session = await verifySession() - if (!session) return null + if (!session) return Response.json({}); const endpoint = process.env.MEGA_INTERNAL_HOST; const cookieHeader = request.headers.get('cookie') || ''; diff --git a/moon/src/app/api/user/ssh/[id]/delete/route.ts b/moon/src/app/api/user/ssh/[id]/delete/route.ts index f37cb90b0..f2c23dde0 100644 --- a/moon/src/app/api/user/ssh/[id]/delete/route.ts +++ b/moon/src/app/api/user/ssh/[id]/delete/route.ts @@ -5,7 +5,7 @@ const endpoint = process.env.MEGA_INTERNAL_HOST; export async function POST(request: Request, { params }: { params: { id: string } }) { const session = await verifySession() - if (!session) return null + if (!session) return Response.json({}) const cookieHeader = request.headers.get('cookie') || ''; diff --git a/moon/src/app/api/user/ssh/route.ts b/moon/src/app/api/user/ssh/route.ts index 81d48c7ba..746f4baad 100644 --- a/moon/src/app/api/user/ssh/route.ts +++ b/moon/src/app/api/user/ssh/route.ts @@ -7,7 +7,7 @@ const endpoint = process.env.MEGA_INTERNAL_HOST; export async function POST(request: NextRequest) { const session = await verifySession() - if (!session) return null + if (!session) return Response.json({}) const cookieHeader = request.headers.get('cookie') || ''; const body = await request.json(); @@ -33,7 +33,7 @@ export async function POST(request: NextRequest) { export async function GET(request: NextRequest) { const session = await verifySession() - if (!session) return null + if (!session) return Response.json({}) const cookieHeader = request.headers.get('cookie') || '';