From 6e7c9b11fe2508808c4e278580c8d2e134d1276a Mon Sep 17 00:00:00 2001 From: Jake Bailey <5341706+jakebailey@users.noreply.github.com> Date: Tue, 8 Nov 2022 21:39:10 -0800 Subject: [PATCH 1/2] Add smoke tests to CI --- .github/workflows/ci.yml | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1f014077728ab..4abaf52d60501 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -86,6 +86,33 @@ jobs: - name: Build src run: npx hereby build-src + smoke: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-node@v3 + with: + node-version: "*" + check-latest: true + - run: npm ci + + - run: npx hereby lkg + - run: | + npm pack + mv typescript*.tgz typescript.tgz + echo "PACKAGE=$PWD/typescript.tgz" >> $GITHUB_ENV + + - name: Smoke test + run: | + cd "$(mktemp -d)" + npm init --yes + npm install $PACKAGE + + npx tsc --version + echo '{"seq": 1, "command": "status"}' | npx tsserver + node -e 'console.log(require("typescript").version)' + node -e 'console.log(require("typescript/lib/tsserverlibrary").version)' misc: runs-on: ubuntu-latest From e2399793db2c7009cc8383a56385ac31b2fb0caa Mon Sep 17 00:00:00 2001 From: Jake Bailey <5341706+jakebailey@users.noreply.github.com> Date: Thu, 10 Nov 2022 19:24:54 -0800 Subject: [PATCH 2/2] Test matrix in smoke test --- .github/workflows/ci.yml | 39 ++++++++++++++++++++++++++++++++++++--- 1 file changed, 36 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4abaf52d60501..308e803d77804 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -107,12 +107,45 @@ jobs: run: | cd "$(mktemp -d)" npm init --yes - npm install $PACKAGE + npm install $PACKAGE tslib npx tsc --version echo '{"seq": 1, "command": "status"}' | npx tsserver - node -e 'console.log(require("typescript").version)' - node -e 'console.log(require("typescript/lib/tsserverlibrary").version)' + + cat > smoke.js << EOF + const { __importDefault, __importStar } = require("tslib"); + const ts = require(process.argv[2]); + + // See: https://github.com/microsoft/TypeScript/pull/51474#issuecomment-1310871623 + const fns = [ + [() => ts.version, true], + [() => ts.default.version, false], + [() => __importDefault(ts).version, false], + [() => __importDefault(ts).default.version, true], + [() => __importStar(ts).version, true], + [() => __importStar(ts).default.version, true], + ]; + + for (const [fn, shouldSucceed] of fns) { + let success = false; + try { + success = !!fn(); + } + catch {} + if (success !== shouldSucceed) { + if (success) { + console.error(`${fn.toString()} unexpectedly succeeded.`); + } + else { + console.error(`${fn.toString()} did not succeed.`); + } + process.exitCode = 1; + } + } + EOF + + node ./smoke.js typescript + node ./smoke.js typescript/lib/tsserverlibrary misc: runs-on: ubuntu-latest