Skip to content

Commit 021fd20

Browse files
authored
Add smoke tests to CI (#51464)
1 parent 2d5e372 commit 021fd20

File tree

1 file changed

+60
-0
lines changed

1 file changed

+60
-0
lines changed

.github/workflows/ci.yml

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,66 @@ jobs:
8686
- name: Build src
8787
run: npx hereby build-src
8888

89+
smoke:
90+
runs-on: ubuntu-latest
91+
92+
steps:
93+
- uses: actions/checkout@v3
94+
- uses: actions/setup-node@v3
95+
with:
96+
node-version: "*"
97+
check-latest: true
98+
- run: npm ci
99+
100+
- run: npx hereby lkg
101+
- run: |
102+
npm pack
103+
mv typescript*.tgz typescript.tgz
104+
echo "PACKAGE=$PWD/typescript.tgz" >> $GITHUB_ENV
105+
106+
- name: Smoke test
107+
run: |
108+
cd "$(mktemp -d)"
109+
npm init --yes
110+
npm install $PACKAGE tslib
111+
112+
npx tsc --version
113+
echo '{"seq": 1, "command": "status"}' | npx tsserver
114+
115+
cat > smoke.js << EOF
116+
const { __importDefault, __importStar } = require("tslib");
117+
const ts = require(process.argv[2]);
118+
119+
// See: https://github.com/microsoft/TypeScript/pull/51474#issuecomment-1310871623
120+
const fns = [
121+
[() => ts.version, true],
122+
[() => ts.default.version, false],
123+
[() => __importDefault(ts).version, false],
124+
[() => __importDefault(ts).default.version, true],
125+
[() => __importStar(ts).version, true],
126+
[() => __importStar(ts).default.version, true],
127+
];
128+
129+
for (const [fn, shouldSucceed] of fns) {
130+
let success = false;
131+
try {
132+
success = !!fn();
133+
}
134+
catch {}
135+
if (success !== shouldSucceed) {
136+
if (success) {
137+
console.error(`${fn.toString()} unexpectedly succeeded.`);
138+
}
139+
else {
140+
console.error(`${fn.toString()} did not succeed.`);
141+
}
142+
process.exitCode = 1;
143+
}
144+
}
145+
EOF
146+
147+
node ./smoke.js typescript
148+
node ./smoke.js typescript/lib/tsserverlibrary
89149
90150
misc:
91151
runs-on: ubuntu-latest

0 commit comments

Comments
 (0)