diff --git a/.github/workflows/master-2.yml b/.github/workflows/master-2.yml index dd38f92f..b94ab7f3 100644 --- a/.github/workflows/master-2.yml +++ b/.github/workflows/master-2.yml @@ -10,7 +10,6 @@ jobs: build-scan: name: SonarCloud Scan runs-on: ubuntu-latest - if: "! contains(toJSON(github.event.commits.*.message), '[skip ci]')" steps: - uses: actions/checkout@v4 @@ -25,6 +24,9 @@ jobs: cache: maven - name: Build/Test & SonarCloud Scan + env: + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} + if: env.SONAR_TOKEN != '' run: mvn -B clean verify -Pcoverage,sonar -Dsonar.token=${{ secrets.SONAR_TOKEN }} build-test: @@ -35,7 +37,6 @@ jobs: java: ['11', '17', '21'] os: [ubuntu-latest, windows-latest] runs-on: ${{ matrix.os }} - if: "! contains(toJSON(github.event.commits.*.message), '[skip ci]')" steps: - uses: actions/checkout@v4 diff --git a/.github/workflows/master.yml b/.github/workflows/master.yml index 926b22ec..c8000c74 100644 --- a/.github/workflows/master.yml +++ b/.github/workflows/master.yml @@ -10,7 +10,6 @@ jobs: build-scan: name: SonarCloud Scan runs-on: ubuntu-latest - if: "! contains(toJSON(github.event.commits.*.message), '[skip ci]')" steps: - uses: actions/checkout@v4 @@ -25,6 +24,9 @@ jobs: cache: maven - name: Build/Test & SonarCloud Scan + env: + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} + if: env.SONAR_TOKEN != '' run: mvn -B clean verify -Pcoverage,sonar -Dsonar.token=${{ secrets.SONAR_TOKEN }} build-test: @@ -35,7 +37,6 @@ jobs: java: ['8', '11', '17', '21'] os: [ubuntu-latest, windows-latest] runs-on: ${{ matrix.os }} - if: "! contains(toJSON(github.event.commits.*.message), '[skip ci]')" steps: - uses: actions/checkout@v4 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 7a892d8e..0ee87e7d 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -13,7 +13,6 @@ jobs: java: ['11', '17', '21'] os: [ubuntu-latest, windows-latest] runs-on: ${{ matrix.os }} - if: "! contains(toJSON(github.event.commits.*.message), '[skip ci]')" steps: - uses: actions/checkout@v4 diff --git a/.github/workflows/sonar.yml b/.github/workflows/sonar.yml new file mode 100644 index 00000000..db54d6ec --- /dev/null +++ b/.github/workflows/sonar.yml @@ -0,0 +1,52 @@ +name: Manual SonarCloud Analysis + +on: + workflow_dispatch: + inputs: + pr_id: + description: 'Pull Request ID to analyze' + required: true + type: string + +jobs: + sonar-analysis: + name: SonarCloud Analysis for PR + runs-on: ubuntu-latest + + steps: + - name: Get PR details + id: pr + uses: actions/github-script@v7 + with: + script: | + const pr = await github.rest.pulls.get({ + owner: context.repo.owner, + repo: context.repo.repo, + pull_number: ${{ inputs.pr_id }} + }); + core.setOutput('head_ref', pr.data.head.ref); + core.setOutput('base_ref', pr.data.base.ref); + core.setOutput('head_sha', pr.data.head.sha); + + - uses: actions/checkout@v4 + with: + ref: ${{ steps.pr.outputs.head_sha }} + fetch-depth: 0 + + - name: Set up JDK 17 + uses: actions/setup-java@v4 + with: + java-version: 17 + distribution: 'temurin' + cache: maven + + - name: Build/Test & SonarCloud Scan + env: + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} + if: env.SONAR_TOKEN != '' + run: | + mvn -B clean verify -Pcoverage,sonar \ + -Dsonar.token=${{ secrets.SONAR_TOKEN }} \ + -Dsonar.pullrequest.key=${{ inputs.pr_id }} \ + -Dsonar.pullrequest.branch=${{ steps.pr.outputs.head_ref }} \ + -Dsonar.pullrequest.base=${{ steps.pr.outputs.base_ref }} \ No newline at end of file diff --git a/src/main/java/com/github/switcherapi/client/service/validators/DateTimeValidator.java b/src/main/java/com/github/switcherapi/client/service/validators/DateTimeValidator.java index 613f40b0..4c9af227 100644 --- a/src/main/java/com/github/switcherapi/client/service/validators/DateTimeValidator.java +++ b/src/main/java/com/github/switcherapi/client/service/validators/DateTimeValidator.java @@ -19,7 +19,7 @@ public abstract class DateTimeValidator extends Validator { protected String getFullDate(final String date) { SwitcherUtils.debug(logger, LOG_DATE, date); - final String time = RegExUtils.removePattern(date, FULL_DATE_REGEX).trim(); + final String time = RegExUtils.removePattern((CharSequence) date, FULL_DATE_REGEX).trim(); return getFullTime(date, time); } diff --git a/src/test/java/com/github/switcherapi/client/SwitcherBasicCriteriaResponseTest.java b/src/test/java/com/github/switcherapi/client/SwitcherBasicCriteriaResponseTest.java index 875ceafe..3b0dd791 100644 --- a/src/test/java/com/github/switcherapi/client/SwitcherBasicCriteriaResponseTest.java +++ b/src/test/java/com/github/switcherapi/client/SwitcherBasicCriteriaResponseTest.java @@ -37,7 +37,7 @@ static void setup() throws IOException { } @AfterAll - static void tearDown() throws IOException { + static void tearDown() { MockWebServerHelper.tearDownMockServer(); } diff --git a/src/test/java/com/github/switcherapi/client/SwitcherBasicTest.java b/src/test/java/com/github/switcherapi/client/SwitcherBasicTest.java index 5a57c12f..e17fe72b 100644 --- a/src/test/java/com/github/switcherapi/client/SwitcherBasicTest.java +++ b/src/test/java/com/github/switcherapi/client/SwitcherBasicTest.java @@ -35,7 +35,7 @@ static void setup() throws IOException { } @AfterAll - static void tearDown() throws IOException { + static void tearDown() { MockWebServerHelper.tearDownMockServer(); } diff --git a/src/test/java/com/github/switcherapi/client/SwitcherConfigNativeTest.java b/src/test/java/com/github/switcherapi/client/SwitcherConfigNativeTest.java index aa05535a..3d80e6ba 100644 --- a/src/test/java/com/github/switcherapi/client/SwitcherConfigNativeTest.java +++ b/src/test/java/com/github/switcherapi/client/SwitcherConfigNativeTest.java @@ -20,7 +20,7 @@ static void setup() throws IOException { } @AfterAll - static void tearDown() throws IOException { + static void tearDown() { MockWebServerHelper.tearDownMockServer(); } diff --git a/src/test/java/com/github/switcherapi/client/SwitcherContextRemoteExecutorTest.java b/src/test/java/com/github/switcherapi/client/SwitcherContextRemoteExecutorTest.java index 0763c8b0..681414d9 100644 --- a/src/test/java/com/github/switcherapi/client/SwitcherContextRemoteExecutorTest.java +++ b/src/test/java/com/github/switcherapi/client/SwitcherContextRemoteExecutorTest.java @@ -22,7 +22,7 @@ static void setup() throws IOException { } @AfterAll - static void tearDown() throws IOException { + static void tearDown() { MockWebServerHelper.tearDownMockServer(); } diff --git a/src/test/java/com/github/switcherapi/client/SwitcherFail1Test.java b/src/test/java/com/github/switcherapi/client/SwitcherFail1Test.java index 4deabe53..ac20d9b8 100644 --- a/src/test/java/com/github/switcherapi/client/SwitcherFail1Test.java +++ b/src/test/java/com/github/switcherapi/client/SwitcherFail1Test.java @@ -28,7 +28,7 @@ static void setup() throws IOException { } @AfterAll - static void tearDown() throws IOException { + static void tearDown() { MockWebServerHelper.tearDownMockServer(); //clean generated outputs diff --git a/src/test/java/com/github/switcherapi/client/SwitcherFail2Test.java b/src/test/java/com/github/switcherapi/client/SwitcherFail2Test.java index d9cce345..1c10e56c 100644 --- a/src/test/java/com/github/switcherapi/client/SwitcherFail2Test.java +++ b/src/test/java/com/github/switcherapi/client/SwitcherFail2Test.java @@ -28,7 +28,7 @@ static void setup() throws IOException { } @AfterAll - static void tearDown() throws IOException { + static void tearDown() { MockWebServerHelper.tearDownMockServer(); } diff --git a/src/test/java/com/github/switcherapi/client/SwitcherForceResolveTest.java b/src/test/java/com/github/switcherapi/client/SwitcherForceResolveTest.java index 7dfb2f13..ca5907bf 100644 --- a/src/test/java/com/github/switcherapi/client/SwitcherForceResolveTest.java +++ b/src/test/java/com/github/switcherapi/client/SwitcherForceResolveTest.java @@ -35,7 +35,7 @@ static void setup() throws IOException { } @AfterAll - static void tearDown() throws IOException { + static void tearDown() { MockWebServerHelper.tearDownMockServer(); } diff --git a/src/test/java/com/github/switcherapi/client/SwitcherSilentModeTest.java b/src/test/java/com/github/switcherapi/client/SwitcherSilentModeTest.java index 39c1ae7e..930956fb 100644 --- a/src/test/java/com/github/switcherapi/client/SwitcherSilentModeTest.java +++ b/src/test/java/com/github/switcherapi/client/SwitcherSilentModeTest.java @@ -29,7 +29,7 @@ static void setup() throws IOException { } @AfterAll - static void tearDown() throws IOException { + static void tearDown() { MockWebServerHelper.tearDownMockServer(); } diff --git a/src/test/java/com/github/switcherapi/client/SwitcherSnapshotValidationFailTest.java b/src/test/java/com/github/switcherapi/client/SwitcherSnapshotValidationFailTest.java index 7a75148c..eeb6a45f 100644 --- a/src/test/java/com/github/switcherapi/client/SwitcherSnapshotValidationFailTest.java +++ b/src/test/java/com/github/switcherapi/client/SwitcherSnapshotValidationFailTest.java @@ -31,7 +31,7 @@ static void setup() throws IOException { } @AfterAll - static void tearDown() throws IOException { + static void tearDown() { MockWebServerHelper.tearDownMockServer(); //clean generated outputs diff --git a/src/test/java/com/github/switcherapi/client/SwitcherSnapshotValidationTest.java b/src/test/java/com/github/switcherapi/client/SwitcherSnapshotValidationTest.java index 01014688..e86a6bdc 100644 --- a/src/test/java/com/github/switcherapi/client/SwitcherSnapshotValidationTest.java +++ b/src/test/java/com/github/switcherapi/client/SwitcherSnapshotValidationTest.java @@ -28,7 +28,7 @@ static void setup() throws IOException { } @AfterAll - static void tearDown() throws IOException { + static void tearDown() { MockWebServerHelper.tearDownMockServer(); //clean generated outputs diff --git a/src/test/java/com/github/switcherapi/client/SwitcherThrottleTest.java b/src/test/java/com/github/switcherapi/client/SwitcherThrottleTest.java index 19aca2e5..04da78cc 100644 --- a/src/test/java/com/github/switcherapi/client/SwitcherThrottleTest.java +++ b/src/test/java/com/github/switcherapi/client/SwitcherThrottleTest.java @@ -26,7 +26,7 @@ static void setup() throws IOException { } @AfterAll - static void tearDown() throws IOException { + static void tearDown() { MockWebServerHelper.tearDownMockServer(); } diff --git a/src/test/java/com/github/switcherapi/client/SwitcherValidateTest.java b/src/test/java/com/github/switcherapi/client/SwitcherValidateTest.java index c5910c58..9e1d648b 100644 --- a/src/test/java/com/github/switcherapi/client/SwitcherValidateTest.java +++ b/src/test/java/com/github/switcherapi/client/SwitcherValidateTest.java @@ -27,7 +27,7 @@ static void setup() throws IOException { } @AfterAll - static void tearDown() throws IOException { + static void tearDown() { MockWebServerHelper.tearDownMockServer(); //clean generated outputs diff --git a/src/test/java/com/github/switcherapi/client/remote/ClientRemoteTest.java b/src/test/java/com/github/switcherapi/client/remote/ClientRemoteTest.java index 66bad3eb..f7e15df0 100644 --- a/src/test/java/com/github/switcherapi/client/remote/ClientRemoteTest.java +++ b/src/test/java/com/github/switcherapi/client/remote/ClientRemoteTest.java @@ -50,7 +50,7 @@ static void setup() throws IOException { } @AfterAll - static void tearDown() throws IOException { + static void tearDown() { MockWebServerHelper.tearDownMockServer(); executorService.shutdown(); } diff --git a/src/test/java/com/github/switcherapi/client/remote/ClientWSTest.java b/src/test/java/com/github/switcherapi/client/remote/ClientWSTest.java index 853b2a61..58707f9f 100644 --- a/src/test/java/com/github/switcherapi/client/remote/ClientWSTest.java +++ b/src/test/java/com/github/switcherapi/client/remote/ClientWSTest.java @@ -32,7 +32,7 @@ static void setup() throws IOException { } @AfterAll - static void tearDown() throws IOException { + static void tearDown() { MockWebServerHelper.tearDownMockServer(); executorService.shutdown(); }