Skip to content

Commit ee29275

Browse files
JGreenleeshankari
authored andcommitted
add validate-configs workflow
index.d.ts is based on appConfigTypes.ts from e-mission-phone https://github.com/e-mission/e-mission-phone/blob/30e4b78ff64596b20cea811000f6d5b11a6b6cae/www/js/types/appConfigTypes.ts, moved here to be the source of truth for supported config options. Added package.json so this functions as a minimal npm package and the types can be used downstream on e-mission-phone In a workflow, we can generate JSON schema from the typescript declarations and validate all the configs accordingly. This will help us catch mistakes in config creation or edits and will allow us to set up auto-merge for trusted PRs Adding this validation exposed several inconsistencies in the config, which I have also fixed in this commit: e-mission/op-admin-dashboard#167 (comment)
1 parent 0f51034 commit ee29275

13 files changed

+205
-27
lines changed
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: Validate Configs
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
branches: [main]
8+
9+
jobs:
10+
validate_configs:
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- name: Checkout code
15+
uses: actions/checkout@v3
16+
17+
- name: Set up Node.js
18+
uses: actions/setup-node@v3
19+
with:
20+
node-version: '18'
21+
22+
- name: Generate JSON schema with typescript-json-schema
23+
run: |
24+
npm install -g typescript-json-schema
25+
npx typescript-json-schema index.d.ts DeploymentConfig --noExtraProps --required --out config.schema.json
26+
27+
- name: Validate all configs against config.schema.json
28+
uses: cardinalby/schema-validator-action@v3
29+
with:
30+
file: 'configs/*.json'
31+
schema: 'config.schema.json'

configs/ccebikes.nrel-op.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
2+
"url_abbreviation": "ccebikes",
23
"version": 1,
3-
"name": "ccebikes",
44
"ts": 1655143472,
55
"server": {
66
"connectUrl": "https://ccebikes-openpath.nrel.gov/api/",

configs/choose-your-ride.nrel-op.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
2+
"url_abbreviation": "choose-your-ride",
23
"version": 1,
3-
"name": "choose-your-ride",
44
"ts": 1655143472,
55
"server": {
66
"connectUrl": "https://choose-your-ride-openpath.nrel.gov/api/",

configs/cortezebikes.nrel-op.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
2+
"url_abbreviation": "cortezebikes",
23
"version": 1,
3-
"name": "cortezebikes",
44
"ts": 1655143472,
55
"server": {
66
"connectUrl": "https://cortezebikes-openpath.nrel.gov/api/",

configs/dev-emulator-program.nrel-op.json

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,6 @@
1818
"short_textual_description": "OpenPATH is the only open source platform for instrumenting mobility patterns. We welcome contributions and pull requests.",
1919
"why_we_collect": "So that you can see how OpenPATH works",
2020
"research_questions": ["Comparing the open-access group (no intervention) and programs that provide interventions.", "General monitoring of mobility trends for travel behavior, including shifts to travel behavior and the introduction of new mobility modes."]
21-
},
22-
"es":{
23-
"deployment_partner_name": "Laboratorio Nacional de Energías Renovables (NREL)"
2421
}
2522
}
2623
},

configs/dev-emulator-study.nrel-op.json

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,6 @@
1717
"short_textual_description": "OpenPATH is the only open source platform for instrumenting mobility patterns. We welcome contributions and pull requests.",
1818
"why_we_collect": "So that you can see how OpenPATH works",
1919
"research_questions": ["Comparing the open-access group (no intervention) and programs that provide interventions.", "General monitoring of mobility trends for travel behavior, including shifts to travel behavior and the introduction of new mobility modes."]
20-
},
21-
"es":{
22-
"deployment_partner_name": "Laboratorio Nacional de Energías Renovables (NREL)"
2320
}
2421
}
2522
},

configs/dev-emulator-timeuse.nrel-op.json

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,6 @@
1818
"short_textual_description": "OpenPATH is the only open source platform for instrumenting mobility patterns. We welcome contributions and pull requests.",
1919
"why_we_collect": "So that you can see how OpenPATH works",
2020
"research_questions": ["Comparing the open-access group (no intervention) and programs that provide interventions.", "General monitoring of mobility trends for travel behavior, including shifts to travel behavior and the introduction of new mobility modes."]
21-
},
22-
"es":{
23-
"deployment_partner_name": "Laboratorio Nacional de Energías Renovables (NREL)"
2421
}
2522
}
2623
},

configs/dfc-fermata.nrel-op.json

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@
104104
"year": 2014,
105105
"color": "red",
106106
"engine": "ICE",
107-
"mpg": 33
107+
"mpge": 33
108108
}
109109
},
110110
{
@@ -122,7 +122,7 @@
122122
"year": 2011,
123123
"color": "silver",
124124
"engine": "HEV",
125-
"mpg": 48
125+
"mpge": 48
126126
}
127127
},
128128
{
@@ -208,7 +208,7 @@
208208
"year": 1999,
209209
"color": "red",
210210
"engine": "ICE",
211-
"mpg": 21
211+
"mpge": 21
212212
}
213213
},
214214
{
@@ -401,7 +401,7 @@
401401
"metrics": {
402402
"include_test_users": false,
403403
"phone_dashboard_ui": {
404-
"sections": ["summary", "surveys", "engagement"],
404+
"sections": ["footprint", "surveys", "travel"],
405405
"metric_list": {
406406
"count": [ "primary_ble_sensed_mode" ],
407407
"distance": [ "primary_ble_sensed_mode" ],
@@ -410,12 +410,6 @@
410410
},
411411
"footprint_options": {
412412
"unlabeled_uncertainty": false
413-
},
414-
"summary_options": {
415-
"summary_metrics": ["distance", "count", "duration", "response_count"]
416-
},
417-
"engagement_options": {
418-
"leaderboard_metric": ["distance", "e_car"]
419413
}
420414
}
421415
},

configs/ebikegj.nrel-op.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
2+
"url_abbreviation": "ebikegj",
23
"version": 1,
3-
"name": "ebikegj",
44
"ts": 1655143472,
55
"server": {
66
"connectUrl": "https://ebikegj-openpath.nrel.gov/api/",

configs/ebikethere-garfield-county.nrel-op.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
2+
"url_abbreviation": "ebikethere-garfield-county",
23
"version": 2,
3-
"name": "ebikethere-garfield-county",
44
"ts": 1655143472,
55
"server": {
66
"connectUrl": "https://ebikethere-garfield-county-openpath.nrel.gov/api/",

0 commit comments

Comments
 (0)