Skip to content

ci: initial setup #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 23 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions .github/workflows/grammars.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ name: Building tree-sitter grammars
on:
pull_request:
branches:
- master
- main
push:
branches:
- master
- main

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
Expand Down Expand Up @@ -57,3 +57,6 @@ jobs:

- name: Build WASM
run: yarn grammar:wasm

- name: Test parsers
run: yarn test:grammars
4 changes: 2 additions & 2 deletions .github/workflows/linter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ name: Linter checks
on:
pull_request:
branches:
- master
- main
push:
branches:
- master
- main

env:
HUSKY: 0
Expand Down
21 changes: 19 additions & 2 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ name: E2E and Unit tests
on:
pull_request:
branches:
- master
- main
push:
branches:
- master
- main

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
Expand Down Expand Up @@ -44,11 +44,20 @@ jobs:
node-version: 22.x
cache: "yarn"

- name: Setup EMSDK
uses: mymindstorm/setup-emsdk@v14
with:
version: 3.1.54
actions-cache-folder: "emsdk-cache"

- name: Install dependencies
env:
YARN_ENABLE_HARDENED_MODE: false
run: yarn install --immutable

- name: Build WASM
run: yarn grammar:wasm

- name: Build Extension
run: yarn build

Expand All @@ -62,3 +71,11 @@ jobs:
- name: Run e2e tests
if: matrix.os != 'ubuntu-latest'
run: yarn run test:e2e

- name: Upload Language Server Logs
if: always()
uses: actions/upload-artifact@v4
with:
name: language-server-logs-${{ matrix.os }}
path: dist/ton-language-server.log
if-no-files-found: ignore
9 changes: 7 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@
"grammar:tlb:wasm": "cd server/src/languages/tlb/tree-sitter-tlb && tree-sitter generate && tree-sitter build --wasm",
"watch": "webpack --watch",
"precommit": "yarn build && yarn fmt && yarn lint",
"test:grammars": "yarn test:grammars:tolk && yarn test:grammars:fift && yarn test:grammars:tlb",
"test:grammars:tolk": "cd ./server/src/languages/tolk/tree-sitter-tolk/ && tree-sitter test",
"test:grammars:fift": "cd ./server/src/languages/fift/tree-sitter-fift/ && tree-sitter test",
"test:grammars:tlb": "cd ./server/src/languages/tlb/tree-sitter-tlb/ && tree-sitter test",
"test:e2e": "yarn test:e2e:tolk",
"test:e2e:compile": "tsc -p ./server/src/e2e/tsconfig.json",
"test:e2e:tolk": "yarn test:e2e:compile && ts-node server/src/e2e/runTolkTest.ts",
Expand Down Expand Up @@ -260,7 +264,8 @@
},
{
"command": "tolk.getUnresolvedIdentifiers",
"title": "Tolk: Get Unresolved Identifiers"
"title": "Tolk: Get Unresolved Identifiers",
"category": "Tolk"
}
],
"keybindings": [
Expand Down Expand Up @@ -499,7 +504,7 @@
"@types/vscode": "^1.63.0",
"@vscode/test-cli": "^0.0.10",
"@vscode/test-electron": "^2.4.1",
"@vscode/vsce": "^3.0.0",
"@vscode/vsce": "^3.6.0",
"c8": "^10.1.3",
"copy-webpack-plugin": "^12.0.2",
"eslint": "^9.19.0",
Expand Down
9 changes: 9 additions & 0 deletions server/src/e2e/runTolkTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// Copyright © 2025 TON Studio
import * as path from "node:path"
import {runTests} from "@vscode/test-electron"
import {mkdirSync} from "node:fs"

// eslint-disable-next-line functional/type-declaration-immutability
interface TestRunOptions {
Expand Down Expand Up @@ -112,6 +113,14 @@ async function main(): Promise<void> {
const extensionTestsPath = path.resolve(__dirname, "./out/tolk/index.js")
const testWorkspace = path.resolve(__dirname, "../../../test-workspace")

mkdirSync(testWorkspace, {recursive: true})

if (options.verbose) {
console.log(" extensionDevelopmentPath:", extensionDevelopmentPath)
console.log(" extensionTestsPath:", extensionTestsPath)
console.log(" testWorkspace:", testWorkspace)
}

await runTests({
extensionDevelopmentPath,
extensionTestsPath,
Expand Down
2 changes: 0 additions & 2 deletions server/src/e2e/tolk/compiler-tests.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,6 @@ suite("Compiler Tests Suite", () => {
)
const tolkFiles = glob.sync(testCasesPath, {windowsPathsNoEscape: true})

console.log("tolkFiles", tolkFiles.length)

for (const tolkFile of tolkFiles) {
const testName = path.basename(tolkFile, ".tolk")

Expand Down
95 changes: 0 additions & 95 deletions server/src/e2e/tolk/testcases/completion-select/snippets.test
Original file line number Diff line number Diff line change
Expand Up @@ -42,60 +42,6 @@ fun foo() {
var name<caret>: int = value;
}

========================================================================
If snippet
========================================================================
fun foo() {
if<caret>
}
------------------------------------------------------------------------
fun foo() {
if (condition<caret>) {

}
}

========================================================================
If-else snippet
========================================================================
fun foo() {
ife<caret>
}
------------------------------------------------------------------------
fun foo() {
if (condition<caret>) {

} else {

}
}

========================================================================
Do while snippet
========================================================================
fun foo() {
while<caret>
}
------------------------------------------------------------------------
fun foo() {
do {

} while (condition<caret>);
}

========================================================================
Repeat snippet
========================================================================
fun foo() {
repeat<caret>
}
------------------------------------------------------------------------
fun foo() {
repeat(count<caret>) {

}
}

========================================================================
Try snippet
========================================================================
Expand All @@ -108,44 +54,3 @@ fun foo() {
<caret>
}
}

========================================================================
Try catch snippet
========================================================================
fun foo() {
tryc<caret>
}
------------------------------------------------------------------------
fun foo() {
try {
<caret>
} catch (e) {

}
}

========================================================================
Match snippet
========================================================================
fun foo() {
match<caret>
}
------------------------------------------------------------------------
fun foo() {
match (condition<caret>) {

}
}

========================================================================
Match snippet as an expression
========================================================================
fun foo() {
val a = match<caret>
}
------------------------------------------------------------------------
fun foo() {
val a = match (condition<caret>) {

}
}
11 changes: 0 additions & 11 deletions server/src/e2e/tolk/testcases/documentation/auto-return-type.test
Original file line number Diff line number Diff line change
Expand Up @@ -77,14 +77,3 @@ fun int.<caret>foo(self) {}
```tolk
fun int.foo(self): void
```

========================================================================
Instance method with auto return type documentation: return self
========================================================================
fun int.<caret>foo(self) {
return self
}
------------------------------------------------------------------------
```tolk
fun int.foo(self): int
```
6 changes: 2 additions & 4 deletions server/src/e2e/tolk/testcases/types2/generic-structs.test
Original file line number Diff line number Diff line change
Expand Up @@ -114,10 +114,8 @@ fun main() {
//! ^ Ok<int>
if (r is Ok) { r; }
//! ^ Ok<int>
if (r is OkAlias<int>) { r; }
//! ^ OkAlias<int>
if (r !is OkAlias<int>) { r; }
//! ^ Err<slice>
if (r !is Ok<int>) { r; }
//! ^ Err<slice>
if (r is Ok<int> && r !is Err<slice> && r is Ok) { r; }
//! ^ Ok<int>
}
Expand Down
Binary file not shown.
Binary file not shown.
1 change: 0 additions & 1 deletion server/src/languages/tolk/tree-sitter-tolk/main.tolk
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
fun t<T>() {}

// fun Container<T>.getItem(self) { return self.item; }
// fun builder.add(mutate self) { }
Expand Down
2 changes: 1 addition & 1 deletion server/src/languages/tolk/tree-sitter-tolk/src/parser.c

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file not shown.
3 changes: 2 additions & 1 deletion server/src/languages/tolk/type-inference.ts
Original file line number Diff line number Diff line change
Expand Up @@ -486,6 +486,7 @@ class InferenceWalker {
public inferReturnType(): Ty {
const returnTypes = this.ctx.returnTypes
if (returnTypes.length === 0) return VoidTy.VOID
if (returnTypes.length === 1) return returnTypes[0]

let joined: Ty | null = null

Expand Down Expand Up @@ -664,7 +665,7 @@ class InferenceWalker {
}

private processReturnStatement(node: SyntaxNode, flow: FlowContext): FlowContext {
const expression = node.child(1)
const expression = node.childForFieldName("body")
if (expression) {
flow = this.inferExpression(
expression,
Expand Down
2 changes: 1 addition & 1 deletion server/src/languages/tolk/types/ty.ts
Original file line number Diff line number Diff line change
Expand Up @@ -840,7 +840,7 @@ export function subtractTypes(left: Ty | null, right: Ty): Ty {
}
} else if (left.contains(right)) {
for (const leftVariant of left.elements) {
if (!leftVariant.baseType().equals(right.baseType())) {
if (!leftVariant.unwrapAlias().equals(right.unwrapAlias())) {
restVariants.push(leftVariant)
}
}
Expand Down
16 changes: 15 additions & 1 deletion server/src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,7 @@ async function initializeFallback(uri: string): Promise<void> {
await initialize()
}

connection.onInitialize(async (initParams: lsp.InitializeParams): Promise<lsp.InitializeResult> => {
const onInitialize = async (initParams: lsp.InitializeParams): Promise<lsp.InitializeResult> => {
console.info("Started new session")
console.info("Running in", initParams.clientInfo?.name)
console.info("workspaceFolders:", initParams.workspaceFolders)
Expand All @@ -384,6 +384,8 @@ connection.onInitialize(async (initParams: lsp.InitializeParams): Promise<lsp.In

workspaceFolders = initParams.workspaceFolders ?? []
const opts = initParams.initializationOptions as ClientOptions | undefined
console.log("initializationOptions:", opts)

const treeSitterUri = opts?.treeSitterWasmUri ?? `${__dirname}/tree-sitter.wasm`
const tolkLangUri = opts?.tolkLangWasmUri ?? `${__dirname}/tree-sitter-tolk.wasm`
const fiftLangUri = opts?.fiftLangWasmUri ?? `${__dirname}/tree-sitter-fift.wasm`
Expand Down Expand Up @@ -940,6 +942,18 @@ connection.onInitialize(async (initParams: lsp.InitializeParams): Promise<lsp.In
},
},
}
}
connection.onInitialize(async (initParams: lsp.InitializeParams): Promise<lsp.InitializeResult> => {
try {
return await onInitialize(initParams)
} catch (error) {
if (error instanceof Error) {
console.error("error", error.message)
}
console.error("error", error)
}
// @ts-expect-error aaa
return {}
})

Logger.initialize(connection, `${__dirname}/ton-language-server.log`)
Expand Down
Loading
Loading