Skip to content

Commit

Permalink
fix line ending & add typechecking action
Browse files Browse the repository at this point in the history
  • Loading branch information
SpikeVN committed Sep 1, 2024
1 parent d56c49c commit d795c64
Show file tree
Hide file tree
Showing 38 changed files with 219 additions and 111 deletions.
19 changes: 19 additions & 0 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: "type checking"
on:
push:
pull_request:

jobs:
check:
name: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.12"
cache: "pip"
- name: "Installing dependencies"
run: "pip install -r requirements.txt"
- name: "Inspecting"
run: "basedpyright"
4 changes: 2 additions & 2 deletions .github/workflows/michaelsoft.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
- uses: actions/checkout@v4
- uses: actions-rust-lang/setup-rust-toolchain@v1
- uses: actions/setup-python@v5
with:
with:
python-version: "3.12"
cache: "pip"
- name: "Installing dependencies"
Expand All @@ -26,4 +26,4 @@ jobs:
uses: actions/upload-artifact@v4
with:
name: engine
path: dist/*
path: dist/*
20 changes: 20 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.6.0
hooks:
- id: end-of-file-fixer
- id: trailing-whitespace
- repo: https://github.com/psf/black-pre-commit-mirror
rev: 24.8.0
hooks:
- id: black
language_version: python3.12
- repo: https://github.com/DetachHead/basedpyright-pre-commit-mirror
rev: 1.17.1
hooks:
- id: basedpyright
- repo: https://github.com/doublify/pre-commit-rust
rev: v1.0
hooks:
- id: fmt
- id: cargo-check
4 changes: 4 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@

{
"recommendations": ["detachhead.basedpyright"]
}
2 changes: 1 addition & 1 deletion .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@
"cwd": "${workspaceFolder}/server"
}
]
}
}
2 changes: 1 addition & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
"rust-analyzer.files.excludeDirs": [
"engine/src/logic"
]
}
}
2 changes: 1 addition & 1 deletion .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -103,4 +103,4 @@
}
}
]
}
}
8 changes: 4 additions & 4 deletions README.txt
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
OWL
- a high priority Team Falco project
- a high priority Team Falco project
======================
Open source development of the new Rust engine

Technical specifications
------------------------
The server software will host a web service and a WebSockets server on a
The server software will host a web service and a WebSockets server on a
hard-coded IP adress and port at `localhost:6942/`.

The Python bindings is manually typed and wheel built using PyO3.
The JavaScript bindings is automatically generated using wasm-

The protocol in which the client and server communicates in is based
on `serde` serialization of Rust structs. Bindings for Python and
on `serde` serialization of Rust structs. Bindings for Python and
JavaScript is available (see `engine/engine.pyi` and the generated
`node_modules/client/client.d.ts`)

Expand Down Expand Up @@ -40,7 +40,7 @@ Building
--------
* For client, use `bun run dev`. The Rust module will be automatically
compiled and bundled, and hot-reload enabled Vite starts serving on
localhost:5173/.
localhost:5173/.
* For server, use `./gang run`. The Rust module will be compiled,
the Python binding generated, the wheel built and installed automatically.
`server/main.py` is subsequenly called, with CWD=/server/.
Expand Down
2 changes: 1 addition & 1 deletion assets/.gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
question_test.json
question_khoidong.json
question_khoidong.json
1 change: 0 additions & 1 deletion chick.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,3 @@ run:
- bun run dev &
- cd ../server
- python3 main.py

2 changes: 1 addition & 1 deletion config.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,4 @@
"accessKey": "chatgpt"
}
]
}
}
40 changes: 20 additions & 20 deletions engine/engine.pyi
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
from typing import Any, Optional, Callable, Literal, Union, Iterable, Mapping
from abc import abstractmethod, ABC

PacketData = Union[
AuthenticationStatus,
PartProperties,
Player,
Credentials,
Question,
QuestionBank,
Query,
Show,
Ticker,
Timer,
str,
list[ProcedureSignature],
ProcedureCall,
GameState,
list[GameState],
]
PacketData = (
AuthenticationStatus
| PartProperties
| Player
| Credentials
| Question
| QuestionBank
| Query
| Show
| Ticker
| Timer
| str
| list[ProcedureSignature]
| ProcedureCall
| GameState
| list[GameState]
)
"""All the possible values in a packet's data."""

class Packet(ABC):
Expand Down Expand Up @@ -338,9 +338,9 @@ class Question:
prompt: str
key: str
score: int
choices: Optional[list[str]]
score_false: Optional[int]
explaination: Optional[str]
choices: list[str] | None
score_false: int | None
explaination: str | None

def __init__(
self,
Expand Down
2 changes: 1 addition & 1 deletion frontend/client/types/client.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -275,4 +275,4 @@ export class ClientHandle {
* Fishes out pesky panics and returns nice errors.
*/
static set_panic_hook(): void;
}
}
2 changes: 1 addition & 1 deletion frontend/client/types/logic/panel.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ export class Panel {

static inspect(t: any): void;
static cpacket_test<T extends PacketType>(cp: Packet<T>): void;
}
}
7 changes: 7 additions & 0 deletions frontend/eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,12 @@ export default [
},
{
ignores: ["build/", ".svelte-kit/", "dist/"]
},
{
rules: {
semi: "error",
"@typescript-eslint/no-unused-vars": "off",
"@typescript-eslint/no-explicit-any": "off"
}
}
];
4 changes: 2 additions & 2 deletions frontend/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<title>Đường đua xanh 2024</title>
<base href="/" />
<script>

</script>
</head>

Expand All @@ -35,4 +35,4 @@ <h6>
</h6>
</body>

</html>
</html>
2 changes: 1 addition & 1 deletion frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,4 @@
"vite-plugin-top-level-await": "^1.4.1",
"vite-plugin-wasm": "^3.3.0"
}
}
}
20 changes: 10 additions & 10 deletions frontend/src/app.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,27 +10,27 @@
%sveltekit.head%
<script>
/*
@licstart The following is the entire license notice for the
@licstart The following is the entire license notice for the
JavaScript and WebAssembly code in this page.
Copyright (C) 2024 Nguyễn Tri Phương
The JavaScript and WebAssembly code in this page
The JavaScript and WebAssembly code in this page
is free software: you can redistribute it and/or modify it under
the terms of the GNU General Public License (GNU GPL) as published
by the Free Software Foundation, either version 3 of the License,
or (at your option) any later version. The code is distributed
WITHOUT ANY WARRANTY; without even the implied warranty of
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
GPL for more details.
As additional permission under GNU GPL version 3 section 7, you
may distribute non-source (e.g., minimized or compacted) forms of
that code without the copy of the GNU GPL normally required by
section 4, provided you include this license notice and a URL
through which recipients can access the Corresponding Source.
through which recipients can access the Corresponding Source.
@licend The above is the entire license notice
for the JavaScript and WebAssembly code in this page.
*/
Expand All @@ -41,4 +41,4 @@
<div style="display: contents">%sveltekit.body%</div>
</body>

</html>
</html>
7 changes: 4 additions & 3 deletions frontend/src/components/AntiCheat.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@
/**
* World-class super secure "the ultimate hammer" ACC NCP Vulkan NoFly
* "popbob killer" "5x hausemaster" "100x2b anticheat no cap fr fr"
* "TheChosenOne Annihilator" "the superior watchdawg"
*
* Detects debugger using an old feature named SourceMappingURL.
* When the browser devtools is open, it automatically sends a get request
* to the specified URL. This does not affect non-devtools usage.
* Identify debugger-like behaviour ultilizing an obscure browser feature.
* When activated, a get request is automatically initiated in the instant
* DevTools is opened. Non-DevTools usage is not affected by this countermeasure.
* TODO - test this.
*/
export let url: string;
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/lib/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,4 +83,4 @@ export class Connection {
async send<T extends PacketType>(packet: Packet<T>) {
this.ws.send(packet.pack());
}
}
}
2 changes: 1 addition & 1 deletion frontend/src/lib/player.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,4 @@ export class PlayerManager implements Readable<Map<string, Player>> {
async updateAll() {
await this.connection.send(Peeker.Query.playerList());
}
}
}
2 changes: 1 addition & 1 deletion frontend/src/lib/push.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,4 @@ export class Push {
static object(name: string, t: object): Packet<PacketType.UpdateState> {
return Push.create(name, t, Peeker.PortableType.OBJECT)
}
}
}
2 changes: 1 addition & 1 deletion frontend/src/lib/rpcbuilder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,4 @@ export class CallProcedure {
this.call.value
)
}
}
}
1 change: 0 additions & 1 deletion frontend/src/lib/state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,4 +122,3 @@ export class StateManager implements Readable<any> {
await this.connection.send(Push.create("timer_json", t.pack(), Peeker.PortableType.OBJECT));
}
}

2 changes: 1 addition & 1 deletion frontend/src/lib/value.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,4 @@ export class Value {
static object(t: object): PortableValue {
return Value.create(t, Peeker.PortableType.OBJECT)
}
}
}
2 changes: 1 addition & 1 deletion frontend/src/routes/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import { onMount } from "svelte";
import TitleBar from "../components/TitleBar.svelte";
import { goto } from "$app/navigation";
let username: HTMLInputElement;
let accessKey: HTMLInputElement;
let conn: Connection;
Expand Down
12 changes: 12 additions & 0 deletions frontend/src/routes/game/vcnv/+page.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<script lang="ts">
import { Peeker, Connection, GameMaster } from "$lib";
import { onMount } from "svelte";
import Load from "../../components/Load";
let conn: Connection;
let gm: GameMaster;
onMount(async () => {
conn = await Connection.create();
});
</script>
2 changes: 1 addition & 1 deletion frontend/static/global.css
Original file line number Diff line number Diff line change
Expand Up @@ -231,4 +231,4 @@ button {

button:focus {
outline: 0;
}
}
26 changes: 26 additions & 0 deletions pyrightconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"stubPath": "engine",
"exclude": [
"engine"
],
"reportUnusedCallResult": "none",
"reportImplicitRelativeImport": "none",
"reportImplicitOverride": "information",
"reportUnusedParameter": "none",
"reportUnknownLambdaType": "none",
"reportUnusedImport": "none",
"reportUnknownMemberType": "none",
"reportUnknownVariableType": "none",
"reportUnknownArgumentType": "none",
"reportMissingTypeArgument": "none",
"reportAny": "none",
"reportUnknownParameterType": "none",
"reportMissingParameterType": "none",
"reportIgnoreCommentWithoutRule": "none",
"reportPrivateLocalImportUsage": "none",
"reportUninitializedInstanceVariable": "none",
"reportMissingSuperCall": "none",
"reportConstantRedefinition": "none",
"reportIncompatibleVariableOverride": "none",
"enableTypeIgnoreComments": true
}
3 changes: 2 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
maturin
maturin
basedpyright
Loading

0 comments on commit d795c64

Please sign in to comment.