From 61424fae37e8d27ecc2b1f3066a137e1e119ebd7 Mon Sep 17 00:00:00 2001 From: Martin Zanoni Date: Wed, 8 Nov 2023 09:56:45 +0100 Subject: [PATCH 1/7] feat: update pipelines to support both packages --- .github/workflows/publish.yml | 22 +++++++++++++++++----- .github/workflows/unit-testing.yml | 27 ++++++++++++++++++++++++++- 2 files changed, 43 insertions(+), 6 deletions(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index d19e277..57e0c28 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -8,22 +8,34 @@ jobs: publish: runs-on: ubuntu-latest defaults: - run: - working-directory: ./packages/client steps: - uses: actions/checkout@v3 + - uses: actions/setup-node@v3 with: - node-version: 16 + node-version: 18 registry-url: https://registry.npmjs.com/ scope: '@relewise' - - name: Update version - uses: brettdorrans/write-version-to-file@master + + - name: Calculate environment variables + run: | + echo "TAG_NAME=${{ github.event.tag_name }}" >> $GITHUB_ENV + echo "PACKAGE_PATH=$(npm run package-path $TAG_NAME --silent)" >> $GITHUB_ENV + + - uses: brettdorrans/write-version-to-file@master + name: Update version + working-directory: ./packages/${ PACKAGE_PATH } with: filename: './packages/client/src/version.ts' placeholder: '${VERSION}' + - run: npm ci + working-directory: ./packages/${ PACKAGE_PATH } + - run: npm run publish + working-directory: ./packages/${ PACKAGE_PATH } + - run: npm publish --access public + working-directory: ./packages/${ PACKAGE_PATH } env: NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}} diff --git a/.github/workflows/unit-testing.yml b/.github/workflows/unit-testing.yml index 62c1ea0..41f8c51 100644 --- a/.github/workflows/unit-testing.yml +++ b/.github/workflows/unit-testing.yml @@ -10,7 +10,7 @@ env: node-version: '18' jobs: - test: + test-sdk: runs-on: ubuntu-latest defaults: run: @@ -33,6 +33,31 @@ jobs: name: Build Types - run: npm test name: Unit tests + - run: npm run integration-test + env: + npm_config_DATASET_ID: ${{secrets.INTEGRATIONTESTS_DATASET_ID}} + npm_config_API_KEY: ${{secrets.INTEGRATIONTESTS_API_KEY}} + name: Integration tests + + test-integrations: + runs-on: ubuntu-latest + defaults: + run: + working-directory: ./packages/integrations + strategy: + fail-fast: true + steps: + - uses: actions/checkout@v3 + - name: Use Node.js ${{ env.node-version }} + uses: actions/setup-node@v3 + with: + node-version: ${{ env.node-version }} + - run: npm ci + name: Install dependencies + - run: npm run build + name: Build + - run: npm test + name: Unit tests - run: npm run integration-test env: npm_config_DATASET_ID: ${{secrets.INTEGRATIONTESTS_DATASET_ID}} From 1faf862045c0e08a86f393a9bb9b3bdf3077e6c1 Mon Sep 17 00:00:00 2001 From: Martin Zanoni Date: Thu, 9 Nov 2023 11:10:52 +0100 Subject: [PATCH 2/7] update release pipeline --- .github/workflows/publish.yml | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 57e0c28..c4afce5 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -19,14 +19,16 @@ jobs: - name: Calculate environment variables run: | - echo "TAG_NAME=${{ github.event.tag_name }}" >> $GITHUB_ENV - echo "PACKAGE_PATH=$(npm run package-path $TAG_NAME --silent)" >> $GITHUB_ENV + echo "TAG_NAME=$(github.event.tag_name)" + echo "PACKAGE_PATH=$(github.event.tag_name.split('@')[0])" >> $GITHUB_ENV + echo "VERSION=$(github.event.tag_name.split('@')[1])" >> $GITHUB_ENV - uses: brettdorrans/write-version-to-file@master + if: ${{ PACKAGE_PATH == 'client' }} name: Update version working-directory: ./packages/${ PACKAGE_PATH } with: - filename: './packages/client/src/version.ts' + filename: './src/version.ts' placeholder: '${VERSION}' - run: npm ci From 63982cda0ad5eca8df4c9bbc1ffe989aecfd98f6 Mon Sep 17 00:00:00 2001 From: Martin Zanoni Date: Fri, 10 Nov 2023 12:15:49 +0100 Subject: [PATCH 3/7] add unit test --- .../integrations/tests/unit-tests/integrator.ts | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 packages/integrations/tests/unit-tests/integrator.ts diff --git a/packages/integrations/tests/unit-tests/integrator.ts b/packages/integrations/tests/unit-tests/integrator.ts new file mode 100644 index 0000000..d2f8503 --- /dev/null +++ b/packages/integrations/tests/unit-tests/integrator.ts @@ -0,0 +1,16 @@ + +import { expect, test } from '@jest/globals'; +import { Integrator } from '../../src'; + +const { npm_config_API_KEY: API_KEY, npm_config_DATASET_ID: DATASET_ID, npm_config_SERVER_URL: SERVER_URL } = process.env; + +const integrator = new Integrator(DATASET_ID!, API_KEY!, { serverUrl: SERVER_URL }); + +test('Batch size', async() => { + expect(integrator.batchSize).toBe(1_000); +}); + +test('Batch size', async() => { + integrator.batchSize = 2; + expect(integrator.batchSize).toBe(2); +}); \ No newline at end of file From f882e1a9c07171232ec54265568cb412847e1965 Mon Sep 17 00:00:00 2001 From: Martin Zanoni Date: Fri, 10 Nov 2023 12:16:32 +0100 Subject: [PATCH 4/7] fix pipeline error --- .github/workflows/publish.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index c4afce5..edc264d 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -7,7 +7,6 @@ on: jobs: publish: runs-on: ubuntu-latest - defaults: steps: - uses: actions/checkout@v3 From b437cb192de60c6972b63f98bebfc32fee7da120 Mon Sep 17 00:00:00 2001 From: Martin Zanoni Date: Fri, 10 Nov 2023 12:17:52 +0100 Subject: [PATCH 5/7] rename test --- .../tests/unit-tests/{integrator.ts => integrator.unit.test.ts} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename packages/integrations/tests/unit-tests/{integrator.ts => integrator.unit.test.ts} (100%) diff --git a/packages/integrations/tests/unit-tests/integrator.ts b/packages/integrations/tests/unit-tests/integrator.unit.test.ts similarity index 100% rename from packages/integrations/tests/unit-tests/integrator.ts rename to packages/integrations/tests/unit-tests/integrator.unit.test.ts From da4c2969a56e2f41e64480ddb7ac9bbc3ebc5416 Mon Sep 17 00:00:00 2001 From: Martin Zanoni Date: Fri, 10 Nov 2023 12:26:31 +0100 Subject: [PATCH 6/7] use dummy values --- .../integrations/tests/unit-tests/integrator.unit.test.ts | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/packages/integrations/tests/unit-tests/integrator.unit.test.ts b/packages/integrations/tests/unit-tests/integrator.unit.test.ts index d2f8503..e1b193c 100644 --- a/packages/integrations/tests/unit-tests/integrator.unit.test.ts +++ b/packages/integrations/tests/unit-tests/integrator.unit.test.ts @@ -2,9 +2,7 @@ import { expect, test } from '@jest/globals'; import { Integrator } from '../../src'; -const { npm_config_API_KEY: API_KEY, npm_config_DATASET_ID: DATASET_ID, npm_config_SERVER_URL: SERVER_URL } = process.env; - -const integrator = new Integrator(DATASET_ID!, API_KEY!, { serverUrl: SERVER_URL }); +const integrator = new Integrator('dummy value', 'dummy value'); test('Batch size', async() => { expect(integrator.batchSize).toBe(1_000); From a7c808bc898be552e0b580636b84005e8b48fcb6 Mon Sep 17 00:00:00 2001 From: Martin Zanoni Date: Fri, 10 Nov 2023 12:45:55 +0100 Subject: [PATCH 7/7] fix yml syntax error --- .github/workflows/publish.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index edc264d..6550511 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -16,7 +16,7 @@ jobs: registry-url: https://registry.npmjs.com/ scope: '@relewise' - - name: Calculate environment variables + - name: Calculate environment variables run: | echo "TAG_NAME=$(github.event.tag_name)" echo "PACKAGE_PATH=$(github.event.tag_name.split('@')[0])" >> $GITHUB_ENV