Skip to content

Commit 4cccfc9

Browse files
authored
Update test running instructions in README and other housekeeping (#186)
* Update test running instructions in README. * Don't format shared test data. * Run formatter. * Set husky pre-commit script as executable.
1 parent c1609e2 commit 4cccfc9

35 files changed

+751
-702
lines changed

.github/workflows/publish.yml

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,25 @@
11
name: Publish NPM Package
22

33
on:
4-
push:
5-
tags:
6-
- '*'
4+
push:
5+
tags:
6+
- '*'
77

88
jobs:
9-
package:
10-
runs-on: ubuntu-latest
11-
name: Publish NPM Package
9+
package:
10+
runs-on: ubuntu-latest
11+
name: Publish NPM Package
1212

13-
steps:
14-
- name: Cloning repo
15-
uses: actions/checkout@v3
13+
steps:
14+
- name: Cloning repo
15+
uses: actions/checkout@v3
1616

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

22-
- run: npm ci
23-
- run: npm run deploy
24-
env:
25-
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
22+
- run: npm ci
23+
- run: npm run deploy
24+
env:
25+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,37 @@
11
name: Unit/Integration Tests
22

33
on:
4-
pull_request:
5-
types:
6-
- opened
7-
- synchronize
8-
- reopened
9-
- ready_for_review
10-
push:
11-
branches:
12-
- main
4+
pull_request:
5+
types:
6+
- opened
7+
- synchronize
8+
- reopened
9+
- ready_for_review
10+
push:
11+
branches:
12+
- main
1313
jobs:
14-
build-and-test:
15-
strategy:
16-
matrix:
17-
node-version: [18.x, 20.x, 22.x]
18-
runs-on: ubuntu-latest
19-
steps:
20-
- uses: actions/checkout@v4
21-
with:
22-
submodules: true
23-
- uses: actions/setup-node@v4
24-
with:
25-
node-version: "${{ matrix.node-version }}"
26-
- name: cache node modules
27-
uses: actions/cache@v4
28-
with:
29-
path: ~/.npm # npm cache files are stored in `~/.npm` on Linux/macOS
30-
key: npm-${{ matrix.node-version }}-${{ hashFiles('package-lock.json') }}
31-
restore-keys: |
32-
npm-${{ matrix.node-version }}-${{ hashFiles('package-lock.json') }}
33-
npm-
34-
- run: npm ci
35-
- run: npm test
36-
env:
37-
CI: true
14+
build-and-test:
15+
strategy:
16+
matrix:
17+
node-version: [18.x, 20.x, 22.x]
18+
runs-on: ubuntu-latest
19+
steps:
20+
- uses: actions/checkout@v4
21+
with:
22+
submodules: true
23+
- uses: actions/setup-node@v4
24+
with:
25+
node-version: '${{ matrix.node-version }}'
26+
- name: cache node modules
27+
uses: actions/cache@v4
28+
with:
29+
path: ~/.npm # npm cache files are stored in `~/.npm` on Linux/macOS
30+
key: npm-${{ matrix.node-version }}-${{ hashFiles('package-lock.json') }}
31+
restore-keys: |
32+
npm-${{ matrix.node-version }}-${{ hashFiles('package-lock.json') }}
33+
npm-
34+
- run: npm ci
35+
- run: npm test
36+
env:
37+
CI: true

.husky/pre-commit

100644100755
File mode changed.

.prettierignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
*.json
1+
*.json
2+
tests/engine/engine-tests/engine-test-data

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,11 @@ If you encounter a bug or feature request we would like to hear about it. Before
2121

2222
## Testing
2323

24-
To run the local tests you need to run following command beforehand:
24+
To run the local tests you need to run following commands beforehand:
2525

2626
```bash
2727
git submodule add [email protected]:Flagsmith/engine-test-data.git tests/engine/engine-tests/engine-test-data/
28+
git submodule update --init --recursive
2829
```
2930

3031
## Get in touch

flagsmith-engine/environments/util.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ export function buildEnvironmentModel(environmentJSON: any) {
1515
);
1616
environmentModel.featureStates = featureStates;
1717
if (!!environmentJSON.identity_overrides) {
18-
environmentModel.identityOverrides = environmentJSON.identity_overrides.map((identityData: any) =>
19-
buildIdentityModel(identityData)
18+
environmentModel.identityOverrides = environmentJSON.identity_overrides.map(
19+
(identityData: any) => buildIdentityModel(identityData)
2020
);
2121
}
2222
return environmentModel;

flagsmith-engine/features/models.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { randomUUID as uuidv4 } from "node:crypto";
1+
import { randomUUID as uuidv4 } from 'node:crypto';
22
import { getHashedPercentateForObjIds } from '../utils/hashing/index.js';
33

44
export class FeatureModel {

flagsmith-engine/features/util.ts

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -19,23 +19,23 @@ export function buildFeatureStateModel(featuresStateModelJSON: any): FeatureStat
1919
featuresStateModelJSON.featurestate_uuid
2020
);
2121

22-
featureStateModel.featureSegment = featuresStateModelJSON.feature_segment ?
23-
buildFeatureSegment(featuresStateModelJSON.feature_segment) :
24-
undefined;
22+
featureStateModel.featureSegment = featuresStateModelJSON.feature_segment
23+
? buildFeatureSegment(featuresStateModelJSON.feature_segment)
24+
: undefined;
2525

2626
const multivariateFeatureStateValues = featuresStateModelJSON.multivariate_feature_state_values
2727
? featuresStateModelJSON.multivariate_feature_state_values.map((fsv: any) => {
28-
const featureOption = new MultivariateFeatureOptionModel(
29-
fsv.multivariate_feature_option.value,
30-
fsv.multivariate_feature_option.id
31-
);
32-
return new MultivariateFeatureStateValueModel(
33-
featureOption,
34-
fsv.percentage_allocation,
35-
fsv.id,
36-
fsv.mv_fs_value_uuid
37-
);
38-
})
28+
const featureOption = new MultivariateFeatureOptionModel(
29+
fsv.multivariate_feature_option.value,
30+
fsv.multivariate_feature_option.id
31+
);
32+
return new MultivariateFeatureStateValueModel(
33+
featureOption,
34+
fsv.percentage_allocation,
35+
fsv.id,
36+
fsv.mv_fs_value_uuid
37+
);
38+
})
3939
: [];
4040

4141
featureStateModel.multivariateFeatureStateValues = multivariateFeatureStateValues;

flagsmith-engine/identities/models.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export class IdentityModel {
1919
environmentApiKey: string,
2020
identifier: string,
2121
identityUuid?: string,
22-
djangoID?: number,
22+
djangoID?: number
2323
) {
2424
this.identityUuid = identityUuid || uuidv4();
2525
this.createdDate = Date.parse(created_date) || Date.now();

flagsmith-engine/segments/evaluators.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,11 +67,10 @@ export function traitsMatchSegmentCondition(
6767
}
6868
const traits = identityTraits.filter(t => t.traitKey === condition.property_);
6969
const trait = traits.length > 0 ? traits[0] : undefined;
70-
if (condition.operator === IS_SET ) {
70+
if (condition.operator === IS_SET) {
7171
return !!trait;
72-
} else if (condition.operator === IS_NOT_SET){
72+
} else if (condition.operator === IS_NOT_SET) {
7373
return trait == undefined;
7474
}
7575
return trait ? condition.matchesTraitValue(trait.traitValue) : false;
76-
7776
}

0 commit comments

Comments
 (0)