From bc8f0537bc0f43ad0420e6b78d50a30784810f21 Mon Sep 17 00:00:00 2001 From: Christopher McLaughlin Date: Sat, 19 Mar 2022 21:44:21 +0000 Subject: [PATCH 1/2] sonarqube testing --- .github/workflows/build.yml | 21 +++++++++++++++++++++ api/src/Average.php | 2 ++ core/src/Average.php | 2 ++ sonar-project.properties | 1 + 4 files changed, 26 insertions(+) create mode 100644 .github/workflows/build.yml create mode 100644 sonar-project.properties diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..6a568d4 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,21 @@ +name: Build +on: + push: + branches: + - main # or the name of your main branch +jobs: + build: + name: Build + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + with: + fetch-depth: 0 + - uses: sonarsource/sonarqube-scan-action@master + env: + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} + SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }} + - uses: sonarsource/sonarqube-quality-gate-action@master + timeout-minutes: 5 + env: + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} \ No newline at end of file diff --git a/api/src/Average.php b/api/src/Average.php index c887adf..b49a632 100644 --- a/api/src/Average.php +++ b/api/src/Average.php @@ -19,7 +19,9 @@ public function mean(array $numbers) { */ public function median(array $numbers) { sort($numbers); + $size = count($numbers); + if ($size % 2) { return $numbers[$size / 2]; } else { diff --git a/core/src/Average.php b/core/src/Average.php index 862bf04..6494dfa 100644 --- a/core/src/Average.php +++ b/core/src/Average.php @@ -19,7 +19,9 @@ public function mean(array $numbers) { */ public function median(array $numbers) { sort($numbers); + $size = count($numbers); + if ($size % 2) { return $numbers[$size / 2]; } else { diff --git a/sonar-project.properties b/sonar-project.properties new file mode 100644 index 0000000..5ecb89f --- /dev/null +++ b/sonar-project.properties @@ -0,0 +1 @@ +sonar.projectKey=Github-Actions-Test \ No newline at end of file From a04bb817a5bfc0bf6e6dc91f53ed51f2d362bb21 Mon Sep 17 00:00:00 2001 From: Christopher McLaughlin Date: Sat, 19 Mar 2022 21:46:11 +0000 Subject: [PATCH 2/2] sonarqube testing --- .github/workflows/build.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 6a568d4..94479a3 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,5 +1,7 @@ name: Build on: + pull_request: + types: [opened, synchronize, reopened] push: branches: - main # or the name of your main branch