diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6ee4b54..650248d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -5,7 +5,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v4 - name: Set up php 8.1 uses: shivammathur/setup-php@v2 with: @@ -15,4 +15,6 @@ jobs: - name: Run tests and collect coverage run: vendor/bin/phpunit --coverage-clover coverage.xml . - name: Upload coverage to Codecov - uses: codecov/codecov-action@v3 + uses: codecov/codecov-action@v5 + env: + CODECOV_TOKEN: ${{ secrets.CODECOV_ORG_TOKEN }} diff --git a/.github/workflows/enforce-license-compliance.yml b/.github/workflows/enforce-license-compliance.yml new file mode 100644 index 0000000..86be741 --- /dev/null +++ b/.github/workflows/enforce-license-compliance.yml @@ -0,0 +1,14 @@ +name: Enforce License Compliance + +on: + pull_request: + branches: [main, master] + +jobs: + enforce-license-compliance: + runs-on: ubuntu-latest + steps: + - name: 'Enforce License Compliance' + uses: getsentry/action-enforce-license-compliance@57ba820387a1a9315a46115ee276b2968da51f3d # main + with: + fossa_api_key: ${{ secrets.FOSSA_API_KEY }} diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 023b52d..0000000 --- a/.travis.yml +++ /dev/null @@ -1,16 +0,0 @@ -language: php - -php: - - 7.2 - - 7.3 - - 7.4 - -before_script: - - travis_retry composer self-update - - travis_retry composer install --no-interaction --prefer-source --dev - -script: - - vendor/bin/phpunit --coverage-clover coverage.xml - -after_success: - - bash <(curl -s https://codecov.io/bash) diff --git a/LICENSE.md b/LICENSE.md new file mode 100644 index 0000000..c341b2a --- /dev/null +++ b/LICENSE.md @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2022 Codecov + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/README.md b/README.md index 0892ba8..b91974c 100644 --- a/README.md +++ b/README.md @@ -1,46 +1,18 @@ # [Codecov](https://codecov.io) PHP Example +[![codecov](https://codecov.io/github/codecov/example-php/branch/main/graph/badge.svg?token=A7Mb0qlkNW)](https://app.codecov.io/github/codecov/example-php) [![FOSSA Status](https://app.fossa.com/api/projects/git%2Bgithub.com%2Fcodecov%2Fexample-php.svg?type=shield)](https://app.fossa.com/projects/git%2Bgithub.com%2Fcodecov%2Fexample-php?ref=badge_shield) +This example repository shows how Codecov can be integrated with a simple php project. It uses **GitHub Actions** as the CI/CD provider and **phpunit** as the coverage provider. -## Guide - -### Travis Setup - -Add to your `.travis.yml` file. -```yml -language: php - -script: - - vendor/bin/phpunit --coverage-clover coverage.xml - -after_success: - - bash <(curl -s https://codecov.io/bash) -``` - -### Produce Coverage Reports -Collect coverage reports `vendor/bin/phpunit --coverage-clover coverage.xml`, [see here](https://github.com/codecov/example-php/blob/master/.travis.yml#L15) - -### FAQ -- Q: Can I use phpunit.xml.dist?
A: Start tracking coverage metrics by adding a coverage logger: - ```xml - - ... - - - - -``` -- Q: I don't see one or more files, why?
A: Codecov will only show files that have lines covered (hit or miss). If your file has no statments it will not show up in Codecov until you add some. Go get em' tiger! - -## Caveats -### Private Repo -Repository tokens are required for (a) all private repos, (b) public repos not using Travis-CI, CircleCI or AppVeyor. Find your repository token at Codecov and provide via appending `-t ` to you where you upload reports. +For more information, please see the links below. ## Links +- [Quick Start](https://docs.codecov.com/docs/quick-start) +- [GitHub Tutorial](https://docs.codecov.com/docs/github-tutorial) - [Community Boards](https://community.codecov.io) - [Support](https://codecov.io/support) - [Documentation](https://docs.codecov.io) ## License -[![FOSSA Status](https://app.fossa.com/api/projects/git%2Bgithub.com%2Fcodecov%2Fexample-php.svg?type=large)](https://app.fossa.com/projects/git%2Bgithub.com%2Fcodecov%2Fexample-php?ref=badge_large) \ No newline at end of file +[![FOSSA Status](https://app.fossa.com/api/projects/git%2Bgithub.com%2Fcodecov%2Fexample-php.svg?type=large)](https://app.fossa.com/projects/git%2Bgithub.com%2Fcodecov%2Fexample-php?ref=badge_large) diff --git a/tests/calculatorTest.php b/tests/calculatorTest.php index 3c41ed4..9713e02 100644 --- a/tests/calculatorTest.php +++ b/tests/calculatorTest.php @@ -10,11 +10,11 @@ class calculatorTest extends PHPUnit\Framework\TestCase */ public function testAdd() { - $this->assertEquals(BasicCalculator::add(1, 2), 3.0); - $this->assertEquals(BasicCalculator::add(1.0, 2.0), 3.0); - $this->assertEquals(BasicCalculator::add(0, 2.0), 2.0); - $this->assertEquals(BasicCalculator::add(2.0, 0), 2.0); - $this->assertEquals(BasicCalculator::add(-4, 2.0), -2.0); + $this->assertEquals(3.0, BasicCalculator::add(1, 2)); + $this->assertEquals(3.0, BasicCalculator::add(1.0, 2.0)); + $this->assertEquals(2.0, BasicCalculator::add(0, 2.0)); + $this->assertEquals(2.0, BasicCalculator::add(2.0, 0)); + $this->assertEquals(-2.0, BasicCalculator::add(-4, 2.0)); } /** @@ -22,12 +22,12 @@ public function testAdd() */ public function testSubtract() { - $this->assertEquals(BasicCalculator::subtract(1, 2), -1.0); - $this->assertEquals(BasicCalculator::subtract(2, 1), 1.0); - $this->assertEquals(BasicCalculator::subtract(1.0, 2.0), -1.0); - $this->assertEquals(BasicCalculator::subtract(0, 2.0), -2.0); - $this->assertEquals(BasicCalculator::subtract(2.0, 0), 2.0); - $this->assertEquals(BasicCalculator::subtract(-4, 2.0), -6.0); + $this->assertEquals(-1.0, BasicCalculator::subtract(1, 2)); + $this->assertEquals(1.0, BasicCalculator::subtract(2, 1)); + $this->assertEquals(-1.0, BasicCalculator::subtract(1.0, 2.0)); + $this->assertEquals(-2.0, BasicCalculator::subtract(0, 2.0)); + $this->assertEquals(2.0, BasicCalculator::subtract(2.0, 0)); + $this->assertEquals(-6.0, BasicCalculator::subtract(-4, 2.0)); } /** @@ -35,11 +35,11 @@ public function testSubtract() */ public function testMultiply() { - $this->assertEquals(BasicCalculator::multiply(1, 2), 2.0); - $this->assertEquals(BasicCalculator::multiply(1.0, 2.0), 2.0); - $this->assertEquals(BasicCalculator::multiply(0, 2.0), 0.0); - $this->assertEquals(BasicCalculator::multiply(2.0, 0), 0.0); - $this->assertEquals(BasicCalculator::multiply(-4, 2.0), -8.0); + $this->assertEquals(2.0, BasicCalculator::multiply(1, 2)); + $this->assertEquals(2.0, BasicCalculator::multiply(1.0, 2.0)); + $this->assertEquals(0.0, BasicCalculator::multiply(0, 2.0)); + $this->assertEquals(0.0, BasicCalculator::multiply(2.0, 0)); + $this->assertEquals(-8.0, BasicCalculator::multiply(-4, 2.0)); } /** @@ -47,10 +47,10 @@ public function testMultiply() */ public function testDivide() { - $this->assertEquals(BasicCalculator::divide(1, 2), 0.5); - $this->assertEquals(BasicCalculator::divide(1.0, 2.0), 0.5); - $this->assertEquals(BasicCalculator::divide(0, 2.0), 0.0); - $this->assertEquals(BasicCalculator::divide(-4, 2.0), -2.0); - // $this->assertEquals(BasicCalculator::divide(2.0, 0), 'Cannot divide by 0'); + $this->assertEquals(0.5, BasicCalculator::divide(1, 2)); + $this->assertEquals(0.5, BasicCalculator::divide(1.0, 2.0)); + $this->assertEquals(0.0, BasicCalculator::divide(0, 2.0)); + $this->assertEquals(-2.0, BasicCalculator::divide(-4, 2.0)); + // $this->assertEquals('Cannot divide by 0', BasicCalculator::divide(2.0, 0)); } }