mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-15 03:23:08 -06:00
Add smoke tests to CI (#51464)
This commit is contained in:
parent
2d5e37272d
commit
021fd20aac
60
.github/workflows/ci.yml
vendored
60
.github/workflows/ci.yml
vendored
@ -86,6 +86,66 @@ 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 tslib
|
||||
|
||||
npx tsc --version
|
||||
echo '{"seq": 1, "command": "status"}' | npx tsserver
|
||||
|
||||
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
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user