Skip to content

Commit a073e77

Browse files
NIAD-3349: Add CheckStyle to GitHub Actions (#300)
* NIAD-3349: Add Checkstyle to GitHub Actions * Update `test.yml` to include CheckStyle tests for `main` `intTest`, `test` and `recepResponder` * * Fix issue with the artifact path * Escaping whitespace in text block for test where the whitespace is intentional * * Remove recepResponder checks from CheckStyle.
1 parent 6ca346e commit a073e77

File tree

2 files changed

+46
-8
lines changed

2 files changed

+46
-8
lines changed

.github/workflows/test.yml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,45 @@ on:
33
workflow_call:
44

55
jobs:
6+
checkstyle:
7+
name: Checkstyle
8+
runs-on: ubuntu-latest
9+
steps:
10+
- name: Checkout Repository
11+
uses: actions/checkout@v4
12+
13+
- name: Setup Java 21 LTS
14+
uses: actions/setup-java@v4
15+
with:
16+
java-version: 21
17+
distribution: 'temurin'
18+
19+
- name: Setup Gradle
20+
uses: gradle/actions/setup-gradle@v4
21+
22+
- name: Checkstyle
23+
run: ./gradlew checkStyleMain checkstyleTest checkstyleIntTest
24+
25+
- name: Collect Artifacts
26+
if: always()
27+
run: |
28+
mkdir -p artifacts
29+
cp -r ./build/reports ./artifacts
30+
31+
- name: Upload Artifacts
32+
uses: actions/upload-artifact@v4
33+
if: always()
34+
with:
35+
name: 'Checkstyle Reports'
36+
path: ./artifacts/**
37+
compression-level: 9
38+
39+
- name: Temporary Artifacts Cleanup
40+
run: rm -rf ./artifacts
41+
642
unit-tests:
743
name: Unit Tests
44+
needs: [ checkstyle ]
845
runs-on: ubuntu-latest
946
steps:
1047
- name: Checkout Repository
@@ -44,6 +81,7 @@ jobs:
4481

4582
component-tests:
4683
name: Component Tests
84+
needs: [ checkstyle ]
4785
runs-on: ubuntu-latest
4886
steps:
4987
- name: Checkout Repository
@@ -83,6 +121,7 @@ jobs:
83121

84122
integration_tests:
85123
name: Integration Tests
124+
needs: [ checkstyle ]
86125
permissions:
87126
contents: read
88127
runs-on: ubuntu-latest

src/test/java/uk/nhs/digital/nhsconnect/nhais/utils/PemFormatterTest.java

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,16 @@ public class PemFormatterTest {
99
@Test
1010
public void When_CertHasExtraWhitespace_Expect_ItIsTrimmed() {
1111

12-
// this warning is suppressed as the extra whitespace (including trailing whitespace) is intentional
13-
@SuppressWarnings("com.puppycrawl.tools.checkstyle.checks.regexp.RegexpSingleLineCheck")
12+
//The extra whitespace (including trailing whitespace) is intentional for this test and has been suppressed with `\s`
1413
final String withWhitespace = """
1514
-----BEGIN CERTIFICATE-----
16-
MIIFXzCCA0egAwIBAgIJALRbCSor9bEbMA0GCSqGSIb3DQEBCwUAMEUxCzAJBgNV
17-
18-
15+
MIIFXzCCA0egAwIBAgIJALRbCSor9bEbMA0GCSqGSIb3DQEBCwUAMEUxCzAJBgNV \s
16+
\s
17+
\s
1918
W/JNIRmhLoeFNGNh8HvhI2PwOCsFiqT1rrCaUtusTyH0Ggs=
20-
21-
-----END CERTIFICATE-----
22-
""";
19+
\s
20+
-----END CERTIFICATE----- \s
21+
\s""";
2322

2423
final String trimmed = """
2524
-----BEGIN CERTIFICATE-----

0 commit comments

Comments
 (0)