Skip to content
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
157 changes: 157 additions & 0 deletions .github/workflows/typescript-package.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,157 @@
#<!--
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
#-->
# TypeScript CI for @apache-burr/core
# Mirrors the structure of python-package.yml:
# lint → typecheck → unit tests → integration tests → type tests

name: Build Burr TypeScript

on:
push:
branches:
- main
paths:
- 'typescript/**'
- '.github/workflows/typescript-package.yml'
pull_request:
types: [opened, synchronize, reopened]
paths:
- 'typescript/**'
- '.github/workflows/typescript-package.yml'

# Cancel in-progress runs for the same PR/branch
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

jobs:
lint:
runs-on: ubuntu-latest
defaults:
run:
working-directory: typescript
steps:
- uses: actions/checkout@v4

- name: Use Node.js 20.x
uses: actions/setup-node@v4
with:
node-version: '20'
- name: Install dependencies
run: npm install

- name: Install workspace dependencies
run: npm install --workspace=packages/burr-core

- name: Lint
run: npm run lint

typecheck:
runs-on: ubuntu-latest
defaults:
run:
working-directory: typescript
steps:
- uses: actions/checkout@v4

- name: Use Node.js 20.x
uses: actions/setup-node@v4
with:
node-version: '20'

- name: Install dependencies
run: npm install && npm install --workspace=packages/burr-core

- name: Typecheck
run: cd packages/burr-core && npx tsc --noEmit

test:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
node-version: ['18', '20', '22']
defaults:
run:
working-directory: typescript
steps:
- uses: actions/checkout@v4

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}

- name: Install dependencies
run: npm install && npm install --workspace=packages/burr-core

- name: Run unit tests
working-directory: typescript/packages/burr-core
run: npx jest --no-coverage --testPathIgnorePatterns='type-tests|integration'

- name: Run integration tests
working-directory: typescript/packages/burr-core
run: npx jest src/__tests__/integration.test.ts --no-coverage

test-types:
runs-on: ubuntu-latest
defaults:
run:
working-directory: typescript
steps:
- uses: actions/checkout@v4

- name: Use Node.js 20.x
uses: actions/setup-node@v4
with:
node-version: '20'

- name: Install dependencies
run: npm install && npm install --workspace=packages/burr-core

- name: Run compile-time type tests
working-directory: typescript/packages/burr-core
run: npx jest src/__tests__/type-tests/runner.test.ts --no-coverage

build:
runs-on: ubuntu-latest
needs: [lint, typecheck, test, test-types]
defaults:
run:
working-directory: typescript
steps:
- uses: actions/checkout@v4

- name: Use Node.js 20.x
uses: actions/setup-node@v4
with:
node-version: '20'

- name: Install dependencies
run: npm install && npm install --workspace=packages/burr-core

- name: Build
working-directory: typescript/packages/burr-core
run: npx tsc --build

- name: Verify dist output exists
working-directory: typescript/packages/burr-core
run: |
test -f dist/index.js || (echo "Build failed: dist/index.js not found" && exit 1)
test -f dist/index.d.ts || (echo "Build failed: dist/index.d.ts not found" && exit 1)
22 changes: 21 additions & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
# $ cd /PATH/TO/REPO
# $ pre-commit install

exclude: '^telemetry/ui|^burr/tracking/server/demo_data(/|$)'
exclude: '^telemetry/ui|^typescript/|^burr/tracking/server/demo_data(/|$)'
repos:
- repo: https://github.com/ambv/black
rev: 23.11.0
Expand Down Expand Up @@ -68,6 +68,26 @@ repos:
rev: 6.1.0
hooks:
- id: flake8
# ESLint for TypeScript
- repo: https://github.com/pre-commit/mirrors-eslint
rev: v8.56.0
hooks:
- id: eslint
files: ^typescript/.*\.[jt]sx?$
types: [file]
args: ['--fix']
additional_dependencies:
- eslint@8.56.0
- '@typescript-eslint/parser@6.21.0'
- '@typescript-eslint/eslint-plugin@6.21.0'
- typescript@5.3.3
# Prettier for TypeScript
- repo: https://github.com/pre-commit/mirrors-prettier
rev: v3.1.0
hooks:
- id: prettier
files: ^typescript/.*\.(ts|tsx|js|jsx|json|md)$
args: ['--write']
- repo: local
# This is a bit of a hack, but its the easiest way to get it to all run together
# https://stackoverflow.com/questions/64001471/pylint-with-pre-commit-and-esllint-with-husky
Expand Down
22 changes: 22 additions & 0 deletions typescript/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"parser": "@typescript-eslint/parser",
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/recommended"
],
"plugins": ["@typescript-eslint"],
"env": {
"node": true,
"es6": true
},
"parserOptions": {
"ecmaVersion": 2020,
"sourceType": "module"
},
"rules": {
"@typescript-eslint/explicit-function-return-type": "warn",
"@typescript-eslint/no-explicit-any": "warn",
"@typescript-eslint/no-unused-vars": ["error", { "argsIgnorePattern": "^_" }]
}
}

37 changes: 37 additions & 0 deletions typescript/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Dependencies
node_modules/
package-lock.json
yarn.lock
pnpm-lock.yaml

# Build outputs
dist/
build/
*.tsbuildinfo

# Testing
coverage/
.nyc_output/

# IDEs
.vscode/
.idea/
*.swp
*.swo
*~

# OS
.DS_Store
Thumbs.db

# Logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# Environment
.env
.env.local
.env.*.local

9 changes: 9 additions & 0 deletions typescript/.prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"semi": true,
"trailingComma": "es5",
"singleQuote": true,
"printWidth": 100,
"tabWidth": 2,
"useTabs": false
}

Loading
Loading