Skip to content

Commit 3c1f19c

Browse files
committed
Merge branch 'master' of https://github.com/shtaif/react-async-iterators into async-iter-memo
2 parents f86a313 + b8850eb commit 3c1f19c

15 files changed

+119
-97
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
name: Common Setup for CI with locally packaged library code
2+
3+
description: Reusable common setup with locally packaged library code for project's CI jobs
4+
5+
inputs:
6+
node-version:
7+
description: Specific Node.js version to override the common one that's gonna be selected by default
8+
required: false
9+
default: v22.5.0
10+
11+
runs:
12+
using: composite
13+
steps:
14+
- uses: ./.github/actions/ci-common-setup
15+
with:
16+
node-version: ${{ inputs.node-version }}
17+
18+
- name: Get "name" and "version" from package.json
19+
id: package-json-info
20+
shell: bash
21+
run: |
22+
{
23+
echo "package_name=$(cat ./package.json | jq -r '.name')"
24+
echo "package_version=$(cat ./package.json | jq -r '.version')"
25+
} >> $GITHUB_OUTPUT
26+
27+
- name: Build and pack library locally
28+
id: pkg-pack
29+
shell: bash
30+
run: |
31+
pnpm pack
32+
33+
- name: Install locally-packaged library
34+
shell: bash
35+
run: |
36+
PACKAGE_FILENAME=$(ls ${{ steps.package-json-info.outputs.package_name }}-${{ steps.package-json-info.outputs.package_version }}.tgz)
37+
pnpm i packaged-react-async-iterators@file:./$PACKAGE_FILENAME
38+
39+
- name: Type-check tests code
40+
shell: bash
41+
run: |
42+
[[ -e ./src ]] && mv ./src ./src-ignored-for-packaged-testing
43+
echo 'export * from "packaged-react-async-iterators";' > ./spec/libEntrypoint.ts

.github/workflows/ci-build-check.yaml

-18
This file was deleted.

.github/workflows/ci-eslint-check.yaml

-18
This file was deleted.

.github/workflows/ci-prettier-check.yaml

-18
This file was deleted.

.github/workflows/ci-tests-type-check.yaml

-18
This file was deleted.

.github/workflows/ci-tests.yaml

-18
This file was deleted.

.github/workflows/ci.yaml

+68
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
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}"
31+
32+
ts_build_test:
33+
runs-on: ubuntu-latest
34+
steps:
35+
- uses: actions/checkout@v4
36+
with:
37+
ref: ${{ github.head_ref }}
38+
39+
- uses: ./.github/actions/ci-common-setup
40+
41+
- name: TypeScript test build
42+
run: pnpm run build-check
43+
44+
run_tests:
45+
runs-on: ubuntu-latest
46+
steps:
47+
- uses: actions/checkout@v4
48+
with:
49+
ref: ${{ github.head_ref }}
50+
51+
- uses: ./.github/actions/ci-common-setup-locally-packaged
52+
53+
- name: Run tests against packaged library code
54+
run: |
55+
pnpm test
56+
57+
run_type_check_on_tests:
58+
runs-on: ubuntu-latest
59+
steps:
60+
- uses: actions/checkout@v4
61+
with:
62+
ref: ${{ github.head_ref }}
63+
64+
- uses: ./.github/actions/ci-common-setup-locally-packaged
65+
66+
- name: Type-check tests code
67+
run: |
68+
pnpm run test-typings-check

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)