Skip to content

Commit

Permalink
refactor CI test runs to run against the code in a built and packaged…
Browse files Browse the repository at this point in the history
… form instead of against the source code
  • Loading branch information
shtaif committed Feb 1, 2025
1 parent 2c34532 commit 92e816b
Show file tree
Hide file tree
Showing 10 changed files with 63 additions and 10 deletions.
30 changes: 30 additions & 0 deletions .github/workflows/___.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: CI - ___

on:
pull_request:
branches: [master]

jobs:
lint_check____________:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.head_ref }}

- uses: ./.github/actions/ci-common-setup

- name: Lint check
run: pnpm exec eslint --cache

prettier_check____________:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.head_ref }}

- uses: ./.github/actions/ci-common-setup

- name: Prettier check
run: pnpm exec prettier --check "./{src,spec}/**/*.{ts,tsx,js,mjs,jsx}"
28 changes: 25 additions & 3 deletions .github/workflows/ci-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,28 @@ jobs:
ref: ${{ github.head_ref }}

- uses: ./.github/actions/ci-common-setup

- name: Run tests
run: pnpm run test

- name: Get "name" from package.json
id: get-name
run: |
echo "package_name=$(cat ./package.json | jq -r '.name')" >> $GITHUB_OUTPUT
- name: Build and pack library locally
id: pkg-pack
run: |
pnpm pack
- run: |
PACKAGE_FILENAME=$(ls ${{ steps.get-name.outputs.package_name }}-*.tgz)
echo $PACKAGE_FILENAME
# - name: Install locally-packaged library
# run: |
# pnpm i packaged-react-async-iterators@file:./${{fromJson(steps.pkg-pack.outputs.pkg_pack_results)[0].filename}}

# - name: Run tests against packaged library code
# run: |
# [[ -e ./src ]] && mv ./src ./src-ignored-for-packaged-testing
# echo 'export * from "packaged-react-async-iterators";' > ./spec/libEntrypoint.ts
# pnpm test
# [[ -e ./src-ignored-for-packaged-testing ]] && mv ./src-ignored-for-packaged-testing ./src
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
"test-typings-check": "tsc --noEmit -p ./spec/tsconfig.json",
"build": "rm -rf ./dist && tsc -p tsconfig.json && tsc -p tsconfig-cjs.json && node ./scripts/set-module-type-in-dist-builds.mjs",
"build-check": "tsc --noEmit -p ./tsconfig.json",
"prepublishOnly": "npm run build"
"prepack": "npm run build"
},
"peerDependencies": {
"react": ">=17"
Expand Down
1 change: 1 addition & 0 deletions spec/libEntrypoint.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from '../src/index.js';
2 changes: 1 addition & 1 deletion spec/tests/Iterate.spec.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { it, describe, expect, afterEach, vi, type Mock } from 'vitest';
import { gray } from 'colorette';
import { render, cleanup as cleanupMountedReactTrees, act } from '@testing-library/react';
import { Iterate, It, iterateFormatted, type IterationResult } from '../../src/index.js';
import { Iterate, It, iterateFormatted, type IterationResult } from '../libEntrypoint.js';
import { asyncIterOf } from '../utils/asyncIterOf.js';
import { IteratorChannelTestHelper } from '../utils/IteratorChannelTestHelper.js';

Expand Down
2 changes: 1 addition & 1 deletion spec/tests/IterateMulti.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
ItMulti,
type IterateMultiProps,
type IterationResultSet,
} from '../../src/index.js';
} from '../libEntrypoint.js';
import { pipe } from '../utils/pipe.js';
import { asyncIterOf } from '../utils/asyncIterOf.js';
import { IteratorChannelTestHelper } from '../utils/IteratorChannelTestHelper.js';
Expand Down
2 changes: 1 addition & 1 deletion spec/tests/iterateFormatted.spec.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { it, describe, expect, afterEach } from 'vitest';
import { gray } from 'colorette';
import { render, cleanup as cleanupMountedReactTrees, act } from '@testing-library/react';
import { iterateFormatted, Iterate } from '../../src/index.js';
import { iterateFormatted, Iterate } from '../libEntrypoint.js';
import { pipe } from '../utils/pipe.js';
import { asyncIterOf } from '../utils/asyncIterOf.js';
import { asyncIterToArray } from '../utils/asyncIterToArray.js';
Expand Down
2 changes: 1 addition & 1 deletion spec/tests/useAsyncIter.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { it, describe, expect, afterEach, vi } from 'vitest';
import { gray } from 'colorette';
import { cleanup as cleanupMountedReactTrees, act, renderHook } from '@testing-library/react';
import { useAsyncIter, iterateFormatted } from '../../src/index.js';
import { useAsyncIter, iterateFormatted } from '../libEntrypoint.js';
import { asyncIterOf } from '../utils/asyncIterOf.js';
import { IteratorChannelTestHelper } from '../utils/IteratorChannelTestHelper.js';

Expand Down
2 changes: 1 addition & 1 deletion spec/tests/useAsyncIterMulti.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { it, describe, expect, afterEach, vi } from 'vitest';
import { gray } from 'colorette';
import { cleanup as cleanupMountedReactTrees, act, renderHook } from '@testing-library/react';
import { iterateFormatted, useAsyncIterMulti } from '../../src/index.js';
import { iterateFormatted, useAsyncIterMulti } from '../libEntrypoint.js';
import { pipe } from '../utils/pipe.js';
import { asyncIterOf } from '../utils/asyncIterOf.js';
import { IteratorChannelTestHelper } from '../utils/IteratorChannelTestHelper.js';
Expand Down
2 changes: 1 addition & 1 deletion spec/tests/useAsyncIterState.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
cleanup as cleanupMountedReactTrees,
act,
} from '@testing-library/react';
import { useAsyncIterState } from '../../src/index.js';
import { useAsyncIterState } from '../libEntrypoint.js';
import { asyncIterToArray } from '../utils/asyncIterToArray.js';
import { asyncIterTake } from '../utils/asyncIterTake.js';
import { asyncIterTakeFirst } from '../utils/asyncIterTakeFirst.js';
Expand Down

0 comments on commit 92e816b

Please sign in to comment.