From 56d891583ed5a3ce4c7bd53e507ed97339854a06 Mon Sep 17 00:00:00 2001 From: Daniel Wirtz Date: Wed, 21 Mar 2018 13:26:11 +0100 Subject: [PATCH] Add a build check for PRs (#51) This now checks that distribution files are unmodified and fails otherwise. Also checks if the author is present in the NOTICE file and prints the result, but as email addresses may vary, does not hard-fail. --- .gitattributes | 1 + .travis.yml | 10 ++++++++++ scripts/check-pr.sh | 29 +++++++++++++++++++++++++++++ src/types.ts | 2 +- 4 files changed, 41 insertions(+), 1 deletion(-) create mode 100755 scripts/check-pr.sh diff --git a/.gitattributes b/.gitattributes index a17611cd..4583b202 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,3 +1,4 @@ bin/asc text eol=lf dist/asc.js -diff dist/assemblyscript.js -diff +scripts/check-pr.sh eol=lf diff --git a/.travis.yml b/.travis.yml index d3cf2688..6b5f9f69 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,7 +1,17 @@ language: node_js +notifications: + email: false +stages: + - name: check-pr + if: type = pull_request jobs: include: + - stage: check-pr + node_js: lts/* + script: ./scripts/check-pr.sh + env: Checks contributing guidelines before testing pull requests + - stage: lint node_js: node script: npm run lint diff --git a/scripts/check-pr.sh b/scripts/check-pr.sh new file mode 100755 index 00000000..1657439c --- /dev/null +++ b/scripts/check-pr.sh @@ -0,0 +1,29 @@ +# Distribution files should not be modified +STATUS=0 +if git --no-pager diff --name-only FETCH_HEAD $(git merge-base FETCH_HEAD $TRAVIS_BRANCH) | grep -q "^dist/"; then + STATUS=1 && + printf "\n" && + printf "The pull request includes changes to distribution files, but it shouldn't.\n" && + printf "Please see https://github.com/AssemblyScript/assemblyscript/blob/master/CONTRIBUTING.md\n"; +else + printf "\n" && + printf "GOOD: The pull request does not include changes to distribution files.\n"; +fi + +# Authors should have added themself to the NOTICE file +AUTHOR=$(git log -1 --format="%aE") +if [ -z "$AUTHOR" ]; then + printf "\n" && + printf "Skipping NOTICE check: Commit does not include an email address.\n"; +else + if grep -q "$AUTHOR" NOTICE; then + printf "\n" && + printf "GOOD: Author is present in the NOTICE file.\n"; + else + printf "\n" && + printf "Author does not appear to be listed in the NOTICE file, yet.\n" && + printf "Please see https://github.com/AssemblyScript/assemblyscript/blob/master/CONTRIBUTING.md\n"; + fi +fi + +exit $STATUS diff --git a/src/types.ts b/src/types.ts index 94b93b4d..c410e126 100644 --- a/src/types.ts +++ b/src/types.ts @@ -541,7 +541,7 @@ export class Signature { // check return type var thisReturnType = this.returnType; var targetReturnType = target.returnType; - return thisReturnType == targetReturnType || this.returnType.isAssignableTo(target.returnType); + return thisReturnType == targetReturnType || thisReturnType.isAssignableTo(targetReturnType); } /** Converts this signature to a function type string. */