From 8fd5787b7a0e7fc275e5e32db38823171ea7d807 Mon Sep 17 00:00:00 2001 From: Bryce Osterhaus Date: Wed, 15 May 2024 11:45:28 +0400 Subject: [PATCH 1/5] chore: add github CI for tests --- .github/workflows/test.yml | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 .github/workflows/test.yml diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..9406b57 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,25 @@ +name: Unit Tests + +on: + push: + branches: [master] + pull_request: + branches: [master] + +jobs: + test: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-node@v3 + with: + node-version: 18 + - uses: pnpm/action-setup@v2 + with: + run_install: true + - name: v2 Tests + run: pnpm run test + working-directory: tests/v2-test + - name: v3 Tests + run: pnpm run test + working-directory: tests/v3-test \ No newline at end of file From 468f0fcdea3dfdf64ec963dec218419807441a3c Mon Sep 17 00:00:00 2001 From: Hyeonjong Date: Sat, 20 Jul 2024 16:14:48 +0900 Subject: [PATCH 2/5] test: add failing test --- .../v2-test/typescript/temporary/1tbs.test.ts | 35 +++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 tests/v2-test/typescript/temporary/1tbs.test.ts diff --git a/tests/v2-test/typescript/temporary/1tbs.test.ts b/tests/v2-test/typescript/temporary/1tbs.test.ts new file mode 100644 index 0000000..b220f29 --- /dev/null +++ b/tests/v2-test/typescript/temporary/1tbs.test.ts @@ -0,0 +1,35 @@ +import { format } from 'prettier'; +import type { Fixture } from 'test-settings'; +import { baseOptions } from 'test-settings'; +import { describe, expect, test } from 'vitest'; + +// eslint-disable-next-line import/no-extraneous-dependencies +import * as thisPlugin from '@/packages/v2-plugin'; + +const options = { + ...baseOptions, + plugins: [thisPlugin], + parser: 'typescript', + braceStyle: '1tbs', +}; + +const fixtures: Fixture[] = [ + { + name: 'intentional failure', + input: `a`, + output: `b;\n`, + }, +]; + +describe('typescript/temporary/1tbs', () => { + for (const fixture of fixtures) { + test(fixture.name, () => { + expect( + format(fixture.input, { + ...options, + ...(fixture.options ?? {}), + }), + ).toBe(fixture.output); + }); + } +}); From 68edbbb1f038489554e280c51d49f3d8d4b67617 Mon Sep 17 00:00:00 2001 From: Hyeonjong Date: Sat, 20 Jul 2024 16:21:18 +0900 Subject: [PATCH 3/5] style: apply format to test.yml --- .github/workflows/test.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 9406b57..fcfcf4c 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -1,10 +1,10 @@ name: Unit Tests on: - push: - branches: [master] - pull_request: - branches: [master] + push: + branches: [master] + pull_request: + branches: [master] jobs: test: @@ -13,7 +13,7 @@ jobs: - uses: actions/checkout@v2 - uses: actions/setup-node@v3 with: - node-version: 18 + node-version: 18 - uses: pnpm/action-setup@v2 with: run_install: true @@ -22,4 +22,4 @@ jobs: working-directory: tests/v2-test - name: v3 Tests run: pnpm run test - working-directory: tests/v3-test \ No newline at end of file + working-directory: tests/v3-test From 75059fa7cf7c7765059e009140844793d948af16 Mon Sep 17 00:00:00 2001 From: Hyeonjong Date: Sat, 20 Jul 2024 16:31:12 +0900 Subject: [PATCH 4/5] ci: define prettier version as matrix This means that failing a test on one version will not break testing on the other version. --- .github/workflows/test.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index fcfcf4c..6b2362b 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -9,6 +9,9 @@ on: jobs: test: runs-on: ubuntu-latest + strategy: + matrix: + prettier-version: [v2, v3] steps: - uses: actions/checkout@v2 - uses: actions/setup-node@v3 @@ -17,9 +20,6 @@ jobs: - uses: pnpm/action-setup@v2 with: run_install: true - - name: v2 Tests + - name: Run Tests run: pnpm run test - working-directory: tests/v2-test - - name: v3 Tests - run: pnpm run test - working-directory: tests/v3-test + working-directory: tests/${{ matrix.prettier-version }}-test From 13e5a9fe437e41d719ac58c4b133fc24e63fd8dc Mon Sep 17 00:00:00 2001 From: Hyeonjong Date: Sat, 20 Jul 2024 16:36:29 +0900 Subject: [PATCH 5/5] test: remove failing test --- .../v2-test/typescript/temporary/1tbs.test.ts | 35 ------------------- 1 file changed, 35 deletions(-) delete mode 100644 tests/v2-test/typescript/temporary/1tbs.test.ts diff --git a/tests/v2-test/typescript/temporary/1tbs.test.ts b/tests/v2-test/typescript/temporary/1tbs.test.ts deleted file mode 100644 index b220f29..0000000 --- a/tests/v2-test/typescript/temporary/1tbs.test.ts +++ /dev/null @@ -1,35 +0,0 @@ -import { format } from 'prettier'; -import type { Fixture } from 'test-settings'; -import { baseOptions } from 'test-settings'; -import { describe, expect, test } from 'vitest'; - -// eslint-disable-next-line import/no-extraneous-dependencies -import * as thisPlugin from '@/packages/v2-plugin'; - -const options = { - ...baseOptions, - plugins: [thisPlugin], - parser: 'typescript', - braceStyle: '1tbs', -}; - -const fixtures: Fixture[] = [ - { - name: 'intentional failure', - input: `a`, - output: `b;\n`, - }, -]; - -describe('typescript/temporary/1tbs', () => { - for (const fixture of fixtures) { - test(fixture.name, () => { - expect( - format(fixture.input, { - ...options, - ...(fixture.options ?? {}), - }), - ).toBe(fixture.output); - }); - } -});