Skip to content

Commit ed17840

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 ed17840

10 files changed

+60
-10
lines changed

.github/workflows/___.yaml

Lines changed: 30 additions & 0 deletions
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

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,25 @@ 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+
PACK_RESULTS=$(pnpm pack --json)
21+
{
22+
echo "pkg_pack_results<<EOF"
23+
echo "$PACK_RESULTS"
24+
echo "EOF"
25+
} >> "$GITHUB_OUTPUT"
26+
# } >> $GITHUB_OUTPUT
27+
28+
- name: Install locally-packaged library
29+
run: |
30+
pnpm i packaged-react-async-iterators@file:./${{fromJson(steps.pkg-pack.outputs.pkg_pack_results)[0].filename}}
31+
32+
- name: Run tests against packaged library code
33+
run: |
34+
[[ -e ./src ]] && mv ./src ./src-ignored-for-packaged-testing
35+
echo 'export * from "packaged-react-async-iterators";' > ./spec/libEntrypoint.ts
36+
pnpm test
37+
[[ -e ./src-ignored-for-packaged-testing ]] && mv ./src-ignored-for-packaged-testing ./src

package.json

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * from '../src/index.js';

spec/tests/Iterate.spec.tsx

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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)