Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Migrate to github actions and release-please. #48

Merged
merged 3 commits into from
Oct 15, 2024
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
16 changes: 16 additions & 0 deletions .github/actions/publish-docs/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: Publish Documentation
description: 'Publish documentation to github pages.'

inputs:
github_token:
description: 'The github token to use for committing'
required: true

runs:
using: composite
steps:
- uses: launchdarkly/gh-actions/actions/publish-pages@publish-pages-v1.0.2
name: 'Publish to Github pages'
with:
docs_path: docs
github_token: ${{ inputs.github_token }}
20 changes: 20 additions & 0 deletions .github/actions/publish-npm/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: Publish to NPM
description: Publish an npm package.
inputs:
prerelease:
description: 'Is this a prerelease. If so, then the latest tag will not be updated in npm.'
required: false
dry-run:
description: 'Is this a dry run. If so no package will be published.'
required: false

runs:
using: composite
steps:
- name: Publish
shell: bash
run: |
./scripts/publish-npm.sh
env:
LD_RELEASE_IS_PRERELEASE: ${{ inputs.prerelease }}
LD_RELEASE_IS_DRYRUN: ${{ inputs.dry-run }}
47 changes: 47 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: Build and Test

on:
push:
branches: [main]
paths-ignore:
- '**.md' #Do not need to run CI for markdown changes.
pull_request:
branches: [main]
paths-ignore:
- '**.md'

jobs:
build-test:
strategy:
matrix:
variations: [
{os: ubuntu-latest, node: latest},
{os: ubuntu-latest, node: 18}
]

runs-on: ${{ matrix.variations.os }}
env:
TEST_SERVICE_PORT: 8000

steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: ${{ matrix.variations.node }}
registry-url: 'https://registry.npmjs.org'
- name: Install
run: npm install
- name: Test
run: npm test
- name: Lint
run: npm run lint:all
- name: Check typescript
run: npm run check-typescript
- name: Run contract test service
run: npm run contract-test-service 2>&1 &
- uses: launchdarkly/gh-actions/actions/contract-tests@contract-tests-v1.0.0
with:
test_service_port: ${{ env.TEST_SERVICE_PORT }}
token: ${{ secrets.GITHUB_TOKEN }}
- name: Build Docs
run: npm run doc
12 changes: 12 additions & 0 deletions .github/workflows/lint-pr-title.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
name: Lint PR title

on:
pull_request_target:
types:
- opened
- edited
- synchronize

jobs:
lint-pr-title:
uses: launchdarkly/gh-actions/.github/workflows/lint-pr-title.yml@main
57 changes: 57 additions & 0 deletions .github/workflows/release-please.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
name: Release Please

on:
push:
branches:
- main

jobs:
release-please:
runs-on: ubuntu-latest
outputs:
release_created: ${{ steps.release.outputs.release_created }}
steps:
- uses: googleapis/release-please-action@v4
id: release
with:
token: ${{secrets.GITHUB_TOKEN}}

publish-package:
runs-on: ubuntu-latest
needs: ['release-please']
permissions:
id-token: write
contents: write
if: ${{ needs.release-please.outputs.release_created == 'true' }}
steps:
- uses: actions/checkout@v4

- uses: actions/setup-node@v4
with:
node-version: 20.x
registry-url: 'https://registry.npmjs.org'

- uses: launchdarkly/gh-actions/actions/release-secrets@release-secrets-v1.2.0
name: 'Get NPM token'
with:
aws_assume_role: ${{ vars.AWS_ROLE_ARN }}
ssm_parameter_pairs: '/production/common/releasing/npm/token = NODE_AUTH_TOKEN'

- name: Install Dependencies
run: npm install

- id: publish-npm
name: Publish NPM Package
uses: ./.github/actions/publish-npm
with:
dry-run: 'false'
prerelease: 'false'

- name: Build Documentation
run: npm run doc

- id: publish-docs
name: Publish Documentation
uses: ./.github/actions/publish-docs
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ dist
test-types.js
ldclient-user-cache
/local/
docs/
3 changes: 3 additions & 0 deletions .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
".": "3.2.1"
}
28 changes: 0 additions & 28 deletions docs/Makefile

This file was deleted.

7 changes: 0 additions & 7 deletions docs/doc.md

This file was deleted.

12 changes: 0 additions & 12 deletions docs/tsconfig.json

This file was deleted.

17 changes: 0 additions & 17 deletions docs/typedoc.js

This file was deleted.

7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
"check-typescript": "node_modules/typescript/bin/tsc",
"contract-test-service": "npm --prefix contract-tests install && npm --prefix contract-tests start",
"contract-test-harness": "curl -s https://raw.githubusercontent.com/launchdarkly/sdk-test-harness/main/downloader/run.sh \\ | VERSION=v2 PARAMS=\"-url http://localhost:8000 -debug -stop-service-at-end $TEST_HARNESS_PARAMS\" sh",
"contract-tests": "npm run contract-test-service & npm run contract-test-harness"
"contract-tests": "npm run contract-test-service & npm run contract-test-harness",
"doc": "typedoc"
},
"engines": {
"node": ">= 12.0.0"
Expand All @@ -40,8 +41,8 @@
"jest-junit": "^14.0.1",
"launchdarkly-js-test-helpers": "1.2.1",
"prettier": "2.7.1",
"typescript": "^4.8.4",
"typedoc": "^0.23.24"
"typescript": "~5.4.5",
"typedoc": "^0.25.13"
},
"jest": {
"rootDir": "src",
Expand Down
10 changes: 10 additions & 0 deletions release-please-config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"bootstrap-sha": "aef46172aa8ae518d18e456f573e35bec8f542b0",
"packages": {
".": {
"release-type": "node",
"include-v-in-tag": false,
"include-component-in-tag": false
}
}
}
11 changes: 11 additions & 0 deletions scripts/publish-npm.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/usr/bin/env bash
if $LD_RELEASE_IS_DRYRUN ; then
echo "Doing a dry run of publishing."
else
if $LD_RELEASE_IS_PRERELEASE ; then
echo "Publishing with prerelease tag."
npm publish --tag prerelease --provenance --access public || { echo "npm publish failed" >&2; exit 1; }
else
npm publish --provenance --access public || { echo "npm publish failed" >&2; exit 1; }
fi
fi
17 changes: 17 additions & 0 deletions typedoc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"$schema": "https://typedoc.org/schema.json",
"name": "launchdarkly-node-client-sdk",
"includeVersion": true,
"entryPoints": [
"typings.d.ts",
],
"readme": "none",
"visibilityFilters": {
"protected": false,
"private": false,
"inherited": true,
"external": true,
"@alpha": false,
"@beta": false
}
}
39 changes: 24 additions & 15 deletions typings.d.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
declare module 'launchdarkly-node-client-sdk' {
/**
* This is the API reference for the LaunchDarkly Client-Side Node SDK.
*
*
* In typical usage, you will call {@link initialize} once at startup time to obtain an instance of
* {@link LDClient}, which provides access to all of the SDK's functionality.
*
* For more information, see the [SDK reference guide](https://docs.launchdarkly.com/sdk/client-side/node-js).
*
* @packageDocumentation
*/

//// DOCBUILD-START-REPLACE (see docs/Makefile)
declare module 'launchdarkly-node-client-sdk' {
export * from 'launchdarkly-js-sdk-common';

import {
Expand All @@ -14,7 +24,6 @@ declare module 'launchdarkly-node-client-sdk' {
LDOptionsBase,
LDContext
} from 'launchdarkly-js-sdk-common';
//// DOCBUILD-END-REPLACE

/**
* The current version string of the SDK.
Expand All @@ -26,13 +35,13 @@ declare module 'launchdarkly-node-client-sdk' {
*
* Applications should instantiate a single instance for the lifetime of the application.
* The client will begin attempting to connect to LaunchDarkly as soon as it is created. To
* determine when it is ready to use, call [[LDClient.waitForInitialization]], or register an
* event listener for the `"ready"` event using [[LDClient.on]].
* determine when it is ready to use, call {@link LDClient.waitForInitialization}, or register an
* event listener for the `"ready"` event using {@link LDClient.on}.
*
* @param envKey
* The LaunchDarkly environment ID.
* @param context
* The initial context properties. These can be changed later with [[LDClient.identify]].
* The initial context properties. These can be changed later with {@link LDClient.identify}.
* The context must have a `key` property, except that if you omit `context.key` and set `context.anonymous` to
* true, the SDK will create a randomized unique key (which will be cached in local storage for the
* current OS user account, so the next initialization will reuse the same key).
Expand Down Expand Up @@ -61,8 +70,8 @@ declare module 'launchdarkly-node-client-sdk' {
/**
* Additional parameters to pass to the Node HTTPS API for secure requests. These can include any
* of the TLS-related parameters supported by `https.request()`, such as `ca`, `cert`, and `key`.
* This object should be stored in the `tlsParams` property of [[LDOptions]].
*
* This object should be stored in the `tlsParams` property of {@link LDOptions}.
*
* For more information, see the Node documentation for `https.request()` and `tls.connect()`.
*/
export interface LDTLSOptions {
Expand All @@ -81,27 +90,27 @@ declare module 'launchdarkly-node-client-sdk' {
/**
* The LaunchDarkly SDK client object.
*
* Applications should configure the client at startup time with [[initialize]], and reuse the same instance.
* Applications should configure the client at startup time with {@link initialize}, and reuse the same instance.
*
* For more information, see the [SDK Reference Guide](https://docs.launchdarkly.com/sdk/client-side/node-js).
*/
export interface LDClient extends LDClientBase {
}

/**
* Provides a simple [[LDLogger]] implementation.
* Provides a simple {@link LDLogger} implementation.
*
* This logging implementation uses a simple format that includes only the log level
* and the message text. Output is written to the standard error stream (`console.error`).
* You can filter by log level as described in [[BasicLoggerOptions.level]].
* You can filter by log level as described in {@link BasicLoggerOptions.level}.
*
* To use the logger created by this function, put it into [[LDOptions.logger]]. If
* you do not set [[LDOptions.logger]] to anything, the SDK uses a default logger
* To use the logger created by this function, put it into {@link LDOptions.logger}. If
* you do not set {@link LDOptions.logger} to anything, the SDK uses a default logger
* that is equivalent to `ld.basicLogger({ level: 'info' })`.
*
* @param options Configuration for the logger. If no options are specified, the
* logger uses `{ level: 'info' }`.
*
*
* @example
* This example shows how to use `basicLogger` in your SDK options to enable console
* logging only at `warn` and `error` levels.
Expand All @@ -120,7 +129,7 @@ declare module 'launchdarkly-node-client-sdk' {
* };
* ```
*/
export function basicLogger(
export function basicLogger(
options?: BasicLoggerOptions
): LDLogger;
}