Skip to content

Commit c3ee90b

Browse files
authored
feat: extract and publish core package (#629)
This PR addresses: #616 by: - configuring CI to release a new module (in addition to server/web/react we now release the "core" module (previously called "shared"). - adding a peer dep to the above module to server/web/react - adding a workflow to ensure that `shared` is released ahead of associated web/server/react changes, and which also auto-increments the peer dep version when the core module is released - unrelated `typedoc` improvements/updates > [!NOTE] > I intend to create a new PR that will rename the dir structure according to the packages... so `shared/` will become `core/` and `client/` will become `web/`. I just didn't want to add confusion and noise to this PR. --------- Signed-off-by: Todd Baert <[email protected]>
1 parent 4ce7606 commit c3ee90b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+278
-172
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
on:
2+
push:
3+
branches:
4+
- 'release-please**'
5+
6+
env:
7+
CORE_PACKAGE: core
8+
9+
name: Audit Pending Releases
10+
jobs:
11+
npm-release:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- uses: actions/checkout@v4
15+
with:
16+
ref: ${{ github.event.ref }}
17+
18+
# if this is an SDK release, make sure there's no pending releases for @openfeature/core
19+
- name: Check for Pending Dependency PRs
20+
if: ${{ !endsWith(github.ref_name, env.CORE_PACKAGE) }}
21+
run: |
22+
if [ $(gh pr list --search '"release ${{ env.CORE_PACKAGE }}" in:title' | wc -l) -gt 0 ]; \
23+
then echo "Pending @openfeaure/${{ env.CORE_PACKAGE }} release. Please release @openfeaure/${{ env.CORE_PACKAGE }} first!" && exit 1; \
24+
else echo "No pending @openfeaure/${{ env.CORE_PACKAGE }} releases"; \
25+
fi
26+
env:
27+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
28+
29+
- name: Setup Node
30+
uses: actions/setup-node@v4
31+
with:
32+
node-version: 16
33+
registry-url: "https://registry.npmjs.org"
34+
cache: 'npm'
35+
36+
# if this is an @openfeature/core release, but the SDKs to use this version as a peer, and commit back
37+
- name: Update Peer Version in Dependants
38+
if: ${{ endsWith(github.ref_name, env.CORE_PACKAGE) }}
39+
run: |
40+
npm run update-core-peers && \
41+
! git diff-files --quiet && \
42+
( echo 'Updated peer dependency in dependants, commiting...'
43+
git add --all && \
44+
git config user.name "openfeature-peer-update-bot" && \
45+
git config user.email "[email protected]" && \
46+
git commit -m 'chore: bump @openfeaure/${{ env.CORE_PACKAGE }} peer' -s && \
47+
git push ) || echo 'Peer dependency in dependants is already up to date.'
48+
env:
49+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/pr-checks.yaml

+3
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,9 @@ jobs:
5353
- name: Install
5454
run: npm ci
5555

56+
- name: Install
57+
run: npm run build
58+
5659
- name: Docs
5760
run: npm run docs
5861

.github/workflows/publish-experimental.yml

-40
This file was deleted.

CONTRIBUTING.md

+4-3
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,10 @@ We value having as few runtime dependencies as possible. The addition of any dep
1919
### Modules
2020

2121
This repository uses [NPM workspaces](https://docs.npmjs.com/cli/v9/using-npm/workspaces) to establish a simple monorepo.
22-
Within the root project, there is one common project (`packages/shared`) which features common interfaces and code, consumed by the published modules (`packages/server` and `packages/client`). The shared module is bundled transparently into the published modules - it is not published itself. Changes in `packages/shared` will result in releases of the dependant modules via Release Please.
22+
Within the root project, there is one common project (`packages/shared`) which features common interfaces and code, consumed by the published modules (`packages/server` and `packages/client`).
23+
The shared module is built and published separately, and is a peer dependency of the SDK packages.
24+
Consumers need not install it separately, since `npm` and `yarn` automatically install required peers.
25+
In order to prevent regressions cause by incompatibilities due to version mismatches, the SDKs are locked to a particular version of the `@openfeature/core` module, and the CI enforces that it's released before any dependant SDKs (see [the related workflow](./.github/workflows/audit-pending-releases.yml)).
2326

2427
### Testing
2528

@@ -45,8 +48,6 @@ for the client e2e tests.
4548

4649
Both ES modules and CommonJS modules are supported, so consumers can use both `require` and `import` functions to utilize this module. This is accomplished by building 2 variations of the output, under `dist/esm` and `dist/cjs`, respectively. To force resolution of the `dist/esm/**.js*` files as modules, a package json with only the context `{"type": "module"}` is included at a in a `postbuild` step. Type declarations are included at `/dist/types/`
4750

48-
For testing purposes, you can add a comment containing "/publish" in any PR. This will publish an experimental SDK version with the git SHA appended to the version number.
49-
5051
## Pull Request
5152

5253
All contributions to the OpenFeature project are welcome via GitHub pull requests.

jest.config.ts

+10
Original file line numberDiff line numberDiff line change
@@ -119,12 +119,18 @@ export default {
119119
testEnvironment: 'node',
120120
preset: 'ts-jest',
121121
testMatch: ['<rootDir>/packages/server/test/**/*.spec.ts'],
122+
moduleNameMapper: {
123+
'@openfeature/core': '<rootDir>/packages/shared/src'
124+
},
122125
},
123126
{
124127
displayName: 'client',
125128
testEnvironment: 'node',
126129
preset: 'ts-jest',
127130
testMatch: ['<rootDir>/packages/client/test/**/*.spec.ts'],
131+
moduleNameMapper: {
132+
'@openfeature/core': '<rootDir>/packages/shared/src'
133+
}
128134
},
129135
{
130136
displayName: 'server-e2e',
@@ -133,6 +139,9 @@ export default {
133139
testMatch: ['<rootDir>/packages/server/e2e/**/*.spec.ts'],
134140
modulePathIgnorePatterns: ['.*/node-modules/'],
135141
setupFiles: ['<rootDir>/packages/server/e2e/step-definitions/setup.ts'],
142+
moduleNameMapper: {
143+
'@openfeature/core': '<rootDir>/packages/shared/src'
144+
},
136145
},
137146
{
138147
displayName: 'client-e2e',
@@ -144,6 +153,7 @@ export default {
144153
moduleNameMapper: {
145154
'^uuid$': require.resolve('uuid'),
146155
'^(.*)\\.js$': ['$1', '$1.js'],
156+
'@openfeature/core': '<rootDir>/packages/shared/src'
147157
},
148158
},
149159
],

0 commit comments

Comments
 (0)