From d6be50326c939c0bff99024b5a14a4820ecb27e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Weslley=20Ara=C3=BAjo?= <46850407+wellwelwel@users.noreply.github.com> Date: Sun, 16 Apr 2023 08:28:27 -0300 Subject: [PATCH] ci: Adding TypeScript build test (#1957) --- .github/workflows/ci-tsc-build.yml | 38 ++++++++++++++++++++++++++++++ package.json | 1 + test/tsc-build/index.ts | 4 ++++ test/tsc-build/tsconfig.json | 18 ++++++++++++++ 4 files changed, 61 insertions(+) create mode 100644 .github/workflows/ci-tsc-build.yml create mode 100644 test/tsc-build/index.ts create mode 100644 test/tsc-build/tsconfig.json diff --git a/.github/workflows/ci-tsc-build.yml b/.github/workflows/ci-tsc-build.yml new file mode 100644 index 0000000000..4f59642344 --- /dev/null +++ b/.github/workflows/ci-tsc-build.yml @@ -0,0 +1,38 @@ +name: CI - TypeScript Build + +on: + pull_request: + push: + branches: [ main ] + + workflow_dispatch: + +jobs: + tests-tsc-build: + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + node-version: [18.x] + + name: Node.js ${{ matrix.node-version }} + steps: + - uses: actions/checkout@v3 + + - name: Set up Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v3 + with: + node-version: ${{ matrix.node-version }} + + - name: Cache dependencies + uses: actions/cache@v3 + with: + path: ~/.npm + key: npm-${{ hashFiles('package-lock.json') }} + restore-keys: npm- + + - name: Install npm dependencies + run: npm ci + + - name: Testing TypeScript build + run: npm run test:tsc-build diff --git a/package.json b/package.json index 3f4f48cc66..ce4cbd9896 100644 --- a/package.json +++ b/package.json @@ -12,6 +12,7 @@ "lint:code": "eslint index.js promise.js \"lib/**/*.js\" \"test/**/*.js\" \"benchmarks/**/*.js\"", "lint:docs": "eslint Contributing.md \"documentation/**/*.md\" \"examples/*.js\"", "test": "node ./test/run.js", + "test:tsc-build": "cd \"test/tsc-build\" && npx tsc -p \"tsconfig.json\"", "coverage-test": "c8 -r cobertura -r lcov -r text node ./test/run.js", "benchmark": "node ./benchmarks/benchmark.js", "prettier": "prettier --single-quote --trailing-comma none --write \"{lib,examples,test}/**/*.js\"", diff --git a/test/tsc-build/index.ts b/test/tsc-build/index.ts new file mode 100644 index 0000000000..1956ed7467 --- /dev/null +++ b/test/tsc-build/index.ts @@ -0,0 +1,4 @@ +import mysql from '../../index'; +import mysqlp from '../../promise'; + +export { mysql, mysqlp }; diff --git a/test/tsc-build/tsconfig.json b/test/tsc-build/tsconfig.json new file mode 100644 index 0000000000..6f7c8c0b7c --- /dev/null +++ b/test/tsc-build/tsconfig.json @@ -0,0 +1,18 @@ +{ + "include": ["index.ts"], + "compilerOptions": { + "target": "ES2016", + "module": "CommonJS", + "moduleResolution": "Node", + "isolatedModules": true, + "esModuleInterop": true, + "allowSyntheticDefaultImports": true, + "strict": true, + "alwaysStrict": true, + "noImplicitAny": true, + "strictFunctionTypes": false, + "skipLibCheck": false, + "noEmitOnError": true, + "noEmit": true + } +}