diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..94479a3 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,23 @@ +name: Build +on: + pull_request: + types: [opened, synchronize, reopened] + 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