Skip to content
Closed
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
5 changes: 3 additions & 2 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
Please check directly on the box once each of these are done

- [ ] Documentation (if necessary)
- [ ] Tests (integration test/unit test)
- [ ] Unit Tests Passed
- [ ] Coverage Tests
- [ ] Integration Tests Passed
- [ ] Code Review
- [ ] Code Review
73 changes: 73 additions & 0 deletions .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
name: Run coverage test
on:
push:
branches: [ master ]
paths-ignore:
- 'dbml-homepage/**'
pull_request:
types: [opened, synchronize]
paths-ignore:
- 'dbml-homepage/**'
jobs:
test:
runs-on: ubuntu-22.04
strategy:
matrix:
node-version: [22.x]
services:
postgres:
image: postgres:15-bullseye
env:
POSTGRES_USER: dbml
POSTGRES_PASSWORD: testtest
POSTGRES_DB: dbml_test
ports:
- 5432:5432
# Set health checks to wait until postgres has started
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
mssql:
image: mcr.microsoft.com/mssql/server:2019-latest
env:
ACCEPT_EULA: Y
SA_PASSWORD: dbml.123.123
ports:
- 1433:1433
options: >-
--health-cmd "exit 0"
--health-interval 10s
--health-timeout 5s
--health-retries 5
mysql-8.0:
image: mysql:8.0
env:
MYSQL_DATABASE: dbml_test
MYSQL_ROOT_PASSWORD: root
ports:
- 3306:3306
options: >-
--health-cmd "mysqladmin ping"
--health-interval 10s
--health-timeout 5s
--health-retries 10
steps:
- uses: actions/checkout@v3
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: 'yarn'
- name: Install dependencies
run: yarn install --frozen-lockfile
- name: Run build
run: yarn build
- name: Run coverage
run: yarn coverage
- name: Upload coverage artifact
uses: actions/upload-artifact@v4
with:
name: dbml-parse-coverage-report
path: packages/dbml-parse/coverage/
3 changes: 1 addition & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
name: Run unit test
on:
push:
branches: [ master]
branches: [ master ]
paths-ignore:
- 'dbml-homepage/**'
pull_request:
branches: [ master ]
types: [opened, synchronize]
paths-ignore:
- 'dbml-homepage/**'
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,6 @@ packages/dbml-core/benchmarks/*
tsconfig.tsbuildinfo

packages/dbml-connector/keys

# coverage
coverage/
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
],
"scripts": {
"test": "npx lerna run test",
"coverage": "npx lerna run coverage",
"build": "yarn clean-build && npx lerna run build",
"clean-build": "rm -rf ./packages/dbml-cli/lib ./packages/dbml-core/lib ./packages/dbml-parse/dist ./packages/dbml-connector/dist"
},
Expand Down
6 changes: 4 additions & 2 deletions packages/dbml-parse/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,13 @@
"@types/node": "^20.8.8",
"@typescript-eslint/eslint-plugin": "^8.30.1",
"@typescript-eslint/parser": "^8.30.1",
"@vitest/coverage-v8": "4.0.8",
"fast-check": "^4.3.0",
"monaco-editor-core": "^0.44.0",
"typescript": "^5.2.2",
"vite": "^6.3.5",
"vite": "^7.2.2",
"vite-plugin-dts": "^4.5.4",
"vitest": "^3.1.4"
"vitest": "^4.0.8"
},
"dependencies": {
"lodash-es": "^4.17.21"
Expand Down
3 changes: 1 addition & 2 deletions packages/dbml-parse/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { serialize } from './lib/serialization/serialize';
import Compiler from './compiler';
import * as services from './services/index';

Expand Down Expand Up @@ -51,4 +50,4 @@ export {
type TablePartial,
} from './lib/interpreter/types';

export { serialize, Compiler, services };
export { Compiler, services };
4 changes: 4 additions & 0 deletions packages/dbml-parse/src/lib/lexer/lexer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,10 @@ export default class Lexer {
this.addToken(SyntaxTokenKind.SPACE);
break;
case '\r':
if (this.check('\n')) {
this.advance();
this.addToken(SyntaxTokenKind.NEWLINE);
} else this.addToken(SyntaxTokenKind.SPACE);
break;
case '\n':
this.addToken(SyntaxTokenKind.NEWLINE);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import fs, { readFileSync } from 'fs';
import { readFileSync } from 'fs';
import path from 'path';
import { describe, expect, it } from 'vitest';
import { scanTestNames } from '../jestHelpers';
import { serialize } from '../../src/lib/serialization/serialize';
import Lexer from '../../src/lib/lexer/lexer';
import Parser from '../../src/lib/parser/parser';
import { NodeSymbolIdGenerator } from '../../src/lib/analyzer/symbol/symbols';
import { SyntaxNodeIdGenerator } from '../../src/lib/parser/nodes';
import Analyzer from '../../src/lib/analyzer/analyzer';
import { serialize } from '../serialize';
import Lexer from '../../../src/lib/lexer/lexer';
import Parser from '../../../src/lib/parser/parser';
import { NodeSymbolIdGenerator } from '../../../src/lib/analyzer/symbol/symbols';
import { SyntaxNodeIdGenerator } from '../../../src/lib/parser/nodes';
import Analyzer from '../../../src/lib/analyzer/analyzer';

describe('#binder', () => {
const testNames = scanTestNames(path.resolve(__dirname, './input/'));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -191,22 +191,22 @@
{
"kind": "<newline>",
"startPos": {
"offset": 11,
"offset": 10,
"line": 0,
"column": 11
"column": 10
},
"endPos": {
"offset": 12,
"line": 1,
"column": 0
},
"value": "\n",
"value": "\r\n",
"leadingTrivia": [],
"trailingTrivia": [],
"leadingInvalid": [],
"trailingInvalid": [],
"isInvalid": false,
"start": 11,
"start": 10,
"end": 12
}
],
Expand Down Expand Up @@ -234,45 +234,45 @@
{
"kind": "<newline>",
"startPos": {
"offset": 13,
"offset": 12,
"line": 1,
"column": 1
"column": 0
},
"endPos": {
"offset": 14,
"line": 2,
"column": 0
},
"value": "\n",
"value": "\r\n",
"leadingTrivia": [],
"trailingTrivia": [],
"leadingInvalid": [],
"trailingInvalid": [],
"isInvalid": false,
"start": 13,
"start": 12,
"end": 14
}
],
"trailingTrivia": [
{
"kind": "<newline>",
"startPos": {
"offset": 16,
"offset": 15,
"line": 2,
"column": 2
"column": 1
},
"endPos": {
"offset": 17,
"line": 3,
"column": 0
},
"value": "\n",
"value": "\r\n",
"leadingTrivia": [],
"trailingTrivia": [],
"leadingInvalid": [],
"trailingInvalid": [],
"isInvalid": false,
"start": 16,
"start": 15,
"end": 17
}
],
Expand All @@ -294,7 +294,7 @@
"line": 4,
"column": 0
},
"fullStart": 18,
"fullStart": 17,
"endPos": {
"offset": 38,
"line": 6,
Expand All @@ -320,22 +320,22 @@
{
"kind": "<newline>",
"startPos": {
"offset": 18,
"offset": 17,
"line": 3,
"column": 1
"column": 0
},
"endPos": {
"offset": 19,
"line": 4,
"column": 0
},
"value": "\n",
"value": "\r\n",
"leadingTrivia": [],
"trailingTrivia": [],
"leadingInvalid": [],
"trailingInvalid": [],
"isInvalid": false,
"start": 18,
"start": 17,
"end": 19
}
],
Expand Down Expand Up @@ -482,22 +482,22 @@
{
"kind": "<newline>",
"startPos": {
"offset": 30,
"offset": 29,
"line": 4,
"column": 11
"column": 10
},
"endPos": {
"offset": 31,
"line": 5,
"column": 0
},
"value": "\n",
"value": "\r\n",
"leadingTrivia": [],
"trailingTrivia": [],
"leadingInvalid": [],
"trailingInvalid": [],
"isInvalid": false,
"start": 30,
"start": 29,
"end": 31
}
],
Expand Down Expand Up @@ -609,22 +609,22 @@
{
"kind": "<newline>",
"startPos": {
"offset": 36,
"offset": 35,
"line": 5,
"column": 5
"column": 4
},
"endPos": {
"offset": 37,
"line": 6,
"column": 0
},
"value": "\n",
"value": "\r\n",
"leadingTrivia": [],
"trailingTrivia": [],
"leadingInvalid": [],
"trailingInvalid": [],
"isInvalid": false,
"start": 36,
"start": 35,
"end": 37
}
],
Expand Down
Loading
Loading