Skip to content

Commit ad55c0c

Browse files
authored
chore: check formatting using mops format --check in a workflow. (#129)
Similar to `cargo fmt --check`.
1 parent bf5e8a8 commit ad55c0c

11 files changed

Lines changed: 149 additions & 60 deletions

File tree

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: Backend Motoko Format Check
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
- master
8+
pull_request:
9+
paths:
10+
- backend/mo/**
11+
- .github/workflows/provision-linux.sh
12+
- .github/workflows/backend-motoko-format-check.yml
13+
14+
jobs:
15+
backend-motoko-format-check-linux:
16+
runs-on: ubuntu-24.04
17+
steps:
18+
- uses: actions/checkout@v4
19+
- uses: ZenVoich/setup-mops@v1
20+
with:
21+
mops-version: 1
22+
- name: Provision Linux
23+
run: bash .github/workflows/provision-linux.sh
24+
- name: Run MOPS Format Check Linux
25+
run: |
26+
for d in $(find . -type d -name '.mops' -prune -o -type f -name 'mops.toml' -printf '%h\n'); do
27+
cd $d
28+
echo "Checking directory: $(pwd)" && mops format --check
29+
cd -
30+
done
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"overrides": [{
3+
"files": "*.mo",
4+
"options": {
5+
"tabWidth": 4
6+
}
7+
}]
8+
}

backend/mo/canisters/ic_vetkeys_encrypted_maps_canister/dfx.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,10 @@
55
"type": "motoko",
66
"args": "--enhanced-orthogonal-persistence"
77
}
8+
},
9+
"defaults": {
10+
"build": {
11+
"packtool": "npx ic-mops sources"
12+
}
813
}
914
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
[package]
2+
name = "ic-vetkeys-encrypted-maps-canister"
3+
version = "0.1.0"
4+
repository = "https://github.com/dfinity/vetkd-devkit"
5+
keywords = [
6+
"vetkeys,vetkd,encryption,privacy,signature,BLS,key ",
7+
"derivation,IBE"
8+
]
9+
license = "Apache-2.0"
10+
11+
[dependencies]
12+
base = "0.14.6"

backend/mo/canisters/ic_vetkeys_encrypted_maps_canister/src/Main.mo

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ actor class (keyName : Text) {
2121
public query (msg) func get_accessible_shared_map_names() : async [(Principal, ByteBuf)] {
2222
Array.map<(Principal, Blob), (Principal, ByteBuf)>(
2323
encryptedMaps.getAccessibleSharedMapNames(msg.caller),
24+
2425
func((principal, blob) : (Principal, Blob)) {
2526
(principal, { inner = blob });
2627
},
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"overrides": [{
3+
"files": "*.mo",
4+
"options": {
5+
"tabWidth": 4
6+
}
7+
}]
8+
}

backend/mo/canisters/ic_vetkeys_manager_canister/dfx.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,10 @@
55
"type": "motoko",
66
"args": "--enhanced-orthogonal-persistence"
77
}
8+
},
9+
"defaults": {
10+
"build": {
11+
"packtool": "npx ic-mops sources"
12+
}
813
}
914
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
[package]
2+
name = "ic-vetkeys-manager-canister"
3+
version = "0.1.0"
4+
repository = "https://github.com/dfinity/vetkd-devkit"
5+
keywords = [
6+
"vetkeys,vetkd,encryption,privacy,signature,BLS,key ",
7+
"derivation,IBE"
8+
]
9+
license = "Apache-2.0"
10+
11+
[dependencies]
12+
base = "0.14.6"

backend/mo/ic_vetkeys/.prettierrc

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"overrides": [{
3+
"files": "*.mo",
4+
"options": {
5+
"tabWidth": 4
6+
}
7+
}]
8+
}

backend/mo/ic_vetkeys/src/Types.mo

Lines changed: 55 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -1,64 +1,64 @@
11
module {
2-
public type AccessControlOperations<T> = {
3-
canRead : (t : T) -> Bool;
4-
canWrite : (t : T) -> Bool;
5-
canGetUserRights : (t : T) -> Bool;
6-
canSetUserRights : (t : T) -> Bool;
7-
ownerRights : () -> T;
8-
toText : (t : T) -> Text;
9-
};
2+
public type AccessControlOperations<T> = {
3+
canRead : (t : T) -> Bool;
4+
canWrite : (t : T) -> Bool;
5+
canGetUserRights : (t : T) -> Bool;
6+
canSetUserRights : (t : T) -> Bool;
7+
ownerRights : () -> T;
8+
toText : (t : T) -> Text;
9+
};
1010

11-
public type AccessRights = {
12-
#Read;
13-
#ReadWrite;
14-
#ReadWriteManage;
15-
};
11+
public type AccessRights = {
12+
#Read;
13+
#ReadWrite;
14+
#ReadWriteManage;
15+
};
1616

17-
public func accessRightsOperations() : AccessControlOperations<AccessRights> {
18-
{
19-
canRead = func(accessRights : AccessRights) : Bool {
20-
switch (accessRights) {
21-
case (#Read) { true };
22-
case (#ReadWrite) { true };
23-
case (#ReadWriteManage) { true };
24-
};
25-
};
17+
public func accessRightsOperations() : AccessControlOperations<AccessRights> {
18+
{
19+
canRead = func(accessRights : AccessRights) : Bool {
20+
switch (accessRights) {
21+
case (#Read) { true };
22+
case (#ReadWrite) { true };
23+
case (#ReadWriteManage) { true };
24+
};
25+
};
2626

27-
canWrite = func(accessRights : AccessRights) : Bool {
28-
switch (accessRights) {
29-
case (#Read) { false };
30-
case (#ReadWrite) { true };
31-
case (#ReadWriteManage) { true };
32-
};
33-
};
27+
canWrite = func(accessRights : AccessRights) : Bool {
28+
switch (accessRights) {
29+
case (#Read) { false };
30+
case (#ReadWrite) { true };
31+
case (#ReadWriteManage) { true };
32+
};
33+
};
3434

35-
canGetUserRights = func(accessRights : AccessRights) : Bool {
36-
switch (accessRights) {
37-
case (#Read) { false };
38-
case (#ReadWrite) { false };
39-
case (#ReadWriteManage) { true };
40-
};
41-
};
35+
canGetUserRights = func(accessRights : AccessRights) : Bool {
36+
switch (accessRights) {
37+
case (#Read) { false };
38+
case (#ReadWrite) { false };
39+
case (#ReadWriteManage) { true };
40+
};
41+
};
4242

43-
canSetUserRights = func(accessRights : AccessRights) : Bool {
44-
switch (accessRights) {
45-
case (#Read) { false };
46-
case (#ReadWrite) { false };
47-
case (#ReadWriteManage) { true };
48-
};
49-
};
43+
canSetUserRights = func(accessRights : AccessRights) : Bool {
44+
switch (accessRights) {
45+
case (#Read) { false };
46+
case (#ReadWrite) { false };
47+
case (#ReadWriteManage) { true };
48+
};
49+
};
5050

51-
ownerRights = func() : AccessRights {
52-
#ReadWriteManage;
53-
};
51+
ownerRights = func() : AccessRights {
52+
#ReadWriteManage;
53+
};
5454

55-
toText = func(accessRights : AccessRights) : Text {
56-
switch (accessRights) {
57-
case (#Read) { "Read" };
58-
case (#ReadWrite) { "ReadWrite" };
59-
case (#ReadWriteManage) { "ReadWriteManage" };
60-
};
61-
};
62-
};
63-
};
55+
toText = func(accessRights : AccessRights) : Text {
56+
switch (accessRights) {
57+
case (#Read) { "Read" };
58+
case (#ReadWrite) { "ReadWrite" };
59+
case (#ReadWriteManage) { "ReadWriteManage" };
60+
};
61+
};
62+
};
63+
};
6464
};

0 commit comments

Comments
 (0)