From 185ece274ae32b23f2bf664ced163468b24045f5 Mon Sep 17 00:00:00 2001 From: Eli Bishop Date: Fri, 1 Jul 2022 10:02:30 -0700 Subject: [PATCH 1/3] add CI configuration --- .circleci/config.yml | 40 ++++++++++++++++++++++++++++++++++++++++ .gitignore | 3 ++- index.ts | 2 +- 3 files changed, 43 insertions(+), 2 deletions(-) create mode 100644 .circleci/config.yml diff --git a/.circleci/config.yml b/.circleci/config.yml new file mode 100644 index 0000000..8cd4c0c --- /dev/null +++ b/.circleci/config.yml @@ -0,0 +1,40 @@ +version: 2.1 + +workflows: + test: + jobs: + - build-run-linux: + context: hello-world-demos + + test-daily: + triggers: + - schedule: + cron: "0 6 * * *" + filters: + branches: + only: main + jobs: + - build-run-linux: + context: hello-world-demos + +# This CI build ensures that the demo both compiles and works correctly. For the runtime test, +# we use an SDK key and flag key that are passed in via the CircleCI project configuration; +# the flag is configured to return a true value. + +jobs: + build-run-linux: + docker: + - image: circleci/node:latest + steps: + - checkout + - run: + name: insert SDK key and flag key into demo code + command: | + sed -i.bak "s/sdkKey *= *\".*\"/sdkKey = \"${LD_HELLO_WORLD_SDK_KEY}\"/" index.ts + sed -i.bak "s/featureFlagKey *= *\".*\"/featureFlagKey = \"${LD_HELLO_WORLD_FLAG_KEY_WITH_TRUE_VALUE}\"/" index.ts + - run: npm install + - run: + name: run demo + command: | + npm start | tee output.txt + grep "is true for this user" output.txt || (echo "Flag did not evaluate to expected true value" && exit 1) diff --git a/.gitignore b/.gitignore index b512c09..d5f19d8 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ -node_modules \ No newline at end of file +node_modules +package-lock.json diff --git a/index.ts b/index.ts index a37065f..788bdd4 100644 --- a/index.ts +++ b/index.ts @@ -1,7 +1,7 @@ import * as LaunchDarkly from 'launchdarkly-node-server-sdk'; // Set sdkKey to your LaunchDarkly SDK key. -const sdkKey = ""; +const sdkKey = "sdk-218759d7-ebb4-4311-8933-33fcc77b1850"; // Set featureFlagKey to the feature flag key you want to evaluate. const featureFlagKey = "my-boolean-flag"; From 527d99d9a79e8a9d538199e8ba457fac8176668b Mon Sep 17 00:00:00 2001 From: Eli Bishop Date: Fri, 1 Jul 2022 11:18:10 -0700 Subject: [PATCH 2/3] don't use nodemon - we want it to just run and exit --- package.json | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/package.json b/package.json index c0f7519..3f969cf 100644 --- a/package.json +++ b/package.json @@ -4,14 +4,12 @@ "description": "Hello LaunchDarkly for Node.js with TypeScript", "main": "index.ts", "scripts": { - "start": "npm run build:live", - "build:live": "nodemon --exec ./node_modules/.bin/ts-node -- ./index.ts" + "start": "ts-node ./index.ts" }, "author": "LaunchDarkly ", "license": "Apache-2.0", "devDependencies": { "@types/node": "8.0.4", - "nodemon": "1.11.0", "ts-node": "3.1.0", "typescript": "2.4.1" }, From ddbc0605345973b5c712b821db244a23cb549572 Mon Sep 17 00:00:00 2001 From: Eli Bishop Date: Fri, 1 Jul 2022 11:34:15 -0700 Subject: [PATCH 3/3] remove test SDK key (note, this was just a test environment, it's not a disaster if it is in the Git history) --- index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.ts b/index.ts index 788bdd4..a37065f 100644 --- a/index.ts +++ b/index.ts @@ -1,7 +1,7 @@ import * as LaunchDarkly from 'launchdarkly-node-server-sdk'; // Set sdkKey to your LaunchDarkly SDK key. -const sdkKey = "sdk-218759d7-ebb4-4311-8933-33fcc77b1850"; +const sdkKey = ""; // Set featureFlagKey to the feature flag key you want to evaluate. const featureFlagKey = "my-boolean-flag";