Skip to content

Commit

Permalink
fix CI to use Bun instead of Node/Yarn, add test for issue #268
Browse files Browse the repository at this point in the history
  • Loading branch information
auguwu committed Jul 1, 2024
1 parent 76b79b2 commit f213c14
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 52 deletions.
31 changes: 14 additions & 17 deletions .github/workflows/CI.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

name: CI
on:
workflow_dispatch:
workflow_dispatch: {}
push:
branches:
- master
Expand All @@ -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
42 changes: 7 additions & 35 deletions tests/inputs.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit f213c14

Please sign in to comment.