From e90e56a060214200a4743e43b5ca01b1a2b6e2fb Mon Sep 17 00:00:00 2001 From: Jeffry Lum <22460123+j-lum@users.noreply.github.com> Date: Tue, 16 Jun 2020 22:11:23 +0800 Subject: [PATCH] Reintroduce repo-wide checks (#42) 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 --- .github/check-eof-newline.sh | 18 ++++++++++++++++++ .github/check-line-endings.sh | 19 +++++++++++++++++++ .github/check-trailing-whitespace.sh | 26 ++++++++++++++++++++++++++ .github/run-checks.sh | 11 +++++++++++ .github/workflows/gradle.yml | 5 +++++ docs/DeveloperGuide.md | 4 ++-- docs/Gemfile | 2 +- docs/Testing.md | 2 +- docs/UserGuide.md | 4 ++-- docs/tutorials/RemovingFields.md | 2 +- docs/tutorials/TracingCode.md | 4 ++-- 11 files changed, 88 insertions(+), 9 deletions(-) create mode 100755 .github/check-eof-newline.sh create mode 100755 .github/check-line-endings.sh create mode 100755 .github/check-trailing-whitespace.sh create mode 100755 .github/run-checks.sh diff --git a/.github/check-eof-newline.sh b/.github/check-eof-newline.sh new file mode 100755 index 00000000000..b771f3988dd --- /dev/null +++ b/.github/check-eof-newline.sh @@ -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 diff --git a/.github/check-line-endings.sh b/.github/check-line-endings.sh new file mode 100755 index 00000000000..3de67ea87f6 --- /dev/null +++ b/.github/check-line-endings.sh @@ -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 + } +' diff --git a/.github/check-trailing-whitespace.sh b/.github/check-trailing-whitespace.sh new file mode 100755 index 00000000000..33841caa81f --- /dev/null +++ b/.github/check-trailing-whitespace.sh @@ -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 + } +' diff --git a/.github/run-checks.sh b/.github/run-checks.sh new file mode 100755 index 00000000000..7aad1e96220 --- /dev/null +++ b/.github/run-checks.sh @@ -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 diff --git a/.github/workflows/gradle.yml b/.github/workflows/gradle.yml index 391c46b4fe9..e0de81abaf1 100644 --- a/.github/workflows/gradle.yml +++ b/.github/workflows/gradle.yml @@ -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 diff --git a/docs/DeveloperGuide.md b/docs/DeveloperGuide.md index db96476f913..4829fe43011 100644 --- a/docs/DeveloperGuide.md +++ b/docs/DeveloperGuide.md @@ -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. @@ -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 diff --git a/docs/Gemfile b/docs/Gemfile index bf0110f33cb..999a7099d8d 100644 --- a/docs/Gemfile +++ b/docs/Gemfile @@ -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? \ No newline at end of file +gem 'wdm', '~> 0.1.0' if Gem.win_platform? diff --git a/docs/Testing.md b/docs/Testing.md index 3d584134452..8a99e82438a 100644 --- a/docs/Testing.md +++ b/docs/Testing.md @@ -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).
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.
- e.g. `seedu.address.logic.LogicManagerTest` \ No newline at end of file + e.g. `seedu.address.logic.LogicManagerTest` diff --git a/docs/UserGuide.md b/docs/UserGuide.md index 5d0883ceb55..b91c3bab04d 100644 --- a/docs/UserGuide.md +++ b/docs/UserGuide.md @@ -29,7 +29,7 @@ AddressBook Level 3 (AB3) is a **desktop app for managing contacts, optimized fo * **`add`**`n/John Doe p/98765432 e/johnd@example.com 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. @@ -73,7 +73,7 @@ Adds a person to the address book. Format: `add n/NAME p/PHONE_NUMBER e/EMAIL a/ADDRESS [t/TAG]…​` -
:bulb: **Tip:** +
:bulb: **Tip:** A person can have any number of tags (including 0)
diff --git a/docs/tutorials/RemovingFields.md b/docs/tutorials/RemovingFields.md index d8dc5d9fcf8..aa8e0baaad9 100644 --- a/docs/tutorials/RemovingFields.md +++ b/docs/tutorials/RemovingFields.md @@ -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.
- + :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.
diff --git a/docs/tutorials/TracingCode.md b/docs/tutorials/TracingCode.md index 1ecd0a1c4db..bd34ed498cd 100644 --- a/docs/tutorials/TracingCode.md +++ b/docs/tutorials/TracingCode.md @@ -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 + "]");