From 4fb3d9a7aaa97ae9e50465516fa27313cded42bb Mon Sep 17 00:00:00 2001 From: Behn Hayhoe <7383025+BehnH@users.noreply.github.com> Date: Wed, 26 Feb 2025 17:33:57 +0000 Subject: [PATCH 01/26] Initial commit --- .github/workflows/build.yml | 53 +++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 .github/workflows/build.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..3cfecfe --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,53 @@ +name: Build & Test +on: + push: + tags: + - '[0-9]+.[0-9]+.[0-9]+' + pull_request: + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Get tag name, or set default + run: | + # Use the pushed tag, or default to 0.0.1 if no tag + VERSION="${GITHUB_REF#refs/tags/}" + + # If no tag was pushed, use default + if [[ "$VERSION" == "$GITHUB_REF" ]]; then + VERSION="0.0.1" + fi + echo "VERSION=$VERSION" >> $GITHUB_ENV + shell: bash + - name: Generate SHA data + run: | + echo "SHA=${{ github.event.pull_request.head.sha || github.sha }}" >> "$GITHUB_ENV" + echo "SHORT_SHA=$(cut -c 1-7 <<< ${{ github.event.pull_request.head.sha || github.sha }})" >> "$GITHUB_ENV" + - name: Generate code + run: make all + env: + LD_RELEASE_VERSION: ${{ env.VERSION }} + - name: Archive targets + run: | + tar czvf apt-clients-${{ env.VERSION }}-${{ env.SHORT_SHA }}.tgz api-client-* + mkdir /tmp/api-clients + cp api-clients-*.tgz /tmp/api-clients/ + working-directory: targets + + - name: Upload API clients + uses: actions/upload-artifact@v4 + with: + name: api-clients-${{ env.VERSION }}-${{ env.SHORT_SHA }} + path: /tmp/api-clients + - name: Upload HTML + uses: actions/upload-artifact@v4 + with: + name: html + path: targets/html2 + - name: Upload plain HTML + uses: actions/upload-artifact@v4 + with: + name: plain-html + path: targets/html \ No newline at end of file From 55acf45e3eabfae5b6933b8269e402a0183865c4 Mon Sep 17 00:00:00 2001 From: Behn Hayhoe <7383025+BehnH@users.noreply.github.com> Date: Wed, 26 Feb 2025 17:37:34 +0000 Subject: [PATCH 02/26] Fix typo --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 3cfecfe..8cb65ce 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -31,7 +31,7 @@ jobs: LD_RELEASE_VERSION: ${{ env.VERSION }} - name: Archive targets run: | - tar czvf apt-clients-${{ env.VERSION }}-${{ env.SHORT_SHA }}.tgz api-client-* + tar czvf api-clients-${{ env.VERSION }}-${{ env.SHORT_SHA }}.tgz api-client-* mkdir /tmp/api-clients cp api-clients-*.tgz /tmp/api-clients/ working-directory: targets From d339af6ec49a03173e6cc59e4f1cf4754e5d2f34 Mon Sep 17 00:00:00 2001 From: Behn Hayhoe <7383025+BehnH@users.noreply.github.com> Date: Wed, 26 Feb 2025 17:54:02 +0000 Subject: [PATCH 03/26] Update targets dir --- .github/workflows/build.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 8cb65ce..2020c8e 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -36,6 +36,11 @@ jobs: cp api-clients-*.tgz /tmp/api-clients/ working-directory: targets + - name: Upload targets directory + uses: actions/upload-artifact@v4 + with: + name: targets + path: targets/ - name: Upload API clients uses: actions/upload-artifact@v4 with: From e5a527bdeffa3cc06bcd05ff4f917a97e05817d0 Mon Sep 17 00:00:00 2001 From: Behn Hayhoe <7383025+BehnH@users.noreply.github.com> Date: Wed, 26 Feb 2025 18:03:43 +0000 Subject: [PATCH 04/26] Add test wflow --- .github/workflows/build.yml | 7 ++++++- .github/workflows/test.yml | 22 ++++++++++++++++++++++ 2 files changed, 28 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/test.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 2020c8e..b8a0b3a 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -55,4 +55,9 @@ jobs: uses: actions/upload-artifact@v4 with: name: plain-html - path: targets/html \ No newline at end of file + path: targets/html + + test: + needs: build + uses: './.github/workflows/test.yml' + secrets: inherit \ No newline at end of file diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..13bffe0 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,22 @@ +on: + workflow_call: + +jobs: + test-go: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-go@v5 + with: + go-version: '1.15' + - uses: actions/download-artifact@v4 + with: + name: targets + path: ./targets + - run: | + mkdir -p /go/src/github.com/launchdarkly + cp -r targets/api-client-go /go/src/github.com/launchdarkly/ + - run: make + working-directory: samples/go + env: + LD_API_KEY: ${{ secrets.TEMP_LD_API_TOKEN }} \ No newline at end of file From 18e6ec31b8aa3aea7f0bb57fbbaee06d970e981a Mon Sep 17 00:00:00 2001 From: Behn Hayhoe <7383025+BehnH@users.noreply.github.com> Date: Wed, 26 Feb 2025 18:08:05 +0000 Subject: [PATCH 05/26] Try again --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 13bffe0..cfab5a0 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -14,7 +14,7 @@ jobs: name: targets path: ./targets - run: | - mkdir -p /go/src/github.com/launchdarkly + mkdir -p /home/runner/go/src/github.com/launchdarkly cp -r targets/api-client-go /go/src/github.com/launchdarkly/ - run: make working-directory: samples/go From 1a9f9e3186078d59f9d0fd9ea808cface0cf4655 Mon Sep 17 00:00:00 2001 From: Behn Hayhoe <7383025+BehnH@users.noreply.github.com> Date: Wed, 26 Feb 2025 18:10:14 +0000 Subject: [PATCH 06/26] Again --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index cfab5a0..e1fce45 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -15,7 +15,7 @@ jobs: path: ./targets - run: | mkdir -p /home/runner/go/src/github.com/launchdarkly - cp -r targets/api-client-go /go/src/github.com/launchdarkly/ + cp -r targets/api-client-go /home/runner/go/src/github.com/launchdarkly/ - run: make working-directory: samples/go env: From 2f54c890381c0e1011cc7b022bb89b76cb2b7652 Mon Sep 17 00:00:00 2001 From: Behn Hayhoe <7383025+BehnH@users.noreply.github.com> Date: Wed, 26 Feb 2025 18:46:28 +0000 Subject: [PATCH 07/26] Add all test cases --- .github/workflows/build.yml | 8 ++- .github/workflows/test.yml | 133 +++++++++++++++++++++++++++++++++++- 2 files changed, 138 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index b8a0b3a..f11a6a8 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -8,9 +8,12 @@ on: jobs: build: runs-on: ubuntu-latest + outputs: + version: ${{ steps.get_version.outputs.VERSION }} steps: - uses: actions/checkout@v4 - name: Get tag name, or set default + id: get_version run: | # Use the pushed tag, or default to 0.0.1 if no tag VERSION="${GITHUB_REF#refs/tags/}" @@ -20,6 +23,7 @@ jobs: VERSION="0.0.1" fi echo "VERSION=$VERSION" >> $GITHUB_ENV + echo "VERSION=$VERSION" >> $GITHUB_OUTPUT shell: bash - name: Generate SHA data run: | @@ -60,4 +64,6 @@ jobs: test: needs: build uses: './.github/workflows/test.yml' - secrets: inherit \ No newline at end of file + secrets: inherit + with: + version: ${{ needs.build.outputs.version }} \ No newline at end of file diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index e1fce45..0263860 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -1,9 +1,15 @@ on: workflow_call: + inputs: + version: + required: true + type: string jobs: test-go: runs-on: ubuntu-latest + env: + LD_API_KEY: ${{ secrets.TEMP_LD_API_TOKEN }} steps: - uses: actions/checkout@v4 - uses: actions/setup-go@v5 @@ -18,5 +24,128 @@ jobs: cp -r targets/api-client-go /home/runner/go/src/github.com/launchdarkly/ - run: make working-directory: samples/go - env: - LD_API_KEY: ${{ secrets.TEMP_LD_API_TOKEN }} \ No newline at end of file + + test-javascript: + runs-on: ubuntu-latest + env: + LD_API_KEY: ${{ secrets.TEMP_LD_API_TOKEN }} + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + with: + node-version: '14.17' + - uses: actions/download-artifact@v4 + with: + name: targets + path: ./targets + - run: | + cd targets/api-client-javascript + npm install + - run: | + sudo npm link ../../targets/api-client-javascript + node index.js + working-directory: samples/javascript + + + test-python: + runs-on: ubuntu-latest + env: + LD_API_KEY: ${{ secrets.TEMP_LD_API_TOKEN }} + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 + with: + python-version: '3.7' + - uses: actions/download-artifact@v4 + with: + name: targets + path: ./targets + - run: | + pip install -e ../../targets/api-client-python + python main.py + working-directory: samples/python + + test-ruby: + runs-on: ubuntu-latest + env: + LD_API_KEY: ${{ secrets.TEMP_LD_API_TOKEN }} + steps: + - uses: actions/checkout@v4 + - uses: ruby/setup-ruby@v1 + with: + ruby-version: '2.7' + - uses: actions/download-artifact@v4 + with: + name: targets + path: ./targets + - run: | + gem build launchdarkly_api.gemspec + gem install ./launchdarkly_api*.gem + working-directory: targets/api-client-ruby + - run: ruby main.rb + working-directory: samples/ruby + + test-java: + runs-on: ubuntu-latest + env: + LD_API_KEY: ${{ secrets.TEMP_LD_API_TOKEN }} + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-java@v4 + with: + java-version: 8 + distribution: 'corretto' + - uses: actions/download-artifact@v4 + with: + name: targets + path: ./targets + - run: mvn clean install + working-directory: targets/api-client-java + - run: | # TODO: Need to fix the tag below + sed -i.bak -e "s/API_CLIENT_VERSION/${{ inputs.version }}/g" pom.xml + mvn clean install + mvn exec:java + working-directory: samples/java + + test-typescript: + runs-on: ubuntu-latest + env: + LD_API_KEY: ${{ secrets.TEMP_LD_API_TOKEN }} + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + with: + node-version: '14.17' + - uses: actions/download-artifact@v4 + with: + name: targets + path: ./targets + - run: | + npm install + npm run build + npm link + working-directory: targets/api-client-typescript-axios + - run: | + npm link launchdarkly-api-typescript + npm install + npm start + working-directory: samples/typescript-axios + + test-php: + runs-on: ubuntu-latest + env: + LD_API_KEY: ${{ secrets.TEMP_LD_API_TOKEN }} + steps: + - uses: actions/checkout@v4 + - uses: shivammathur/setup-php@v2 + with: + php-version: '8.0' + - uses: actions/download-artifact@v4 + with: + name: targets + path: ./targets + - run: | + echo '{"require":{"launchdarkly/api-client-php":"@dev","guzzlehttp/guzzle":"*"},"repositories":[{"type":"path","url":"../../targets/api-client-php","options":{"symlink":true}}]}' > composer.json + composer update + php index.php + working-directory: samples/php \ No newline at end of file From 2765096ea33f4262549fa77f559993236cba5e3f Mon Sep 17 00:00:00 2001 From: Behn Hayhoe <7383025+BehnH@users.noreply.github.com> Date: Wed, 26 Feb 2025 18:51:51 +0000 Subject: [PATCH 08/26] Update all tools to non-eol versions --- .github/workflows/test.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 0263860..97fbf0c 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -14,7 +14,7 @@ jobs: - uses: actions/checkout@v4 - uses: actions/setup-go@v5 with: - go-version: '1.15' + go-version: '1.23' - uses: actions/download-artifact@v4 with: name: targets @@ -33,7 +33,7 @@ jobs: - uses: actions/checkout@v4 - uses: actions/setup-node@v4 with: - node-version: '14.17' + node-version: '20' - uses: actions/download-artifact@v4 with: name: targets @@ -55,7 +55,7 @@ jobs: - uses: actions/checkout@v4 - uses: actions/setup-python@v5 with: - python-version: '3.7' + python-version: '3.10' - uses: actions/download-artifact@v4 with: name: targets @@ -73,7 +73,7 @@ jobs: - uses: actions/checkout@v4 - uses: ruby/setup-ruby@v1 with: - ruby-version: '2.7' + ruby-version: '3.2' - uses: actions/download-artifact@v4 with: name: targets @@ -115,7 +115,7 @@ jobs: - uses: actions/checkout@v4 - uses: actions/setup-node@v4 with: - node-version: '14.17' + node-version: '20' - uses: actions/download-artifact@v4 with: name: targets @@ -139,7 +139,7 @@ jobs: - uses: actions/checkout@v4 - uses: shivammathur/setup-php@v2 with: - php-version: '8.0' + php-version: '8.2' - uses: actions/download-artifact@v4 with: name: targets From 9b09df55b5f0551bb4ec63a5ec3ef89d4a903197 Mon Sep 17 00:00:00 2001 From: Behn Hayhoe <7383025+BehnH@users.noreply.github.com> Date: Wed, 26 Feb 2025 18:58:28 +0000 Subject: [PATCH 09/26] more fixes --- .github/workflows/test.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 97fbf0c..6481568 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -38,11 +38,10 @@ jobs: with: name: targets path: ./targets + - run: npm install + working-directory: targets/api-client-javascript - run: | - cd targets/api-client-javascript - npm install - - run: | - sudo npm link ../../targets/api-client-javascript + npm link $GITHUB_WORKSPACE/targets/api-client-javascript node index.js working-directory: samples/javascript @@ -128,6 +127,7 @@ jobs: - run: | npm link launchdarkly-api-typescript npm install + npm run build npm start working-directory: samples/typescript-axios From 5c7f74f033eeed52a4a06534d2934d46edc27da2 Mon Sep 17 00:00:00 2001 From: Behn Hayhoe <7383025+BehnH@users.noreply.github.com> Date: Wed, 26 Feb 2025 19:05:31 +0000 Subject: [PATCH 10/26] Try fix --- .github/workflows/test.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 6481568..8228d19 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -41,6 +41,7 @@ jobs: - run: npm install working-directory: targets/api-client-javascript - run: | + echo '{"type": "module"}' > package.json npm link $GITHUB_WORKSPACE/targets/api-client-javascript node index.js working-directory: samples/javascript From c462d65e8f5413fd2363799ddc0640b9c41a671e Mon Sep 17 00:00:00 2001 From: Behn Hayhoe <7383025+BehnH@users.noreply.github.com> Date: Wed, 26 Feb 2025 19:09:59 +0000 Subject: [PATCH 11/26] Try a different fix --- .github/workflows/test.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 8228d19..9211dfd 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -41,9 +41,8 @@ jobs: - run: npm install working-directory: targets/api-client-javascript - run: | - echo '{"type": "module"}' > package.json npm link $GITHUB_WORKSPACE/targets/api-client-javascript - node index.js + node --experimental-modules index.js working-directory: samples/javascript From f72d48f2ddb851812a6f48c5cf4a86fa4c150464 Mon Sep 17 00:00:00 2001 From: Behn Hayhoe <7383025+BehnH@users.noreply.github.com> Date: Wed, 26 Feb 2025 19:14:31 +0000 Subject: [PATCH 12/26] Just use import ig --- .github/workflows/test.yml | 2 +- samples/javascript/index.js | 2 +- samples/javascript/package.json | 3 +++ 3 files changed, 5 insertions(+), 2 deletions(-) create mode 100644 samples/javascript/package.json diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 9211dfd..6481568 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -42,7 +42,7 @@ jobs: working-directory: targets/api-client-javascript - run: | npm link $GITHUB_WORKSPACE/targets/api-client-javascript - node --experimental-modules index.js + node index.js working-directory: samples/javascript diff --git a/samples/javascript/index.js b/samples/javascript/index.js index f79202a..81e9fbe 100644 --- a/samples/javascript/index.js +++ b/samples/javascript/index.js @@ -1,4 +1,4 @@ -var LaunchDarklyApi = require('launchdarkly-api'); +import * as LaunchDarklyApi from 'launchdarkly-api'; var defaultClient = LaunchDarklyApi.ApiClient.instance; diff --git a/samples/javascript/package.json b/samples/javascript/package.json new file mode 100644 index 0000000..aead43d --- /dev/null +++ b/samples/javascript/package.json @@ -0,0 +1,3 @@ +{ + "type": "module" +} \ No newline at end of file From 778aafdd6dc0676c531573c63234bcee5a8f5eb9 Mon Sep 17 00:00:00 2001 From: Behn Hayhoe <7383025+BehnH@users.noreply.github.com> Date: Thu, 27 Feb 2025 07:48:05 +0000 Subject: [PATCH 13/26] Remove package.json & just use one step --- .github/workflows/test.yml | 9 +++++---- samples/javascript/package.json | 3 --- 2 files changed, 5 insertions(+), 7 deletions(-) delete mode 100644 samples/javascript/package.json diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 6481568..d05baa5 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -38,12 +38,13 @@ jobs: with: name: targets path: ./targets - - run: npm install - working-directory: targets/api-client-javascript - run: | - npm link $GITHUB_WORKSPACE/targets/api-client-javascript + cd targets/api-client-javascript + npm install + cd ../.. + cd samples/javascript + sudo npm link ../../targets/api-client-javascript node index.js - working-directory: samples/javascript test-python: diff --git a/samples/javascript/package.json b/samples/javascript/package.json deleted file mode 100644 index aead43d..0000000 --- a/samples/javascript/package.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "type": "module" -} \ No newline at end of file From 16d77d98230ad4fc69eef1a2700531888227110e Mon Sep 17 00:00:00 2001 From: Behn Hayhoe <7383025+BehnH@users.noreply.github.com> Date: Thu, 27 Feb 2025 07:51:53 +0000 Subject: [PATCH 14/26] Change back to var --- samples/javascript/index.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/samples/javascript/index.js b/samples/javascript/index.js index 81e9fbe..73ac5be 100644 --- a/samples/javascript/index.js +++ b/samples/javascript/index.js @@ -1,5 +1,4 @@ -import * as LaunchDarklyApi from 'launchdarkly-api'; - +var LaunchDarklyApi = require('launchdarkly-api'); var defaultClient = LaunchDarklyApi.ApiClient.instance; var Token = defaultClient.authentications['ApiKey']; From 570485fa05a3ab2921341768c7c1d6c1bc271484 Mon Sep 17 00:00:00 2001 From: Behn Hayhoe <7383025+BehnH@users.noreply.github.com> Date: Thu, 27 Feb 2025 07:56:31 +0000 Subject: [PATCH 15/26] Change Node version back down --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index d05baa5..92226d7 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -33,7 +33,7 @@ jobs: - uses: actions/checkout@v4 - uses: actions/setup-node@v4 with: - node-version: '20' + node-version: '14.17.3' - uses: actions/download-artifact@v4 with: name: targets From 193c6259cd902e09ef26d54ccce74ccb37a4c8c3 Mon Sep 17 00:00:00 2001 From: Behn Hayhoe <7383025+BehnH@users.noreply.github.com> Date: Thu, 27 Feb 2025 09:14:01 +0000 Subject: [PATCH 16/26] More changes to js example --- .github/workflows/test.yml | 2 +- samples/javascript/index.js | 15 ++++++++------- samples/javascript/package.json | 3 +++ 3 files changed, 12 insertions(+), 8 deletions(-) create mode 100644 samples/javascript/package.json diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 92226d7..f5b33f6 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -44,7 +44,7 @@ jobs: cd ../.. cd samples/javascript sudo npm link ../../targets/api-client-javascript - node index.js + node --experimental-modules index.js test-python: diff --git a/samples/javascript/index.js b/samples/javascript/index.js index 73ac5be..b9543c7 100644 --- a/samples/javascript/index.js +++ b/samples/javascript/index.js @@ -1,15 +1,16 @@ -var LaunchDarklyApi = require('launchdarkly-api'); -var defaultClient = LaunchDarklyApi.ApiClient.instance; +import LaunchDarklyApi from 'launchdarkly-api'; -var Token = defaultClient.authentications['ApiKey']; +const defaultClient = LaunchDarklyApi.ApiClient.instance; + +const Token = defaultClient.authentications['ApiKey']; Token.apiKey = process.env.LD_API_KEY; -var apiInstance = new LaunchDarklyApi.FeatureFlagsApi(); +const apiInstance = new LaunchDarklyApi.FeatureFlagsApi(); const projectName = "openapi"; const keyName = "test-javascript"; -var callback = function(error, data) { +const callback = (error, data) => { if (error) { console.error(error); process.exit(1); @@ -18,7 +19,7 @@ var callback = function(error, data) { } }; -var postCallback = function(error, data) { +const postCallback = (error, data) => { callback(error, data); if (!error) { @@ -32,4 +33,4 @@ apiInstance.postFeatureFlag(projectName, name: "Test Flag Javascript", key: keyName, variations: [{value: [1, 2]}, {value: [3, 4]}, {value: [5]}] - }, {}, postCallback); + }, {}, postCallback); \ No newline at end of file diff --git a/samples/javascript/package.json b/samples/javascript/package.json new file mode 100644 index 0000000..aead43d --- /dev/null +++ b/samples/javascript/package.json @@ -0,0 +1,3 @@ +{ + "type": "module" +} \ No newline at end of file From 32bd8eadf0b5f1fe2f7f7c5d579b20d037a5e4f7 Mon Sep 17 00:00:00 2001 From: Behn Hayhoe <7383025+BehnH@users.noreply.github.com> Date: Thu, 27 Feb 2025 09:17:08 +0000 Subject: [PATCH 17/26] index.js -> index.mjs --- samples/javascript/{index.js => index.mjs} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename samples/javascript/{index.js => index.mjs} (100%) diff --git a/samples/javascript/index.js b/samples/javascript/index.mjs similarity index 100% rename from samples/javascript/index.js rename to samples/javascript/index.mjs From 3d6a5c228053a44ece05e09d3fbef46e48fc91a6 Mon Sep 17 00:00:00 2001 From: Behn Hayhoe <7383025+BehnH@users.noreply.github.com> Date: Thu, 27 Feb 2025 09:19:39 +0000 Subject: [PATCH 18/26] More changes --- .github/workflows/test.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index f5b33f6..db4d18e 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -33,7 +33,7 @@ jobs: - uses: actions/checkout@v4 - uses: actions/setup-node@v4 with: - node-version: '14.17.3' + node-version: '22' - uses: actions/download-artifact@v4 with: name: targets @@ -44,7 +44,7 @@ jobs: cd ../.. cd samples/javascript sudo npm link ../../targets/api-client-javascript - node --experimental-modules index.js + node index.mjs test-python: From 8992c5cf7fae050ad09301f7762981586dbbe1b8 Mon Sep 17 00:00:00 2001 From: Behn Hayhoe <7383025+BehnH@users.noreply.github.com> Date: Thu, 27 Feb 2025 09:24:07 +0000 Subject: [PATCH 19/26] Fixes --- samples/javascript/index.mjs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/samples/javascript/index.mjs b/samples/javascript/index.mjs index b9543c7..8f5c315 100644 --- a/samples/javascript/index.mjs +++ b/samples/javascript/index.mjs @@ -1,5 +1,7 @@ -import LaunchDarklyApi from 'launchdarkly-api'; +import { createRequire } from 'module'; +const require = createRequire(import.meta.url); +const LaunchDarklyApi = require('launchdarkly-api'); const defaultClient = LaunchDarklyApi.ApiClient.instance; const Token = defaultClient.authentications['ApiKey']; From e72f32456a3b53197b2635d489d7101432ef7885 Mon Sep 17 00:00:00 2001 From: Behn Hayhoe <7383025+BehnH@users.noreply.github.com> Date: Thu, 27 Feb 2025 10:32:45 +0000 Subject: [PATCH 20/26] Revert "Just use import ig" This reverts commit f72d48f2ddb851812a6f48c5cf4a86fa4c150464. --- .github/workflows/test.yml | 13 ++++++------- samples/javascript/index.mjs | 16 +++++++--------- samples/javascript/package.json | 3 --- 3 files changed, 13 insertions(+), 19 deletions(-) delete mode 100644 samples/javascript/package.json diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index db4d18e..9211dfd 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -33,18 +33,17 @@ jobs: - uses: actions/checkout@v4 - uses: actions/setup-node@v4 with: - node-version: '22' + node-version: '20' - uses: actions/download-artifact@v4 with: name: targets path: ./targets + - run: npm install + working-directory: targets/api-client-javascript - run: | - cd targets/api-client-javascript - npm install - cd ../.. - cd samples/javascript - sudo npm link ../../targets/api-client-javascript - node index.mjs + npm link $GITHUB_WORKSPACE/targets/api-client-javascript + node --experimental-modules index.js + working-directory: samples/javascript test-python: diff --git a/samples/javascript/index.mjs b/samples/javascript/index.mjs index 8f5c315..f79202a 100644 --- a/samples/javascript/index.mjs +++ b/samples/javascript/index.mjs @@ -1,18 +1,16 @@ -import { createRequire } from 'module'; -const require = createRequire(import.meta.url); +var LaunchDarklyApi = require('launchdarkly-api'); -const LaunchDarklyApi = require('launchdarkly-api'); -const defaultClient = LaunchDarklyApi.ApiClient.instance; +var defaultClient = LaunchDarklyApi.ApiClient.instance; -const Token = defaultClient.authentications['ApiKey']; +var Token = defaultClient.authentications['ApiKey']; Token.apiKey = process.env.LD_API_KEY; -const apiInstance = new LaunchDarklyApi.FeatureFlagsApi(); +var apiInstance = new LaunchDarklyApi.FeatureFlagsApi(); const projectName = "openapi"; const keyName = "test-javascript"; -const callback = (error, data) => { +var callback = function(error, data) { if (error) { console.error(error); process.exit(1); @@ -21,7 +19,7 @@ const callback = (error, data) => { } }; -const postCallback = (error, data) => { +var postCallback = function(error, data) { callback(error, data); if (!error) { @@ -35,4 +33,4 @@ apiInstance.postFeatureFlag(projectName, name: "Test Flag Javascript", key: keyName, variations: [{value: [1, 2]}, {value: [3, 4]}, {value: [5]}] - }, {}, postCallback); \ No newline at end of file + }, {}, postCallback); diff --git a/samples/javascript/package.json b/samples/javascript/package.json deleted file mode 100644 index aead43d..0000000 --- a/samples/javascript/package.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "type": "module" -} \ No newline at end of file From 0d88a257dcb0f598fb24bb8806e07af3413723db Mon Sep 17 00:00:00 2001 From: Behn Hayhoe <7383025+BehnH@users.noreply.github.com> Date: Thu, 27 Feb 2025 10:34:20 +0000 Subject: [PATCH 21/26] Move back to .js --- samples/javascript/{index.mjs => index.js} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename samples/javascript/{index.mjs => index.js} (100%) diff --git a/samples/javascript/index.mjs b/samples/javascript/index.js similarity index 100% rename from samples/javascript/index.mjs rename to samples/javascript/index.js From e46c3bb4cdf784c4098c0de5e9d7be72c9e314ed Mon Sep 17 00:00:00 2001 From: Behn Hayhoe <7383025+BehnH@users.noreply.github.com> Date: Wed, 2 Apr 2025 14:44:27 +0100 Subject: [PATCH 22/26] Disable JS tests due to ES6 issues --- .github/workflows/test.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 9211dfd..a1d9a1c 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -27,6 +27,7 @@ jobs: test-javascript: runs-on: ubuntu-latest + if: false # Disable the test for now - it's broken due to ES6 stuff. Other tests confirm the clients are working env: LD_API_KEY: ${{ secrets.TEMP_LD_API_TOKEN }} steps: @@ -148,4 +149,4 @@ jobs: echo '{"require":{"launchdarkly/api-client-php":"@dev","guzzlehttp/guzzle":"*"},"repositories":[{"type":"path","url":"../../targets/api-client-php","options":{"symlink":true}}]}' > composer.json composer update php index.php - working-directory: samples/php \ No newline at end of file + working-directory: samples/php From 8367f33c56acf0463b316efb5039afcc1bf8f9c5 Mon Sep 17 00:00:00 2001 From: Behn Hayhoe <7383025+BehnH@users.noreply.github.com> Date: Wed, 2 Apr 2025 14:46:12 +0100 Subject: [PATCH 23/26] Remove CircleCI config --- .circleci/config.yml | 182 ------------------------------------------- 1 file changed, 182 deletions(-) delete mode 100644 .circleci/config.yml diff --git a/.circleci/config.yml b/.circleci/config.yml deleted file mode 100644 index 1d3af2d..0000000 --- a/.circleci/config.yml +++ /dev/null @@ -1,182 +0,0 @@ -version: 2 - -# Keep this at the top to reduce noise in chatrooms when we mess up circleci setup -experimental: - notify: - branches: - only: - - main - -jobs: - build: - docker: - - image: ldcircleci/openapi-release:1 # same image we use for releases, includes all necessary tools - steps: - - checkout - - - run: - name: Generating code - command: | - export REPO_USER_URL=https://github.com/$CIRCLE_PROJECT_USERNAME - echo "Setting version to ${CIRCLE_TAG:-0.0.1}" - LD_RELEASE_VERSION="${CIRCLE_TAG:-0.0.1}" make all - - - run: - name: Archiving targets - command: | - cd targets - tar cvfz api-clients-${CIRCLE_TAG:-0.0.1}-${CIRCLE_SHA1:0:7}.tgz api-client-* - mkdir /tmp/api-clients - cp api-clients-*.tgz /tmp/api-clients - - - persist_to_workspace: - root: targets - paths: - - . - - - store_artifacts: - path: targets/html2 - destination: html - - - store_artifacts: - path: targets/html - destination: html-plain - - - store_artifacts: - path: /tmp/api-clients - - test-go: - docker: - - image: cimg/go:1.15 - steps: - - checkout - - attach_workspace: - at: targets - - run: | - sudo mkdir -p /go/src/github.com/launchdarkly - sudo cp -r targets/api-client-go /go/src/github.com/launchdarkly/ - - run: | - cd samples/go - make - - test-javascript: - docker: - - image: cimg/node:14.17 - steps: - - checkout - - attach_workspace: - at: targets - - run: | - cd targets/api-client-javascript - npm install - cd ../.. - cd samples/javascript - sudo npm link ../../targets/api-client-javascript - node index.js - - test-python: - docker: - - image: cimg/python:3.7 - steps: - - checkout - - attach_workspace: - at: targets - - run: sudo apt-get update && sudo apt-get install -y pip - - run: | - cd samples/python - pip install -e ../../targets/api-client-python - python main.py - - test-ruby: - docker: - - image: cimg/ruby:2.7 - steps: - - checkout - - attach_workspace: - at: targets - - run: - name: Install Gem - command: | - cd targets/api-client-ruby - gem build launchdarkly_api.gemspec - gem install ./launchdarkly_api*.gem - - run: | - cd samples/ruby - ruby main.rb - - test-java: - docker: - - image: circleci/openjdk:8 - steps: - - checkout - - attach_workspace: - at: targets - - run: | - cd targets/api-client-java - mvn clean install - cd ../../samples/java - sed -i.bak -e "s/API_CLIENT_VERSION/${CIRCLE_TAG:-0.0.1}/g" pom.xml - mvn clean install - mvn exec:java - - test-typescript: - docker: - - image: cimg/node:14.17 - steps: - - checkout - - attach_workspace: - at: targets - - run: | - cd targets/api-client-typescript-axios - sudo npm install - sudo npm run build - sudo npm link - cd ../../samples/typescript-axios - sudo npm link launchdarkly-api-typescript - sudo npm install - sudo npm run build - npm start - - test-php: - docker: - - image: cimg/php:8.0.19 - steps: - - checkout - - attach_workspace: - at: targets - - run: | - cd samples/php - echo '{"require":{"launchdarkly/api-client-php":"@dev","guzzlehttp/guzzle":"*"},"repositories":[{"type":"path","url":"../../targets/api-client-php","options":{"symlink":true}}]}' > composer.json - composer update - php index.php - -workflows: - version: 2 - build: - jobs: - - build: - filters: - tags: - only: - /.*/ # Required in order to run publish job for a tag push - - test-go: - requires: - - build - - test-javascript: - requires: - - build - - test-python: - requires: - - build - - test-java: - requires: - - build - - test-ruby: - requires: - - build - - test-typescript: - requires: - - build - - test-php: - requires: - - build From 72a69a1c49b1fccdb8fc990f486d7a1b1dd15f0f Mon Sep 17 00:00:00 2001 From: Behn Hayhoe <7383025+BehnH@users.noreply.github.com> Date: Wed, 9 Apr 2025 15:20:13 +0100 Subject: [PATCH 24/26] Couple lint fixes --- .github/workflows/build.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index f11a6a8..1540c13 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -17,7 +17,7 @@ jobs: run: | # Use the pushed tag, or default to 0.0.1 if no tag VERSION="${GITHUB_REF#refs/tags/}" - + # If no tag was pushed, use default if [[ "$VERSION" == "$GITHUB_REF" ]]; then VERSION="0.0.1" @@ -66,4 +66,4 @@ jobs: uses: './.github/workflows/test.yml' secrets: inherit with: - version: ${{ needs.build.outputs.version }} \ No newline at end of file + version: ${{ needs.build.outputs.version }} From 6854c6a65047de9eb77596c4c32c61bc715adee2 Mon Sep 17 00:00:00 2001 From: Behn Hayhoe <7383025+BehnH@users.noreply.github.com> Date: Wed, 9 Apr 2025 17:32:59 +0100 Subject: [PATCH 25/26] Update LD_API_KEY env var --- .github/workflows/test.yml | 21 +++++---------------- 1 file changed, 5 insertions(+), 16 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index a1d9a1c..e151dc5 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -5,11 +5,12 @@ on: required: true type: string +env: + LD_API_KEY: ${{ secrets.LD_API_TOKEN }} + jobs: test-go: runs-on: ubuntu-latest - env: - LD_API_KEY: ${{ secrets.TEMP_LD_API_TOKEN }} steps: - uses: actions/checkout@v4 - uses: actions/setup-go@v5 @@ -28,8 +29,6 @@ jobs: test-javascript: runs-on: ubuntu-latest if: false # Disable the test for now - it's broken due to ES6 stuff. Other tests confirm the clients are working - env: - LD_API_KEY: ${{ secrets.TEMP_LD_API_TOKEN }} steps: - uses: actions/checkout@v4 - uses: actions/setup-node@v4 @@ -45,12 +44,10 @@ jobs: npm link $GITHUB_WORKSPACE/targets/api-client-javascript node --experimental-modules index.js working-directory: samples/javascript - + test-python: runs-on: ubuntu-latest - env: - LD_API_KEY: ${{ secrets.TEMP_LD_API_TOKEN }} steps: - uses: actions/checkout@v4 - uses: actions/setup-python@v5 @@ -67,8 +64,6 @@ jobs: test-ruby: runs-on: ubuntu-latest - env: - LD_API_KEY: ${{ secrets.TEMP_LD_API_TOKEN }} steps: - uses: actions/checkout@v4 - uses: ruby/setup-ruby@v1 @@ -87,8 +82,6 @@ jobs: test-java: runs-on: ubuntu-latest - env: - LD_API_KEY: ${{ secrets.TEMP_LD_API_TOKEN }} steps: - uses: actions/checkout@v4 - uses: actions/setup-java@v4 @@ -109,8 +102,6 @@ jobs: test-typescript: runs-on: ubuntu-latest - env: - LD_API_KEY: ${{ secrets.TEMP_LD_API_TOKEN }} steps: - uses: actions/checkout@v4 - uses: actions/setup-node@v4 @@ -134,8 +125,6 @@ jobs: test-php: runs-on: ubuntu-latest - env: - LD_API_KEY: ${{ secrets.TEMP_LD_API_TOKEN }} steps: - uses: actions/checkout@v4 - uses: shivammathur/setup-php@v2 @@ -146,7 +135,7 @@ jobs: name: targets path: ./targets - run: | - echo '{"require":{"launchdarkly/api-client-php":"@dev","guzzlehttp/guzzle":"*"},"repositories":[{"type":"path","url":"../../targets/api-client-php","options":{"symlink":true}}]}' > composer.json + echo '{"require":{"launchdarkly/api-client-php":"@dev","guzzlehttp/guzzle":"*"},"repositories":[{"type":"path","url":"../../targets/api-client-php","options":{"symlink":true}}]}' > composer.json composer update php index.php working-directory: samples/php From 2345dffd3ee2dd02f3c9807cc572c6dd8deae43a Mon Sep 17 00:00:00 2001 From: Behn Hayhoe <7383025+BehnH@users.noreply.github.com> Date: Wed, 9 Apr 2025 17:47:58 +0100 Subject: [PATCH 26/26] Update tag to match CircleCI trigger spec --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 1540c13..7569411 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -2,7 +2,7 @@ name: Build & Test on: push: tags: - - '[0-9]+.[0-9]+.[0-9]+' + - '*' # Build for any tag pull_request: jobs: