Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
50d1085
Basic bazel setup.
9Y5 Aug 17, 2021
b5eb9ac
Update documentation.
9Y5 Aug 17, 2021
7aa0bff
Add unit test, test runner and refactor.
9Y5 Aug 17, 2021
f659ebb
Cleaner test.
9Y5 Aug 17, 2021
1e8da3d
Split into packages. Implement Level 1.
9Y5 Aug 20, 2021
e15de96
Fix bug -- should return response text.
9Y5 Aug 20, 2021
67cbff0
Implement level 2 -- Add, List.
9Y5 Aug 20, 2021
7321f72
Refactor into separate method.
9Y5 Aug 20, 2021
8545772
Implements Level-3: Mark as Done
9Y5 Aug 21, 2021
9aa137f
Refactor markasdone as separate responder.
9Y5 Aug 21, 2021
f6069de
Refactor BUILD file.
9Y5 Aug 22, 2021
85c0c59
Implement A-TextUiTesting for macOS and bazel.
9Y5 Aug 23, 2021
6a85092
Basic github workflow:
9Y5 Aug 23, 2021
f30fd06
Run through google-java-format. Add checkstyle config. (#1)
lockarhythm Aug 24, 2021
6c2adf8
Update README layout
lockarhythm Aug 24, 2021
dd6438f
Add pre-commit hook. (#2)
lockarhythm Aug 24, 2021
ee1fd29
Fix Level-3 mark as done. (#3)
lockarhythm Aug 24, 2021
437b385
More classes (#4)
lockarhythm Aug 29, 2021
0605449
Implement Level-4, A-Inheritance. Implement partially Level-5. (#5)
lockarhythm Aug 31, 2021
99c1e95
Implement Level-5 and A-Exceptions. Throw DukeException instead of re…
lockarhythm Aug 31, 2021
52c3d42
Add gif demo in README
lockarhythm Aug 31, 2021
27456d4
Implement delete Level-6 (#8)
lockarhythm Sep 21, 2021
38456e3
Save tasks (#9)
lockarhythm Oct 17, 2021
59884c4
Implement Level-8 minimum. (#10)
lockarhythm Oct 17, 2021
a8eccff
Improve Text UI tests. Added tests for saved serialized data. (#11)
lockarhythm Oct 17, 2021
0c8a48e
Implement C-Sort: Sort tasks by "Date" or" Done" fields (#12)
lockarhythm Oct 24, 2021
50d0cce
Basic implementation for Level-9: find feature. (#13)
lockarhythm Oct 24, 2021
11ef984
Use NLP for dates parsing and include time in formatting. (#14)
lockarhythm Oct 24, 2021
94ad2b6
Run through code formatter. (#15)
lockarhythm Oct 25, 2021
c401a18
Fix code quality feedback #16 (#17)
lockarhythm Oct 26, 2021
fd53b74
Implement A-Assertions (#18)
lockarhythm Oct 26, 2021
ff37085
Add java docs (#25)
lockarhythm Nov 14, 2021
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
45 changes: 45 additions & 0 deletions .github/workflows/workflow.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
on: push
name: Build, Test and Upload JAR
jobs:
checks:
name: Run Unit Tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master

- name: Mount bazel cache
uses: actions/cache@v1
with:
path: "/home/runner/.cache/bazel"
key: bazel

- name: Install bazelisk
run: |
curl -LO "https://github.com/bazelbuild/bazelisk/releases/download/v1.1.0/bazelisk-linux-amd64"
mkdir -p "${GITHUB_WORKSPACE}/bin/"
mv bazelisk-linux-amd64 "${GITHUB_WORKSPACE}/bin/bazel"
chmod +x "${GITHUB_WORKSPACE}/bin/bazel"

- name: Run Unit Tests
run: |
"${GITHUB_WORKSPACE}/bin/bazel" test //...

- name: Run UI and Serialization Tests
working-directory: ./text-ui-test
run: |
chmod +x runtest.sh
./runtest.sh

- name: Build JAR File
run: |
"${GITHUB_WORKSPACE}/bin/bazel" build //:TerminalDuke_deploy.jar

- name: "Move file to non-symlink directory (a workaround for some bug See: https://github.com/actions/upload-artifact/issues/92)"
run: |
mv ${{ github.workspace }}/bazel-bin/TerminalDuke_deploy.jar ${{ github.workspace }}/TerminalDuke_deploy.jar

- name: Upload JAR File
uses: actions/upload-artifact@v2
with:
name: TerminalDuke_deploy.jar
path: ${{ github.workspace }}/TerminalDuke_deploy.jar
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,12 @@ src/main/resources/docs/
bin/

/text-ui-test/ACTUAL.txt
/text-ui-test/tasks.json
text-ui-test/EXPECTED-UNIX.TXT

# Ignore all bazel-* symlinks. There is no full list since this can change
# based on the name of the directory bazel is cloned into.
/bazel-*

# for pre-commit git-hooks
/.cache/*
7 changes: 7 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# See https://pre-commit.com for more information
# See https://pre-commit.com/hooks.html for more hooks
repos:
- repo: https://github.com/maltzj/google-style-precommit-hook
rev: b7e9e7fcba4a5aea463e72fe9964c14877bd8130
hooks:
- id: google-style-java
8 changes: 8 additions & 0 deletions .pre-commit-hooks.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Pre-commit hook to run google-format-java right before commiting
# Source: https://github.com/maltzj/google-style-precommit-hook
- id: google-style-java
name: Google Java Code Style for Java
description: Formats code in Google's Java codestyle.
entry: ./tools/format-code.sh
language: script
files: \.java$ # We don't technically need this, as the script will filter for us, but this will allow the hook to be skipped if no Java is changed.
54 changes: 54 additions & 0 deletions BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
load("@rules_java//java:defs.bzl", "java_binary", "java_test")

java_binary(
name = "TerminalDuke", # Production Build.
srcs = glob([
"src/main/java/com/lockarhythm/**/*.java",
]),
deps = [
"@maven//:org_apache_commons_commons_lang3",
"@maven//:com_google_code_gson_gson",
"@maven//:org_ocpsoft_prettytime_prettytime_nlp",
],
)

java_binary(
name = "TerminalDukeQA", # QA Build. has assertions enabled.
main_class = "com.lockarhythm.application.TerminalDuke",
srcs = glob([
"src/main/java/com/lockarhythm/**/*.java",
]),
deps = [
"@maven//:org_apache_commons_commons_lang3",
"@maven//:com_google_code_gson_gson",
"@maven//:org_ocpsoft_prettytime_prettytime_nlp",
],
jvm_flags = [
"-enableassertions",
],
)

[
java_test(
name = class_name,
size = "small",
srcs = glob([
"src/test/java/com/lockarhythm/**/*.java",
"src/main/java/com/lockarhythm/**/*.java",
]),
deps = [
"@maven//:org_apache_commons_commons_lang3",
"@maven//:com_google_code_gson_gson",
"@maven//:org_ocpsoft_prettytime_prettytime_nlp",
]
)
for class_name in [
"TestTerminalDuke",
"TestEchoResponder",
"TestExitResponder",
"TestListResponder",
"TestMarkAsDoneResponder",
"TestTodoTask",
"TestTaskList",
]
]
79 changes: 58 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,24 +1,61 @@
# Duke project template
<img src="https://user-images.githubusercontent.com/88638946/130622078-e049680c-7895-4725-ace0-49869574887c.png" width="50%" align="right">

# Duke

This is a project template for a greenfield Java project. It's named after the Java mascot _Duke_. Given below are instructions on how to use it.

## Setting up in Intellij

Prerequisites: JDK 11, update Intellij to the most recent version.

1. Open Intellij (if you are not in the welcome screen, click `File` > `Close Project` to close the existing project first)
1. Open the project into Intellij as follows:
1. Click `Open`.
1. Select the project directory, and click `OK`.
1. If there are any further prompts, accept the defaults.
1. Configure the project to use **JDK 11** (not other versions) as explained in [here](https://www.jetbrains.com/help/idea/sdk.html#set-up-jdk).<br>
In the same dialog, set the **Project language level** field to the `SDK default` option.
3. After that, locate the `src/main/java/Duke.java` file, right-click it, and choose `Run Duke.main()` (if the code editor is showing compile errors, try restarting the IDE). If the setup is correct, you should see something like the below as the output:
```
Hello from
____ _
| _ \ _ _| | _____
| | | | | | | |/ / _ \
| |_| | |_| | < __/
|____/ \__,_|_|\_\___|
```
## Demo
![output](https://user-images.githubusercontent.com/88638946/131530452-cbe5ab59-9e43-4c08-affe-f9fdf2c75427.gif)


## Build
Prerequisites: Have `bazel` installed.

To build for local development on macOS:
```bash
# bazel makes a wrapper script around the jar file.
bazel build //:TerminalDuke && ./bazel-bin/TerminalDuke

# or simply
bazel run //:TerminalDuke

# Use bazelisk for M1 Macs (Apple Silicon)
USE_BAZEL_VERSION=ac9353fab161efae4af72e73fbb657a762b3620d bazelisk run //:TerminalDuke

# For QA build, for example, having assertions enabled, build TerminalDukeQA instead
USE_BAZEL_VERSION=ac9353fab161efae4af72e73fbb657a762b3620d bazelisk run //:TerminalDukeQA
```

To build jar file for deployment purposes:
```bash
bazel build //:Duke_deploy.jar

java -jar ./bazel-bin/Duke_deploy.jar
```

## Testing
For unit tests:
```bash
bazel test --test_output=all //...
```
For terminal ui tests (`text-ui-test`):
```bash
cd text-ui-test
./runtest.sh
```

## Code Formatting & Style
Use [google-java-format](https://github.com/google/google-java-format):
```bash
google-java-format --replace **/*.java # executes recursively
```

## Pre-commit Git Hook (Tested on macOS)
`pre-commit` is a python tool that helps to create git pre-commit hook handlers. For this project, it is used to enforce Google Java Style (via `google-java-format`) on new commits.

To setup, ensure you have [`pre-commit`](https://pre-commit.com/#install) installed, then run:
```bash
pre-commit install
```
This only needs to be executed once, so that `pre-commit` can generate the script and write it to `.git/hooks/pre-commit`
Thereafter, it should be executed right before every commit!
27 changes: 27 additions & 0 deletions WORKSPACE
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")

RULES_JVM_EXTERNAL_TAG = "4.0"
RULES_JVM_EXTERNAL_SHA = "31701ad93dbfe544d597dbe62c9a1fdd76d81d8a9150c2bf1ecf928ecdf97169"

http_archive(
name = "rules_jvm_external",
strip_prefix = "rules_jvm_external-%s" % RULES_JVM_EXTERNAL_TAG,
sha256 = RULES_JVM_EXTERNAL_SHA,
url = "https://github.com/bazelbuild/rules_jvm_external/archive/%s.zip" % RULES_JVM_EXTERNAL_TAG,
)

load("@rules_jvm_external//:defs.bzl", "maven_install")

maven_install(
artifacts = [
#"com.google.guava:guava:21.0",
"org.apache.commons:commons-lang3:3.11",
"com.google.code.gson:gson:2.8.8",
"org.ocpsoft.prettytime:prettytime-nlp:5.0.2.Final"
],
repositories = [
# Private repositories are supported through HTTP Basic auth
"https://maven.google.com",
"https://repo1.maven.org/maven2",
],
)
Loading