diff --git a/.github/workflows/test_typescript.yml b/.github/workflows/test_typescript.yml new file mode 100644 index 000000000..bd4dac5c6 --- /dev/null +++ b/.github/workflows/test_typescript.yml @@ -0,0 +1,40 @@ +name: Runs with TypeScript Tests +on: [push, pull_request] + +jobs: + test: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-node@v1 + + - name: Run TypeScript Compiler Tests with new dom.d.ts + run: | + # Get local dependencies + npm install + # Make our new dom APIs + npm run build + + # Clone TypeScript, set it up + git clone https://github.com/microsoft/TypeScript --depth 1 + + # Migrate the generated files into the repo + npm run migrate + + cd TypeScript + npm i + + + # Run TypeScript's tests with the new DOM libs, but don't fail + npm test || true + gulp baseline-accept + + # The git diff now is the difference between tests + git diff > baseline-changes.diff + + - name: Danger + run: npm run danger -- ci + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + diff --git a/.gitignore b/.gitignore index 9b2dda73d..72bc839d1 100644 --- a/.gitignore +++ b/.gitignore @@ -285,3 +285,4 @@ inputfiles/browser.webidl.json !.vscode/launch.template.json package-lock.json yarn.lock +TypeScript diff --git a/dangerfile.js b/dangerfile.js new file mode 100644 index 000000000..59101410f --- /dev/null +++ b/dangerfile.js @@ -0,0 +1,34 @@ +const {markdown} = require("danger") +const {readFileSync, existsSync} = require("fs") +const parseDiff = require("parse-diff") + +const diffPath = "./TypeScript/baseline-changes.diff" +if (existsSync(diffPath)) { + const diffContents = readFileSync(diffPath, "utf8") + const diffedFiles = parseDiff(diffContents) + + const uninterestingFiles = [".generated.d.ts", "globalThisBlockscopedProperties.types", "mappedTypeRecursiveInference.types"] + const withoutKnownNormalFails = diffedFiles.filter(diff => { + return !uninterestingFiles.filter(suffix => diff.to && diff.to.endsWith(suffix)).length > 0 + }) + + 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."] + + withoutKnownNormalFails.forEach(diff => { + md.push(`#### [${diff.to || diff.from}](https://github.com/microsoft/TypeScript/blob/master/${diff.to || diff.from})`) + + md.push("```diff") + diff.chunks.forEach(chunk => { + md.push(chunk.content) + + chunk.changes.forEach(change => { + md.push(change.content) + }) + }) + md.push("```") + }) + + if (md.length > 2) { + markdown(md.join("\n")) + } +} diff --git a/package.json b/package.json index 1a309116d..1ffaf3304 100644 --- a/package.json +++ b/package.json @@ -8,6 +8,7 @@ "fetch": "echo This could take a few minutes... && npm run fetch-idl && npm run fetch-mdn", "baseline-accept": "cpx \"generated\\*\" baselines\\", "test": "tsc -p ./tsconfig.json && node ./lib/index.js && node ./lib/test.js", + "danger": "danger", "migrate": "node ./lib/migrate-to-tsc.js" }, "dependencies": { @@ -16,8 +17,10 @@ "@types/node-fetch": "^2.5.7", "@types/webidl2": "^23.13.2", "cpx2": "^2.0.0", + "danger": "^10.5.4", "jsdom": "^16.4.0", "node-fetch": "^2.6.1", + "parse-diff": "^0.7.0", "print-diff": "^1.0.0", "styleless-innertext": "^1.1.2", "typescript": "4.1.0-dev.20200908",