Skip to content

Commit eb5e6d0

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 eb5e6d0

14 files changed

+112
-97
lines changed

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

Lines changed: 0 additions & 18 deletions
This file was deleted.

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

Lines changed: 0 additions & 18 deletions
This file was deleted.

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

Lines changed: 0 additions & 18 deletions
This file was deleted.

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

Lines changed: 0 additions & 18 deletions
This file was deleted.

.github/workflows/ci-tests.yaml

Lines changed: 0 additions & 18 deletions
This file was deleted.

.github/workflows/ci.yaml

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
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
52+
53+
- name: Get "name" from package.json
54+
id: get-name
55+
run: |
56+
echo "package_name=$(cat ./package.json | jq -r '.name')" >> $GITHUB_OUTPUT
57+
58+
- name: Build and pack library locally
59+
id: pkg-pack
60+
run: |
61+
pnpm pack
62+
63+
- name: Install locally-packaged library
64+
run: |
65+
PACKAGE_FILENAME=$(ls ${{ steps.get-name.outputs.package_name }}-*.tgz)
66+
pnpm i packaged-react-async-iterators@file:./$PACKAGE_FILENAME
67+
68+
- name: Run tests against packaged library code
69+
run: |
70+
[[ -e ./src ]] && mv ./src ./src-ignored-for-packaged-testing
71+
echo 'export * from "packaged-react-async-iterators";' > ./spec/libEntrypoint.ts
72+
pnpm test
73+
[[ -e ./src-ignored-for-packaged-testing ]] && mv ./src-ignored-for-packaged-testing ./src
74+
75+
run_type_check_on_tests:
76+
runs-on: ubuntu-latest
77+
steps:
78+
- uses: actions/checkout@v4
79+
with:
80+
ref: ${{ github.head_ref }}
81+
82+
- uses: ./.github/actions/ci-common-setup
83+
84+
- name: Get "name" from package.json
85+
id: get-name
86+
run: |
87+
echo "package_name=$(cat ./package.json | jq -r '.name')" >> $GITHUB_OUTPUT
88+
89+
- name: Build and pack library locally
90+
id: pkg-pack
91+
run: |
92+
pnpm pack
93+
94+
- name: Install locally-packaged library
95+
run: |
96+
PACKAGE_FILENAME=$(ls ${{ steps.get-name.outputs.package_name }}-*.tgz)
97+
pnpm i packaged-react-async-iterators@file:./$PACKAGE_FILENAME
98+
99+
- name: Type-check tests code
100+
run: |
101+
[[ -e ./src ]] && mv ./src ./src-ignored-for-packaged-testing
102+
echo 'export * from "packaged-react-async-iterators";' > ./spec/libEntrypoint.ts
103+
pnpm run test-typings-check
104+
[[ -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';

0 commit comments

Comments
 (0)