From 6a89285dd6a606c8a779c7e78d9153d659573e1a Mon Sep 17 00:00:00 2001 From: Rui Hu Date: Thu, 14 Mar 2024 13:35:49 +0800 Subject: [PATCH] Add readme for building --- .gitlab-ci.yml | 18 +++++++++++++++++ README.md | 20 +++++++++++++++++++ .../interview/PerformanceAnalyze.java | 8 +++----- 3 files changed, 41 insertions(+), 5 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 52f8adf..968cd23 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -2,8 +2,26 @@ image: azul/zulu-openjdk:8-latest stages: - test + - analyze +# verify the padlock impl independently unit-test-padlock-impl: stage: test script: - ./gradlew :padlock-impl:test + +unit-test-all: + stage: test + script: + - ./gradlew test + artifacts: + when: always + reports: + junit: build/test-results/test/**/TEST-*.xml + +run-performance-analyze: + stage: analyze + needs: + - job: unit-test-all + script: + - ./gradlew runPerformanceAnalyze diff --git a/README.md b/README.md index f9c0acf..8dc4c96 100644 --- a/README.md +++ b/README.md @@ -48,6 +48,26 @@ You should design the proper architectures for your code. Last but not least, readability and maintainability are also important. Take this project as a show off to your designing and coding skills. +## Build + +This repo uses Gradle to build and test. +There is a unit test boilerplate and a gradle task configured to +automatically test and evaluate the code when you push your commits. + +The `SolutionTestBase` is an abstract class for other tests. +It tests the correctness of your solution and don't care about the run time. +See `SolutionTest` for how to use that. + +The `PerformanceAnalyze` is not a unit test, but it do analyze roughly how +fast your solution is. You need to fill in the `solve` method before you run it. + +Use `./gradlew test` to run all unit test configured in the project, +and use `./gradlew runPerformanceTest` to get an analysis. + +> Note: You don't have to have a local gradle installation. +> The `gradlew` script will download one for you. +> Just install a valid jdk (version >= 8) and very thing should be fine. + ## Still have unclear problems? Feel free to contact Jeffrey Freeman (jeffrey.freeman@cleverthis.com). \ No newline at end of file diff --git a/src/test/java/com/cleverthis/interview/PerformanceAnalyze.java b/src/test/java/com/cleverthis/interview/PerformanceAnalyze.java index 6c3b089..97be426 100644 --- a/src/test/java/com/cleverthis/interview/PerformanceAnalyze.java +++ b/src/test/java/com/cleverthis/interview/PerformanceAnalyze.java @@ -7,15 +7,13 @@ import com.cleverthis.interview.padlock.PadlockImpl; */ public class PerformanceAnalyze { private static void solve(PadlockImpl padlock) { - // TODO + new Solution().solve(padlock); } - private static final String RUN_NAME = "Boilerplate"; - private static final int TOTAL_RUN = 50; - private static final int NUMPAD_SIZE = 7; + private static final int TOTAL_RUN = 500; + private static final int NUMPAD_SIZE = 9; static { - System.out.println("Run name: " + RUN_NAME); System.out.println("Total run: " + TOTAL_RUN); System.out.println("Numpad size: " + NUMPAD_SIZE); }