Skip to content

Commit

Permalink
Reintroduce repo-wide checks (#42)
Browse files Browse the repository at this point in the history
As repository-wide checks were not ported over during the migration from
Travis to GitHub Actions, let's reintroduce them.

* Fix formatting errors in documentation
  • Loading branch information
j-lum authored Jun 16, 2020
1 parent 53a4c2d commit e90e56a
Show file tree
Hide file tree
Showing 11 changed files with 88 additions and 9 deletions.
18 changes: 18 additions & 0 deletions .github/check-eof-newline.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/bin/sh
# Checks that all text files end with a newline.

ret=0

# Preserve filename with spaces by only splitting on newlines.
IFS='
'

for filename in $(git grep --cached -I -l -e '' -- ':/'); do
if [ "$(tail -c 1 "./$filename")" != '' ]; then
line="$(wc -l "./$filename" | cut -d' ' -f1)"
echo "ERROR:$filename:$line: no newline at EOF."
ret=1
fi
done

exit $ret
19 changes: 19 additions & 0 deletions .github/check-line-endings.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/bin/sh
# Checks for prohibited line endings.
# Prohibited line endings: \r\n

git grep --cached -I -n --no-color -P '\r$' -- ':/' |
awk '
BEGIN {
FS = ":"
OFS = ":"
ret = 0
}
{
ret = 1
print "ERROR", $1, $2, " prohibited \\r\\n line ending, use \\n instead."
}
END {
exit ret
}
'
26 changes: 26 additions & 0 deletions .github/check-trailing-whitespace.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/bin/sh
# Checks for trailing whitespace

git grep --cached -I -n --no-color -P '[ \t]+$' -- ':/' |
awk '
BEGIN {
FS = ":"
OFS = ":"
ret = 0
}
{
# Only warn for markdown files (*.md) to accomodate text editors
# which do not properly handle trailing whitespace.
# (e.g. GitHub web editor)
if ($1 ~ /\.md$/) {
severity = "WARN"
} else {
severity = "ERROR"
ret = 1
}
print severity, $1, $2, " trailing whitespace."
}
END {
exit ret
}
'
11 changes: 11 additions & 0 deletions .github/run-checks.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/sh
# Runs all check-* scripts, and returns a non-zero exit code if any of them fail.

dir=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd) &&
ret=0 &&
for checkscript in "$dir"/check-*; do
if ! "$checkscript"; then
ret=1
fi
done
exit $ret
5 changes: 5 additions & 0 deletions .github/workflows/gradle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ jobs:
- name: Merge to master
run: git checkout --progress --force ${{ github.sha }}

- name: Run repository-wide tests
if: runner.os == 'Linux'
working-directory: ${{ github.workspace }}/.github
run: ./run-checks.sh

- name: Validate Gradle Wrapper
uses: gradle/wrapper-validation-action@v1

Expand Down
4 changes: 2 additions & 2 deletions docs/DeveloperGuide.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ The ***Architecture Diagram*** given above explains the high-level design of the
* At app launch: Initializes the components in the correct sequence, and connects them up with each other.
* At shut down: Shuts down the components and invokes cleanup methods where necessary.

[**`Commons`**](#common-classes) represents a collection of classes used by multiple other components.
[**`Commons`**](#common-classes) represents a collection of classes used by multiple other components.

The rest of the App consists of four components.

Expand Down Expand Up @@ -198,7 +198,7 @@ The following activity diagram summarizes what happens when a user executes a ne

![CommitActivityDiagram](images/CommitActivityDiagram.png)

#### Design consideration:
#### Design consideration:

##### Aspect: How undo & redo executes

Expand Down
2 changes: 1 addition & 1 deletion docs/Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }

gem 'jekyll'
gem 'github-pages', group: :jekyll_plugins
gem 'wdm', '~> 0.1.0' if Gem.win_platform?
gem 'wdm', '~> 0.1.0' if Gem.win_platform?
2 changes: 1 addition & 1 deletion docs/Testing.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,4 @@ This project has three types of tests:
1. *Integration tests* that are checking the integration of multiple code units (those code units are assumed to be working).<br>
e.g. `seedu.address.storage.StorageManagerTest`
1. Hybrids of unit and integration tests. These test are checking multiple code units as well as how the are connected together.<br>
e.g. `seedu.address.logic.LogicManagerTest`
e.g. `seedu.address.logic.LogicManagerTest`
4 changes: 2 additions & 2 deletions docs/UserGuide.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ AddressBook Level 3 (AB3) is a **desktop app for managing contacts, optimized fo
* **`add`**`n/John Doe p/98765432 e/[email protected] a/John street, block 123, #01-01` : Adds a contact named `John Doe` to the Address Book.

* **`delete`**`3` : Deletes the 3rd contact shown in the current list.

* **`clear`** : Deletes all contacts.

* **`exit`** : Exits the app.
Expand Down Expand Up @@ -73,7 +73,7 @@ Adds a person to the address book.

Format: `add n/NAME p/PHONE_NUMBER e/EMAIL a/ADDRESS [t/TAG]…​`

<div markdown="span" class="alert alert-primary">:bulb: **Tip:**
<div markdown="span" class="alert alert-primary">:bulb: **Tip:**
A person can have any number of tags (including 0)
</div>

Expand Down
2 changes: 1 addition & 1 deletion docs/tutorials/RemovingFields.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ Let’s try removing references to `Address` in `EditPersonDescriptor`.
1. Remove the usages of `address` and select `Do refactor` when you are done.

<div markdown="span" class="alert alert-primary">

:bulb: **Tip:** Removing usages may result in errors. Exercise discretion and fix them. For example, removing the `address` field from the `Person` class will require you to modify its constructor.
</div>

Expand Down
4 changes: 2 additions & 2 deletions docs/tutorials/TracingCode.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,9 @@ Recall from the User Guide that the `edit` command has the format: `edit INDEX [

``` java
@Override
public CommandResult execute(String commandText)
public CommandResult execute(String commandText)
throws CommandException, ParseException {

//Logging, safe to ignore
logger.info("----------------[USER COMMAND][" + commandText + "]");

Expand Down

0 comments on commit e90e56a

Please sign in to comment.