Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit b8850eb

Browse files
authored
ci: refactor CI test runs to run against the code in a built and packaged form instead of the source code (#82)
1 parent 2c34532 commit b8850eb

15 files changed

+119
-97
lines changed
Lines changed: 43 additions & 0 deletions
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‎

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: 68 additions & 0 deletions
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‎

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

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /