Skip to content

Commit e46edc6

Browse files
committed
refactor CI test runs to run against the code in a built and packaged form instead of against the source code
1 parent 2c34532 commit e46edc6

10 files changed

+56
-10
lines changed

.github/workflows/___.yaml

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: CI - ___
2+
3+
on:
4+
pull_request:
5+
branches: [master]
6+
7+
jobs:
8+
lint_check:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- uses: actions/checkout@v4
12+
with:
13+
ref: ${{ github.head_ref }}
14+
15+
- uses: ./.github/actions/ci-common-setup
16+
17+
- name: Lint check
18+
run: pnpm exec eslint --cache
19+
20+
prettier_check:
21+
runs-on: ubuntu-latest
22+
steps:
23+
- uses: actions/checkout@v4
24+
with:
25+
ref: ${{ github.head_ref }}
26+
27+
- uses: ./.github/actions/ci-common-setup
28+
29+
- name: Prettier check
30+
run: pnpm exec prettier --check "./{src,spec}/**/*.{ts,tsx,js,mjs,jsx}"

.github/workflows/ci-tests.yaml

+18-3
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,21 @@ jobs:
1313
ref: ${{ github.head_ref }}
1414

1515
- uses: ./.github/actions/ci-common-setup
16-
17-
- name: Run tests
18-
run: pnpm run test
16+
17+
- name: Build and pack library locally
18+
id: pkg-pack
19+
run: |
20+
echo "pkg_pack_results<<EOF" >> $GITHUB_OUTPUT
21+
pnpm pack --json >> $GITHUB_OUTPUT
22+
echo "EOF" >> $GITHUB_OUTPUT
23+
24+
- name: Install locally packaged library
25+
run: |
26+
pnpm i packaged-react-async-iterators@file:./${{fromJson(steps.pkg-pack.outputs.pkg_pack_results)[0].filename}}
27+
28+
- name: Run tests against packaged library code
29+
run: |
30+
[[ -e ./src ]] && mv ./src ./src-ignored-for-packaged-testing
31+
echo 'export * from "packaged-react-async-iterators";' \> ./spec/libEntrypoint.ts
32+
pnpm test
33+
[[ -e ./src-ignored-for-packaged-testing ]] && mv ./src-ignored-for-packaged-testing ./src

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
"test-typings-check": "tsc --noEmit -p ./spec/tsconfig.json",
4949
"build": "rm -rf ./dist && tsc -p tsconfig.json && tsc -p tsconfig-cjs.json && node ./scripts/set-module-type-in-dist-builds.mjs",
5050
"build-check": "tsc --noEmit -p ./tsconfig.json",
51-
"prepublishOnly": "npm run build"
51+
"prepack": "npm run build"
5252
},
5353
"peerDependencies": {
5454
"react": ">=17"

spec/libEntrypoint.ts

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * from '../src/index.js';

spec/tests/Iterate.spec.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { it, describe, expect, afterEach, vi, type Mock } from 'vitest';
22
import { gray } from 'colorette';
33
import { render, cleanup as cleanupMountedReactTrees, act } from '@testing-library/react';
4-
import { Iterate, It, iterateFormatted, type IterationResult } from '../../src/index.js';
4+
import { Iterate, It, iterateFormatted, type IterationResult } from '../libEntrypoint.js';
55
import { asyncIterOf } from '../utils/asyncIterOf.js';
66
import { IteratorChannelTestHelper } from '../utils/IteratorChannelTestHelper.js';
77

spec/tests/IterateMulti.spec.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import {
77
ItMulti,
88
type IterateMultiProps,
99
type IterationResultSet,
10-
} from '../../src/index.js';
10+
} from '../libEntrypoint.js';
1111
import { pipe } from '../utils/pipe.js';
1212
import { asyncIterOf } from '../utils/asyncIterOf.js';
1313
import { IteratorChannelTestHelper } from '../utils/IteratorChannelTestHelper.js';

spec/tests/iterateFormatted.spec.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { it, describe, expect, afterEach } from 'vitest';
22
import { gray } from 'colorette';
33
import { render, cleanup as cleanupMountedReactTrees, act } from '@testing-library/react';
4-
import { iterateFormatted, Iterate } from '../../src/index.js';
4+
import { iterateFormatted, Iterate } from '../libEntrypoint.js';
55
import { pipe } from '../utils/pipe.js';
66
import { asyncIterOf } from '../utils/asyncIterOf.js';
77
import { asyncIterToArray } from '../utils/asyncIterToArray.js';

spec/tests/useAsyncIter.spec.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { it, describe, expect, afterEach, vi } from 'vitest';
22
import { gray } from 'colorette';
33
import { cleanup as cleanupMountedReactTrees, act, renderHook } from '@testing-library/react';
4-
import { useAsyncIter, iterateFormatted } from '../../src/index.js';
4+
import { useAsyncIter, iterateFormatted } from '../libEntrypoint.js';
55
import { asyncIterOf } from '../utils/asyncIterOf.js';
66
import { IteratorChannelTestHelper } from '../utils/IteratorChannelTestHelper.js';
77

spec/tests/useAsyncIterMulti.spec.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { it, describe, expect, afterEach, vi } from 'vitest';
22
import { gray } from 'colorette';
33
import { cleanup as cleanupMountedReactTrees, act, renderHook } from '@testing-library/react';
4-
import { iterateFormatted, useAsyncIterMulti } from '../../src/index.js';
4+
import { iterateFormatted, useAsyncIterMulti } from '../libEntrypoint.js';
55
import { pipe } from '../utils/pipe.js';
66
import { asyncIterOf } from '../utils/asyncIterOf.js';
77
import { IteratorChannelTestHelper } from '../utils/IteratorChannelTestHelper.js';

spec/tests/useAsyncIterState.spec.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import {
77
cleanup as cleanupMountedReactTrees,
88
act,
99
} from '@testing-library/react';
10-
import { useAsyncIterState } from '../../src/index.js';
10+
import { useAsyncIterState } from '../libEntrypoint.js';
1111
import { asyncIterToArray } from '../utils/asyncIterToArray.js';
1212
import { asyncIterTake } from '../utils/asyncIterTake.js';
1313
import { asyncIterTakeFirst } from '../utils/asyncIterTakeFirst.js';

0 commit comments

Comments
 (0)