Skip to content

Commit ae59d91

Browse files
author
Orta Therox
authored
Merge pull request #867 from microsoft/test_tsc
Adds testing the TypeScript repo against PR changes
2 parents 7d71d3c + 2f44fbb commit ae59d91

File tree

4 files changed

+78
-0
lines changed

4 files changed

+78
-0
lines changed

.github/workflows/test_typescript.yml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
name: Runs with TypeScript Tests
2+
on: [push, pull_request]
3+
4+
jobs:
5+
test:
6+
runs-on: ubuntu-latest
7+
8+
steps:
9+
- uses: actions/checkout@v2
10+
- uses: actions/setup-node@v1
11+
12+
- name: Run TypeScript Compiler Tests with new dom.d.ts
13+
run: |
14+
# Get local dependencies
15+
npm install
16+
# Make our new dom APIs
17+
npm run build
18+
19+
# Clone TypeScript, set it up
20+
git clone https://github.com/microsoft/TypeScript --depth 1
21+
22+
# Migrate the generated files into the repo
23+
npm run migrate
24+
25+
cd TypeScript
26+
npm i
27+
28+
29+
# Run TypeScript's tests with the new DOM libs, but don't fail
30+
npm test || true
31+
gulp baseline-accept
32+
33+
# The git diff now is the difference between tests
34+
git diff > baseline-changes.diff
35+
36+
- name: Danger
37+
run: npm run danger -- ci
38+
env:
39+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
40+

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -285,3 +285,4 @@ inputfiles/browser.webidl.json
285285
!.vscode/launch.template.json
286286
package-lock.json
287287
yarn.lock
288+
TypeScript

dangerfile.js

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
const {markdown} = require("danger")
2+
const {readFileSync, existsSync} = require("fs")
3+
const parseDiff = require("parse-diff")
4+
5+
const diffPath = "./TypeScript/baseline-changes.diff"
6+
if (existsSync(diffPath)) {
7+
const diffContents = readFileSync(diffPath, "utf8")
8+
const diffedFiles = parseDiff(diffContents)
9+
10+
const uninterestingFiles = [".generated.d.ts", "globalThisBlockscopedProperties.types", "mappedTypeRecursiveInference.types"]
11+
const withoutKnownNormalFails = diffedFiles.filter(diff => {
12+
return !uninterestingFiles.filter(suffix => diff.to && diff.to.endsWith(suffix)).length > 0
13+
})
14+
15+
const md = ["## Changed baselines from the TypeScript test suite", "\nThese are the test changes in the TypeScript codebase which showed a difference (excluding a few which will always change), it should give a small sense of what to expect on the TypeScript side if this PR is merged."]
16+
17+
withoutKnownNormalFails.forEach(diff => {
18+
md.push(`#### [${diff.to || diff.from}](https://github.com/microsoft/TypeScript/blob/master/${diff.to || diff.from})`)
19+
20+
md.push("```diff")
21+
diff.chunks.forEach(chunk => {
22+
md.push(chunk.content)
23+
24+
chunk.changes.forEach(change => {
25+
md.push(change.content)
26+
})
27+
})
28+
md.push("```")
29+
})
30+
31+
if (md.length > 2) {
32+
markdown(md.join("\n"))
33+
}
34+
}

package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
"fetch": "echo This could take a few minutes... && npm run fetch-idl && npm run fetch-mdn",
99
"baseline-accept": "cpx \"generated\\*\" baselines\\",
1010
"test": "tsc -p ./tsconfig.json && node ./lib/index.js && node ./lib/test.js",
11+
"danger": "danger",
1112
"migrate": "node ./lib/migrate-to-tsc.js"
1213
},
1314
"dependencies": {
@@ -16,8 +17,10 @@
1617
"@types/node-fetch": "^2.5.7",
1718
"@types/webidl2": "^23.13.2",
1819
"cpx2": "^2.0.0",
20+
"danger": "^10.5.4",
1921
"jsdom": "^16.4.0",
2022
"node-fetch": "^2.6.1",
23+
"parse-diff": "^0.7.0",
2124
"print-diff": "^1.0.0",
2225
"styleless-innertext": "^1.1.2",
2326
"typescript": "4.1.0-dev.20200908",

0 commit comments

Comments
 (0)