Skip to content

Commit 3c3d27f

Browse files
authored
feat: static typing and safe builds (#63)
* Fixed typing in unity and vbl base * Remaking build, moved unity to util * Type safe schema build * Draft generator, failing enums * Correct build * Fixed typing issues and rebuild * Build models and static analysis * Version bump, prep for 1.0 * Fixed CI * Specify latest python * Enable checkout and fetch on repo * chore: Autoformat code * Rename format commit message * Add refs to enable workflow commit * Fix some build spacing --------- Co-authored-by: kjy5 <[email protected]>
1 parent c34cd3d commit 3c3d27f

25 files changed

+455
-314
lines changed

.config/dotnet-tools.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"version": 1,
3+
"isRoot": true,
4+
"tools": {
5+
"csharpier": {
6+
"version": "0.30.3",
7+
"commands": [
8+
"dotnet-csharpier"
9+
]
10+
}
11+
}
12+
}

.github/dependabot.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,14 @@ updates:
1313
pip:
1414
patterns:
1515
- '*'
16+
- package-ecosystem: "nuget" # See documentation for possible values
17+
directory: "/" # Location of package manifests
18+
schedule:
19+
interval: "weekly"
20+
groups:
21+
pip:
22+
patterns:
23+
- '*'
1624
- package-ecosystem: "github-actions" # See documentation for possible values
1725
directory: ".github/workflows" # Location of package manifests
1826
schedule:
Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Build
1+
name: Build Models
22

33
on:
44
pull_request:
@@ -14,20 +14,39 @@ jobs:
1414
steps:
1515
- name: Checkout repository
1616
uses: actions/checkout@v4
17+
with:
18+
ref: ${{ github.head_ref }}
19+
token: ${{ secrets.WORKFLOW_COMMIT_TOKEN }}
1720

1821
- name: 🐍 Setup Python
1922
uses: actions/setup-python@v5
2023
with:
2124
python-version: '3.x'
2225
cache: 'pip'
26+
27+
- name: 🌐 Setup .NET
28+
uses: actions/setup-dotnet@v4
29+
with:
30+
dotnet-version: 9
2331

2432
- name: 📦 Install dependencies
25-
run: pip install .
33+
run: |
34+
pip install .
35+
dotnet tool restore
2636
2737
- name: 🛠️ Build
2838
run: python src/vbl_aquarium/build.py
2939

30-
- name: 📤 PR changes
40+
- name: 🧹 Format
41+
run: dotnet csharpier models/csharp
42+
43+
- name: ✅ Commit code format changes (on PR)
44+
if: github.ref != 'refs/heads/main'
45+
uses: stefanzweifel/git-auto-commit-action@v5
46+
with:
47+
commit_message: "chore: Build Models"
48+
49+
- name: 📤 PR changes (on main)
3150
if: github.ref == 'refs/heads/main'
3251
uses: peter-evans/create-pull-request@v7
3352
with:
Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Autoformat and Lint
1+
name: Static Analysis
22

33
on:
44
pull_request:
@@ -7,8 +7,8 @@ on:
77
- main
88

99
jobs:
10-
autoformat-and-lint:
11-
name: Autoformat and Lint
10+
analyze:
11+
name: Analyze
1212
if: github.actor != 'dependabot[bot]'
1313
runs-on: ubuntu-latest
1414
permissions:
@@ -21,11 +21,17 @@ jobs:
2121
ref: ${{ github.head_ref }}
2222
token: ${{ secrets.WORKFLOW_COMMIT_TOKEN }}
2323

24+
- name: 🐍 Setup Python
25+
uses: actions/setup-python@v5
26+
with:
27+
python-version: '3.13'
28+
cache: 'pip'
29+
2430
- name: 🥚 Install Hatch
2531
uses: pypa/hatch@install
2632

27-
- name: 📝 Static Analysis
28-
run: hatch fmt
33+
- name: 📝 Format Code
34+
run: hatch fmt -f
2935

3036
- name: ✅ Commit code format changes
3137
if: github.ref != 'refs/heads/main'
@@ -43,4 +49,10 @@ jobs:
4349
commit-message: "chore: Autoformat code"
4450
title: "chore: Autoformat code"
4551
branch: "autoformat-code"
46-
delete-branch: true
52+
delete-branch: true
53+
54+
- name: 🧶 Lint
55+
run: hatch fmt --check
56+
57+
- name: 🔍 Type Check
58+
run: hatch run check

.idea/misc.xml

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/vbl-json-schema.iml

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

models/csharp/DockModels.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using System;
2+
23
[Serializable]
34
public struct BucketRequest
45
{
@@ -104,4 +105,3 @@ public UploadRequest(int type, string data, string password)
104105
Password = password;
105106
}
106107
}
107-

models/csharp/EphysLinkModels.cs

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
using UnityEngine;
21
using System;
2+
using UnityEngine;
33

44
[Serializable]
55
public struct AngularResponse
@@ -39,7 +39,16 @@ public struct EphysLinkOptions
3939
public int MpmPort;
4040
public string Serial;
4141

42-
public EphysLinkOptions(bool background, bool ignoreUpdates, string type, bool debug, bool useProxy, string proxyAddress, int mpmPort, string serial)
42+
public EphysLinkOptions(
43+
bool background,
44+
bool ignoreUpdates,
45+
string type,
46+
bool debug,
47+
bool useProxy,
48+
string proxyAddress,
49+
int mpmPort,
50+
string serial
51+
)
4352
{
4453
Background = background;
4554
IgnoreUpdates = ignoreUpdates;
@@ -52,7 +61,6 @@ public EphysLinkOptions(bool background, bool ignoreUpdates, string type, bool d
5261
}
5362
}
5463

55-
5664
[Serializable]
5765
public struct GetManipulatorsResponse
5866
{
@@ -61,7 +69,12 @@ public struct GetManipulatorsResponse
6169
public Vector4 Dimensions;
6270
public string Error;
6371

64-
public GetManipulatorsResponse(string[] manipulators, int numAxes, Vector4 dimensions, string error)
72+
public GetManipulatorsResponse(
73+
string[] manipulators,
74+
int numAxes,
75+
Vector4 dimensions,
76+
string error
77+
)
6578
{
6679
Manipulators = manipulators;
6780
NumAxes = numAxes;
@@ -70,7 +83,6 @@ public GetManipulatorsResponse(string[] manipulators, int numAxes, Vector4 dimen
7083
}
7184
}
7285

73-
7486
[Serializable]
7587
public struct PositionalResponse
7688
{
@@ -125,7 +137,6 @@ public SetInsideBrainRequest(string manipulatorId, bool inside)
125137
}
126138
}
127139

128-
129140
[Serializable]
130141
public struct SetPositionRequest
131142
{
@@ -153,4 +164,3 @@ public ShankCountResponse(int shankCount, string error)
153164
Error = error;
154165
}
155166
}
156-

models/csharp/GenericModels.cs

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
using UnityEngine;
21
using System;
2+
using UnityEngine;
3+
34
[Serializable]
45
public struct BoolData
56
{
@@ -26,7 +27,6 @@ public BoolList(string id, bool[] values)
2627
}
2728
}
2829

29-
3030
[Serializable]
3131
public struct ColorData
3232
{
@@ -40,7 +40,6 @@ public ColorData(string id, Color value)
4040
}
4141
}
4242

43-
4443
[Serializable]
4544
public struct ColorList
4645
{
@@ -128,7 +127,6 @@ public IDListBoolList(string[] iDs, bool[] values)
128127
}
129128
}
130129

131-
132130
[Serializable]
133131
public struct IDListColorData
134132
{
@@ -142,7 +140,6 @@ public IDListColorData(string[] iDs, Color value)
142140
}
143141
}
144142

145-
146143
[Serializable]
147144
public struct IDListColorList
148145
{
@@ -234,7 +231,6 @@ public IDListStringList(string[] iDs, string[] values)
234231
}
235232
}
236233

237-
238234
[Serializable]
239235
public struct IDListVector2Data
240236
{
@@ -248,7 +244,6 @@ public IDListVector2Data(string[] iDs, Vector2 value)
248244
}
249245
}
250246

251-
252247
[Serializable]
253248
public struct IDListVector2List
254249
{
@@ -262,7 +257,6 @@ public IDListVector2List(string[] iDs, Vector2[] values)
262257
}
263258
}
264259

265-
266260
[Serializable]
267261
public struct IDListVector3Data
268262
{
@@ -276,7 +270,6 @@ public IDListVector3Data(string[] iDs, Vector3 value)
276270
}
277271
}
278272

279-
280273
[Serializable]
281274
public struct IDListVector3List
282275
{
@@ -342,7 +335,6 @@ public StringList(string id, string[] values)
342335
}
343336
}
344337

345-
346338
[Serializable]
347339
public struct Vector2Data
348340
{
@@ -356,7 +348,6 @@ public Vector2Data(string id, Vector2 value)
356348
}
357349
}
358350

359-
360351
[Serializable]
361352
public struct Vector3Data
362353
{
@@ -370,7 +361,6 @@ public Vector3Data(string id, Vector3 value)
370361
}
371362
}
372363

373-
374364
[Serializable]
375365
public struct Vector3List
376366
{
@@ -383,4 +373,3 @@ public Vector3List(string id, Vector3[] values)
383373
Values = values;
384374
}
385375
}
386-

models/csharp/LoggingModels.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using System;
2+
23
[Serializable]
34
public struct Log
45
{
@@ -31,4 +32,3 @@ public LogWarning(string msg)
3132
Msg = msg;
3233
}
3334
}
34-

0 commit comments

Comments
 (0)