Skip to content

Commit 56d8915

Browse files
authored
Add a build check for PRs (AssemblyScript#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.
1 parent 3a8f9f1 commit 56d8915

File tree

4 files changed

+41
-1
lines changed

4 files changed

+41
-1
lines changed

.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
bin/asc text eol=lf
22
dist/asc.js -diff
33
dist/assemblyscript.js -diff
4+
scripts/check-pr.sh eol=lf

.travis.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,17 @@
11
language: node_js
2+
notifications:
3+
email: false
4+
stages:
5+
- name: check-pr
6+
if: type = pull_request
27
jobs:
38
include:
49

10+
- stage: check-pr
11+
node_js: lts/*
12+
script: ./scripts/check-pr.sh
13+
env: Checks contributing guidelines before testing pull requests
14+
515
- stage: lint
616
node_js: node
717
script: npm run lint

scripts/check-pr.sh

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# Distribution files should not be modified
2+
STATUS=0
3+
if git --no-pager diff --name-only FETCH_HEAD $(git merge-base FETCH_HEAD $TRAVIS_BRANCH) | grep -q "^dist/"; then
4+
STATUS=1 &&
5+
printf "\n" &&
6+
printf "The pull request includes changes to distribution files, but it shouldn't.\n" &&
7+
printf "Please see https://github.com/AssemblyScript/assemblyscript/blob/master/CONTRIBUTING.md\n";
8+
else
9+
printf "\n" &&
10+
printf "GOOD: The pull request does not include changes to distribution files.\n";
11+
fi
12+
13+
# Authors should have added themself to the NOTICE file
14+
AUTHOR=$(git log -1 --format="%aE")
15+
if [ -z "$AUTHOR" ]; then
16+
printf "\n" &&
17+
printf "Skipping NOTICE check: Commit does not include an email address.\n";
18+
else
19+
if grep -q "$AUTHOR" NOTICE; then
20+
printf "\n" &&
21+
printf "GOOD: Author is present in the NOTICE file.\n";
22+
else
23+
printf "\n" &&
24+
printf "Author does not appear to be listed in the NOTICE file, yet.\n" &&
25+
printf "Please see https://github.com/AssemblyScript/assemblyscript/blob/master/CONTRIBUTING.md\n";
26+
fi
27+
fi
28+
29+
exit $STATUS

src/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -541,7 +541,7 @@ export class Signature {
541541
// check return type
542542
var thisReturnType = this.returnType;
543543
var targetReturnType = target.returnType;
544-
return thisReturnType == targetReturnType || this.returnType.isAssignableTo(target.returnType);
544+
return thisReturnType == targetReturnType || thisReturnType.isAssignableTo(targetReturnType);
545545
}
546546

547547
/** Converts this signature to a function type string. */

0 commit comments

Comments
 (0)