-
Notifications
You must be signed in to change notification settings - Fork 0
Ci/setup pipeline, enforce test coverage and improve tests #3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
codesungrape
merged 14 commits into
main
from
ci/setup-pipeline,-enforce-test-coverage-and-improve-tests
Nov 17, 2025
Merged
Changes from 9 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
235a161
Reformatted with checkstyle
codesungrape faa2e29
Reformat files to comply with Checkstyle rules
codesungrape 4f9a016
Conform to HMCTS Checkstyle; add private constructor
codesungrape b7c1b9b
Add informative comments for future ref
codesungrape 35e12c1
chore: align project formatting and config with HMCTS standards
codesungrape 1f29940
Update file to aggregate tasks to run with one check cmd
codesungrape 8ab98d6
Remove redundant ReturnNull check + update Javadoc string
codesungrape 527e538
Update READme.md
codesungrape 0aa4521
Add CI workflow for merge to main
codesungrape 8324889
Apply grammatical typo/fixes from Copilot
codesungrape 9346299
Apply copilot typo suggestion
codesungrape 69f1730
200~Remove @ActiveProfiles since all envs currently use H2
codesungrape 039ffc5
Update Javadoc to reflect use of record vs lobok @Value
codesungrape 8fbc951
Remove unused ActiveProfiles import
codesungrape File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| # http://editorconfig.org | ||
| root = true | ||
|
|
||
| [*] | ||
| indent_style = space | ||
| indent_size = 2 | ||
| end_of_line = lf | ||
| charset = utf-8 | ||
| trim_trailing_whitespace = true | ||
| insert_final_newline = true | ||
| max_line_length = 120 | ||
|
|
||
| [*.java] | ||
| indent_size = 4 | ||
| ij_continuation_indent_size = 4 | ||
| ij_java_align_multiline_parameters = true | ||
| ij_java_align_multiline_parameters_in_calls = true | ||
| ij_java_call_parameters_new_line_after_left_paren = true | ||
| ij_java_call_parameters_right_paren_on_new_line = true | ||
| ij_java_call_parameters_wrap = on_every_item |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| name: Build & Quality Checks | ||
|
|
||
| on: | ||
| pull_request: | ||
| push: | ||
| branches: [ main ] | ||
|
|
||
| jobs: | ||
| build: | ||
| runs-on: ubuntu-latest | ||
|
|
||
| steps: | ||
| - uses: actions/checkout@v4 | ||
|
|
||
| - name: Set up JDK 21 | ||
| uses: actions/setup-java@v4 | ||
| with: | ||
| java-version: '21' | ||
| distribution: 'temurin' | ||
|
|
||
| - name: Make gradlew executable | ||
| run: chmod +x ./gradlew | ||
|
|
||
| - name: Run Gradle checks | ||
| run: ./gradlew clean check |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1,189 @@ | ||
| # S_BookAPIJAVA | ||
| # S_BookAPIJAVA | ||
|
|
||
| # Code Quality & Static Analysis | ||
|
|
||
| This project follows HMCTS engineering standards for formatting, style, static analysis, and code coverage. | ||
| The following tools are configured and integrated with Gradle: | ||
|
|
||
| - Checkstyle – HMCTS Java code conventions | ||
|
|
||
| - SpotBugs – static analysis for potential defects | ||
|
|
||
| - JaCoCo – code coverage reporting | ||
|
|
||
| - EditorConfig – consistent whitespace and formatting rules | ||
|
|
||
|
|
||
| ---------- | ||
|
|
||
| ## Checkstyle (HMCTS rules) | ||
|
|
||
| Checkstyle uses the HMCTS `checkstyle.xml`, enforcing naming, formatting, Javadoc, and structural rules. | ||
|
|
||
| ### Run Checkstyle | ||
|
|
||
| `./gradlew checkstyleMain | ||
| ./gradlew checkstyleTest` | ||
|
|
||
| ### Run all Checkstyle tasks | ||
|
|
||
| `./gradlew checkstyle` | ||
|
|
||
| ### Checkstyle reports | ||
|
|
||
| Reports are generated at: | ||
|
|
||
| `build/reports/checkstyle/` | ||
|
|
||
| ---------- | ||
|
|
||
| ## SpotBugs (static analysis) | ||
|
|
||
| SpotBugs analyses compiled bytecode and flags potential null pointer issues, performance problems, and common Java defects. | ||
|
|
||
| ### List SpotBugs tasks | ||
|
|
||
| `./gradlew tasks --all | grep spotbugs` | ||
|
|
||
| ### Run SpotBugs on main code | ||
|
|
||
| `./gradlew spotbugsMain` | ||
|
|
||
| ### Run SpotBugs on test code | ||
|
|
||
| `./gradlew spotbugsTest` | ||
|
|
||
| ### Run all SpotBugs tasks | ||
|
|
||
| `./gradlew spotbugs` | ||
|
|
||
| ### SpotBugs reports | ||
|
|
||
| `build/reports/spotbugs/` | ||
|
|
||
| ---------- | ||
|
|
||
| ## JaCoCo (test coverage) | ||
|
|
||
| JaCoCo generates unit test and integration test coverage reports in XML and HTML. | ||
|
|
||
| ### Run tests and generate JaCoCo reports | ||
|
|
||
| `./gradlew test jacocoTestReport` | ||
|
|
||
| ### Coverage report location | ||
|
|
||
| `build/reports/jacoco/test/jacocoTestReport.html` | ||
|
|
||
| ---------- | ||
|
|
||
| ## EditorConfig (formatting and whitespace) | ||
|
|
||
| The project uses HMCTS `.editorconfig` rules, enforcing: | ||
|
|
||
| - 2-space indentation for most files | ||
|
|
||
| - 4-space indentation for `.java` files | ||
|
|
||
| - `LF` line endings | ||
|
|
||
| - UTF-8 charset | ||
|
|
||
| - No trailing whitespace | ||
|
|
||
| - A newline at the end of every file | ||
|
|
||
|
|
||
| Most IDEs (including IntelliJ) apply these rules automatically. | ||
|
|
||
| ---------- | ||
|
|
||
| ## Running all verification tasks | ||
|
|
||
| To verify everything before committing: | ||
|
|
||
| `./gradlew clean build` | ||
|
|
||
| This runs: | ||
|
|
||
| - Checkstyle | ||
|
|
||
| - SpotBugs | ||
|
|
||
| - Tests | ||
|
|
||
| - JaCoCo | ||
|
|
||
| - Compilation | ||
|
|
||
| - Packaging | ||
|
|
||
| ---------- | ||
|
|
||
| ### Gradle Daemon: Stop the Daemon and Force a Clean Run | ||
|
|
||
| **Step 1: Forcefully stop all running Gradle daemons.** | ||
| Forcefully stop all running Gradle daemons. | ||
codesungrape marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| This command tells Gradle to find any background processes it has running and terminate them. | ||
| ```Bash | ||
| ./gradlew --stop | ||
| ``` | ||
|
|
||
| **Step 2: Run a clean build.** | ||
| The clean task deletes the entire build directory. This removes any old, compiled artifacts and cached results, ensuring nothing stale is left over. We will combine it with the checkstyleMain task. | ||
| ```Bash | ||
| ./gradlew clean <checkstyleMain> | ||
codesungrape marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| ``` | ||
|
|
||
| ---------- | ||
|
|
||
| ## IntelliJ Setup | ||
|
|
||
| ### Enable Checkstyle in IntelliJ | ||
|
|
||
| 1. Install the **Checkstyle-IDEA** plugin | ||
|
|
||
| 2. Open IntelliJ settings: | ||
|
|
||
| `Settings → Tools → Checkstyle` | ||
|
|
||
| 3. Add the configuration file: | ||
|
|
||
| `config/checkstyle/checkstyle.xml` | ||
|
|
||
| 4. Set it as the default configuration | ||
|
|
||
| 5. (Optional) Enable “Scan before check-in” | ||
|
|
||
|
|
||
| ---------- | ||
|
|
||
| ### Enable EditorConfig support | ||
|
|
||
| Verify the following setting is enabled: | ||
|
|
||
| `Settings → Editor → Code Style → Enable EditorConfig support` | ||
|
|
||
| ---------- | ||
|
|
||
| ### Reformat code according to project rules | ||
|
|
||
| Use IntelliJ’s reformat command: | ||
|
|
||
| `Windows/Linux: Ctrl + Alt + L macOS: Cmd + Option + L` | ||
|
|
||
| ---------- | ||
|
|
||
| ## Summary | ||
|
|
||
| This project aligns with HMCTS engineering standards: | ||
|
|
||
| - HMCTS Checkstyle enforcement | ||
|
|
||
| - SpotBugs static analysis | ||
|
|
||
| - JaCoCo coverage reports | ||
|
|
||
| - HMCTS EditorConfig formatting | ||
|
|
||
| - Spotless removed (not used by HMCTS) | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.