From f213c14d1c8e84d4321bf8481da1c8e2fbe4d20b Mon Sep 17 00:00:00 2001 From: Noel Date: Sun, 30 Jun 2024 17:51:20 -0700 Subject: [PATCH] fix CI to use Bun instead of Node/Yarn, add test for issue #268 --- .github/workflows/CI.yaml | 31 +++++++++++++---------------- tests/inputs.spec.ts | 42 +++++++-------------------------------- 2 files changed, 21 insertions(+), 52 deletions(-) diff --git a/.github/workflows/CI.yaml b/.github/workflows/CI.yaml index 24b44f0..db1d164 100644 --- a/.github/workflows/CI.yaml +++ b/.github/workflows/CI.yaml @@ -15,7 +15,7 @@ name: CI on: - workflow_dispatch: + workflow_dispatch: {} push: branches: - master @@ -41,27 +41,24 @@ on: - 'LICENSE' - 'renovate.json' jobs: - lint: - name: Linting CI + linting: + name: Lint & Testing runs-on: ubuntu-latest steps: - - name: Checkout the repository + - name: Checkout repository uses: actions/checkout@v4 - - name: Uses Node.js 20.x - uses: actions/setup-node@v4 - with: - node-version: 20.x - - - name: Setup Yarn and node-modules cache - id: yarn-cache - uses: auguwu/node-pm-action@master + - name: Setup Bun + uses: oven-sh/setup-bun@v2 - name: Install dependencies - run: yarn install --immutable + run: bun install --frozen-lockfile + + - name: Lint project + run: bun run lint - - name: Lint project with ESLint - run: yarn lint + - name: Format project + run: bun run fmt - - name: Run all tests - run: yarn test + - name: Run tests + run: bun test diff --git a/tests/inputs.spec.ts b/tests/inputs.spec.ts index 071647e..492f894 100644 --- a/tests/inputs.spec.ts +++ b/tests/inputs.spec.ts @@ -46,42 +46,14 @@ test('resolve default inputs', async () => { expect(inputs!.args.length).toBe(0); }); -// TODO(@auguwu): how to mock process.stdout/stderr in bun -// test("don't resolve invalid inputs", async () => { -// // forbid -// const mockStdout = mockProcessStdout(); -// setInput('forbid', 'unused_mut'); -// setInput('args', '-Funused_mut'); +// test to fix issue #268 +test('allow spaces in `args` and `check-args`', async () => { + setInput('args', '--no-default-features --workspace'); -// let inputs = await getInputs(); -// expect(inputs).toBeNull(); -// expect(mockStdout).toHaveBeenCalledOnce(); -// expect(mockStdout).toHaveBeenCalledWith('::error::To append new forbidden lints, use the `forbid` action input.\n'); - -// mockStdout.mockReset(); - -// // deny -// resetEnv(); -// setInput('deny', 'unused_mut'); -// setInput('args', '-Dunused_mut,-Dboxed_local'); - -// inputs = await getInputs(); -// expect(inputs).toBeNull(); -// expect(mockStdout).toHaveBeenCalledOnce(); -// expect(mockStdout).toHaveBeenCalledWith('::error::To append new deny lints, use the `deny` action input.\n'); - -// mockStdout.mockReset(); - -// resetEnv(); -// setInput('check-args', '--all-features'); - -// inputs = await getInputs(); -// expect(inputs).toBeNull(); -// expect(mockStdout).toHaveBeenCalledOnce(); -// expect(mockStdout).toHaveBeenCalledWith( -// '::error::`--all-features` is replaced by the `all-features` argument when using the action.\n' -// ); -// }); + const input = await getInputs(); + expect(input).not.toBeNull(); + expect(input!.args).toStrictEqual(['--no-default-features', '--workspace']); +}); // See: https://github.com/actions/toolkit/blob/a1b068ec31a042ff1e10a522d8fdf0b8869d53ca/packages/core/src/core.ts#L89 function getInputName(name: string) {