Skip to content

Adds testing the TypeScript repo against PR changes #867

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 15 commits into from
Jan 13, 2021
Merged
Show file tree
Hide file tree
Changes from 11 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions .github/workflows/test_typescript.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
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

- 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
cd TypeScript
npm i

# Move in the generated dom APIs into a new version of TSC
cp -rf ../generated/* src/lib

# 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 }}

1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -285,3 +285,4 @@ inputfiles/browser.webidl.json
!.vscode/launch.template.json
package-lock.json
yarn.lock
TypeScript
33 changes: 33 additions & 0 deletions dangerfile.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
const {message} = 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("```")
})


message(md.join("\n"))
}
5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,19 @@
"fetch-mdn": "npm run build && node ./lib/mdnfetcher.js",
"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"
"test": "tsc -p ./tsconfig.json && node ./lib/index.js && node ./lib/test.js",
"danger": "danger"
},
"dependencies": {
"@types/jsdom": "^16.2.4",
"@types/node": "^14.6.4",
"@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",
Expand Down