Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 43 additions & 0 deletions .github/actions/ci-common-setup-locally-packaged/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: Common Setup for CI with locally packaged library code

description: Reusable common setup with locally packaged library code for project's CI jobs

inputs:
node-version:
description: Specific Node.js version to override the common one that's gonna be selected by default
required: false
default: v22.5.0

runs:
using: composite
steps:
- uses: ./.github/actions/ci-common-setup
with:
node-version: ${{ inputs.node-version }}

- name: Get "name" and "version" from package.json
id: package-json-info
shell: bash
run: |
{
echo "package_name=$(cat ./package.json | jq -r '.name')"
echo "package_version=$(cat ./package.json | jq -r '.version')"
} >> $GITHUB_OUTPUT

- name: Build and pack library locally
id: pkg-pack
shell: bash
run: |
pnpm pack

- name: Install locally-packaged library
shell: bash
run: |
PACKAGE_FILENAME=$(ls ${{ steps.package-json-info.outputs.package_name }}-${{ steps.package-json-info.outputs.package_version }}.tgz)
pnpm i packaged-react-async-iterators@file:./$PACKAGE_FILENAME

- name: Type-check tests code
shell: bash
run: |
[[ -e ./src ]] && mv ./src ./src-ignored-for-packaged-testing
echo 'export * from "packaged-react-async-iterators";' > ./spec/libEntrypoint.ts
18 changes: 0 additions & 18 deletions .github/workflows/ci-build-check.yaml

This file was deleted.

18 changes: 0 additions & 18 deletions .github/workflows/ci-eslint-check.yaml

This file was deleted.

18 changes: 0 additions & 18 deletions .github/workflows/ci-prettier-check.yaml

This file was deleted.

18 changes: 0 additions & 18 deletions .github/workflows/ci-tests-type-check.yaml

This file was deleted.

18 changes: 0 additions & 18 deletions .github/workflows/ci-tests.yaml

This file was deleted.

68 changes: 68 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
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}"

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

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

- name: TypeScript test build
run: pnpm run build-check

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

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

- name: Run tests against packaged library code
run: |
pnpm test

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

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

- name: Type-check tests code
run: |
pnpm run test-typings-check
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