Skip to content

Commit af2f673

Browse files
Merge pull request #227 from splitio/commons-refactor
[WIP][POC] Replace js-client
2 parents d3ebe39 + 4708303 commit af2f673

23 files changed

Lines changed: 1803 additions & 661 deletions

File tree

.github/workflows/docker.yml

Lines changed: 0 additions & 63 deletions
This file was deleted.

.github/workflows/unstable.yml

Lines changed: 0 additions & 55 deletions
This file was deleted.
Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
inputSet:
2+
name: split_evaluator
3+
tags: {}
4+
identifier: split_evaluator
5+
orgIdentifier: PROD
6+
projectIdentifier: Harness_Split
7+
pipeline:
8+
identifier: deploy_qos_v3
9+
stages:
10+
- parallel:
11+
- stage:
12+
identifier: CI
13+
type: CI
14+
spec:
15+
execution:
16+
steps:
17+
- step:
18+
identifier: custom_tag
19+
type: Run
20+
spec:
21+
command: |-
22+
VERSION="$(cat package.json | grep version | head -1 | awk '{ print $2 }' | sed 's/[\",]//g' | tr -d '[[:space:]]')"
23+
24+
# Logging to DockeHub
25+
echo "$DOCKERHUB_TOKEN" | docker login -u "$DOCKERHUB_USERNAME" --password-stdin
26+
27+
# Install the necessary QEMU binaries for multi-platform builds
28+
docker run --privileged --rm tonistiigi/binfmt --install all
29+
envVariables:
30+
DOCKERHUB_USERNAME: infrasplit
31+
DOCKERHUB_TOKEN: <+secrets.getValue("dockerhub-infrasplit-token")>
32+
when:
33+
condition: "true"
34+
- step:
35+
identifier: BuildAndPush
36+
type: BuildAndPushDockerRegistry
37+
spec:
38+
repo: <+trigger.payload.repository.name>
39+
tags:
40+
- <+pipeline.stages.CI_split_evaluator.spec.execution.steps.custom_tag.output.outputVariables.VERSION>
41+
- latest
42+
dockerfile: ""
43+
context: ""
44+
buildArgs:
45+
CODEARTIFACT_AUTH_TOKEN: <+secrets.getValue("codeartifact-token")>
46+
GH_TOKEN: <+secrets.getValue("fme-github-netrc-token")>
47+
envVariables:
48+
PLUGIN_NO_PUSH: <+<+trigger.payload.ref>!="refs/heads/main"?"true":"false">
49+
PLUGIN_PLATFORM: linux/amd64,linux/arm64
50+
strategy:
51+
matrix:
52+
service:
53+
- <+trigger.payload.repository.name>
54+
- stage:
55+
identifier: ECR
56+
type: CI
57+
spec:
58+
execution:
59+
steps:
60+
- step:
61+
identifier: custom_tag
62+
type: Run
63+
spec:
64+
command: |-
65+
VERSION="$(cat package.json | grep version | head -1 | awk '{ print $2 }' | sed 's/[\",]//g' | tr -d '[[:space:]]')"
66+
67+
# Logging to DockeHub
68+
echo "$DOCKERHUB_TOKEN" | docker login -u "$DOCKERHUB_USERNAME" --password-stdin
69+
70+
# Install the necessary QEMU binaries for multi-platform builds
71+
docker run --privileged --rm tonistiigi/binfmt --install all
72+
envVariables:
73+
DOCKERHUB_USERNAME: infrasplit
74+
DOCKERHUB_TOKEN: <+secrets.getValue("dockerhub-infrasplit-token")>
75+
when:
76+
condition: "true"
77+
- step:
78+
identifier: BuildAndPushECR
79+
type: BuildAndPushECR
80+
spec:
81+
imageName: <+trigger.payload.repository.name>
82+
tags:
83+
- <+pipeline.stages.ECR_split_evaluator.spec.execution.steps.custom_tag.output.outputVariables.VERSION>
84+
- latest
85+
dockerfile: ""
86+
context: ""
87+
buildArgs:
88+
CODEARTIFACT_AUTH_TOKEN: <+secrets.getValue("codeartifact-token")>
89+
GH_TOKEN: <+secrets.getValue("fme-github-netrc-token")>
90+
envVariables:
91+
PLUGIN_NO_PUSH: <+<+trigger.payload.ref>!="refs/heads/main"?"true":"false">
92+
PLUGIN_PLATFORM: linux/amd64,linux/arm64
93+
strategy:
94+
matrix:
95+
service:
96+
- <+trigger.payload.repository.name>
97+
- stage:
98+
identifier: deploy
99+
type: Deployment
100+
spec:
101+
services:
102+
values: <+input>
103+
metadata:
104+
parallel: <+input>
105+
properties:
106+
ci:
107+
codebase:
108+
build:
109+
type: branch
110+
spec:
111+
branch: <+trigger.branch>
Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
inputSet:
2+
name: split_evaluator_unstable
3+
tags: {}
4+
identifier: split_evaluator_unstable
5+
orgIdentifier: PROD
6+
projectIdentifier: Harness_Split
7+
pipeline:
8+
identifier: deploy_qos_v3
9+
stages:
10+
- parallel:
11+
- stage:
12+
identifier: CI
13+
type: CI
14+
spec:
15+
execution:
16+
steps:
17+
- step:
18+
identifier: custom_tag
19+
type: Run
20+
spec:
21+
command: |-
22+
VERSION="$(git rev-parse --short HEAD)"
23+
24+
# Logging to DockeHub
25+
echo "$DOCKERHUB_TOKEN" | docker login -u "$DOCKERHUB_USERNAME" --password-stdin
26+
27+
# Install the necessary QEMU binaries for multi-platform builds
28+
docker run --privileged --rm tonistiigi/binfmt --install all
29+
envVariables:
30+
DOCKERHUB_USERNAME: infrasplit
31+
DOCKERHUB_TOKEN: <+secrets.getValue("dockerhub-infrasplit-token")>
32+
when:
33+
condition: "true"
34+
- step:
35+
identifier: BuildAndPush
36+
type: BuildAndPushDockerRegistry
37+
spec:
38+
repo: <+trigger.payload.repository.name>
39+
tags:
40+
- <+pipeline.stages.CI_split_evaluator.spec.execution.steps.custom_tag.output.outputVariables.VERSION>
41+
- latest
42+
dockerfile: ""
43+
context: ""
44+
buildArgs:
45+
CODEARTIFACT_AUTH_TOKEN: <+secrets.getValue("codeartifact-token")>
46+
GH_TOKEN: <+secrets.getValue("fme-github-netrc-token")>
47+
envVariables:
48+
PLUGIN_PLATFORM: linux/amd64,linux/arm64
49+
strategy:
50+
matrix:
51+
service:
52+
- <+trigger.payload.repository.name>
53+
- stage:
54+
identifier: ECR
55+
type: CI
56+
spec:
57+
execution:
58+
steps:
59+
- step:
60+
identifier: custom_tag
61+
type: Run
62+
spec:
63+
command: |-
64+
VERSION="$(git rev-parse --short HEAD)"
65+
66+
# Logging to DockeHub
67+
echo "$DOCKERHUB_TOKEN" | docker login -u "$DOCKERHUB_USERNAME" --password-stdin
68+
69+
# Install the necessary QEMU binaries for multi-platform builds
70+
docker run --privileged --rm tonistiigi/binfmt --install all
71+
envVariables:
72+
DOCKERHUB_USERNAME: infrasplit
73+
DOCKERHUB_TOKEN: <+secrets.getValue("dockerhub-infrasplit-token")>
74+
when:
75+
condition: "true"
76+
- step:
77+
identifier: BuildAndPushECR
78+
type: BuildAndPushECR
79+
spec:
80+
imageName: <+trigger.payload.repository.name>
81+
tags:
82+
- <+pipeline.stages.ECR_split_evaluator.spec.execution.steps.custom_tag.output.outputVariables.VERSION>
83+
- latest
84+
dockerfile: ""
85+
context: ""
86+
buildArgs:
87+
CODEARTIFACT_AUTH_TOKEN: <+secrets.getValue("codeartifact-token")>
88+
GH_TOKEN: <+secrets.getValue("fme-github-netrc-token")>
89+
envVariables:
90+
PLUGIN_PLATFORM: linux/amd64,linux/arm64
91+
strategy:
92+
matrix:
93+
service:
94+
- <+trigger.payload.repository.name>
95+
- stage:
96+
identifier: deploy
97+
type: Deployment
98+
spec:
99+
services:
100+
values: <+input>
101+
metadata:
102+
parallel: <+input>
103+
properties:
104+
ci:
105+
codebase:
106+
build:
107+
type: branch
108+
spec:
109+
branch: <+trigger.branch>

.jest/setEnvVars.js

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,9 @@ jest.mock('../sdk', () => ({
1414
getSplitFactory: jest.fn((settings) => {
1515
const { __dirname } = require('../utils/utils');
1616
const path = require('path');
17-
const { apiKeyMocksMap } = require('../utils/mocks')
18-
17+
const { apiKeyMocksMap } = require('../utils/mocks');
18+
const { syncManagerOfflineFactory } = require('@splitsoftware/splitio-commons/cjs/sync/offline/syncManagerOffline');
19+
const { splitsParserFromFileFactory } = require('../sdk/sync/splitsParserFromFile');
1920
// Clients are configured in localhost mode if there is a features file maped to the authorizationKey value in mocksMap
2021

2122
let features = '';
@@ -61,7 +62,16 @@ jest.mock('../sdk', () => ({
6162
};
6263

6364
let sdk = jest.requireActual('../sdk');
64-
const { factory, impressionsMode } = sdk.getSplitFactory(configForMock);
65+
66+
const moduleOverrider = (modules) => {
67+
if (features) {
68+
modules.splitApiFactory = undefined;
69+
modules.syncManagerFactory = syncManagerOfflineFactory(splitsParserFromFileFactory)
70+
modules.SignalListener = undefined;
71+
}
72+
};
73+
74+
const { factory, impressionsMode } = sdk.getSplitFactory(configForMock, moduleOverrider);
6575

6676
const mockedTelemetry = {
6777
splits: {

admin/__tests__/machine.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
const os = require('os');
2-
const ip = require('@splitsoftware/splitio/cjs/utils/ip');
2+
const ip = require('../../sdk/utils/ip');
33
const request = require('supertest');
44
const app = require('../../app');
55
const { expectError } = require('../../utils/testWrapper/index');

admin/admin.controller.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
const os = require('os');
2-
const ip = require('@splitsoftware/splitio/cjs/utils/ip');
2+
const ip = require('../sdk/utils/ip');
33

44
const utils = require('../utils/utils');
55
const environmentManager = require('../environmentManager').getInstance();

0 commit comments

Comments
 (0)