From 304664a4273856ed38836c0c3f4cb46d51759769 Mon Sep 17 00:00:00 2001 From: Leszek Manicki Date: Mon, 9 Dec 2024 22:03:50 +0100 Subject: [PATCH 1/5] Added github actions workflow to lint and test code on push --- .gitattributes | 1 + .github/workflows/lint-and-test.yaml | 28 ++++++++++++++++++++++++++++ 2 files changed, 29 insertions(+) create mode 100644 .github/workflows/lint-and-test.yaml diff --git a/.gitattributes b/.gitattributes index e8ad548..c6bcc52 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,4 +1,5 @@ .gitattributes export-ignore +.github/ export-ignore .gitignore export-ignore .scrutinizer.yml export-ignore .travis.yml export-ignore diff --git a/.github/workflows/lint-and-test.yaml b/.github/workflows/lint-and-test.yaml new file mode 100644 index 0000000..92f46ca --- /dev/null +++ b/.github/workflows/lint-and-test.yaml @@ -0,0 +1,28 @@ +name: Lint and Test +on: push +permissions: + contents: read +jobs: + build: + runs-on: ubuntu-latest + strategy: + matrix: + php_version: [ '7.4', '8.0' ] + steps: + - uses: actions/checkout@v4 + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php_version }} + - name: Validate composer.json and composer.lock + run: composer validate --strict + - name: Cache Composer packages + id: composer-cache + uses: actions/cache@v3 + with: + path: vendor + key: ${{ runner.os }}-php-${{ matrix.php_version}}-${{ hashFiles('**/composer.lock') }} + - name: Install dependencies + run: composer install --prefer-source --no-progress + - name: Run test suite + run: composer test From cb9d5e76d39216c3fe2628c84fdcfa54fc95301a Mon Sep 17 00:00:00 2001 From: Leszek Manicki Date: Mon, 9 Dec 2024 22:27:50 +0100 Subject: [PATCH 2/5] Send emails on failures of the CI lint and test workflow --- .github/workflows/ci_failure_email.md.tmpl | 3 +++ .github/workflows/lint-and-test.yaml | 22 ++++++++++++++++++++++ 2 files changed, 25 insertions(+) create mode 100644 .github/workflows/ci_failure_email.md.tmpl diff --git a/.github/workflows/ci_failure_email.md.tmpl b/.github/workflows/ci_failure_email.md.tmpl new file mode 100644 index 0000000..322186b --- /dev/null +++ b/.github/workflows/ci_failure_email.md.tmpl @@ -0,0 +1,3 @@ +CI workflow ${WORKFLOW} failed! + +The failed job can be found in [here](${SERVER_URL}/${REPOSITORY}/actions/runs/${RUN_ID}). diff --git a/.github/workflows/lint-and-test.yaml b/.github/workflows/lint-and-test.yaml index 92f46ca..2350ac8 100644 --- a/.github/workflows/lint-and-test.yaml +++ b/.github/workflows/lint-and-test.yaml @@ -14,6 +14,15 @@ jobs: uses: shivammathur/setup-php@v2 with: php-version: ${{ matrix.php_version }} + - uses: nowactions/envsubst@v1 + with: + input: ${{ github.workspace }}/.github/workflows/ci_failure_email.md.tmpl + output: ${{ github.workspace }}/.github/workflows/ci_failure_email.md + env: + WORKFLOW: ${{ github.workflow }} + SERVER_URL: ${{ github.server_url }} + REPOSITORY: ${{ github.repository }} + RUN_ID: ${{ github.run_id }} - name: Validate composer.json and composer.lock run: composer validate --strict - name: Cache Composer packages @@ -26,3 +35,16 @@ jobs: run: composer install --prefer-source --no-progress - name: Run test suite run: composer test + - name: Send mail on failure + if: ${{ failure() }} + uses: dawidd6/action-send-mail@v3 + with: + server_address: smtp.gmail.com + server_port: 465 + username: ${{secrets.CI_MAIL_USERNAME}} + password: ${{secrets.CI_MAIL_PASSWORD}} + to: wikidata-ci-status@wikimedia.de + from: ${{ github.repository }} CI + subject: CI job failed for ${{ github.repository }} + convert_markdown: true + html_body: file://${{ github.workspace }}/.github/workflows/ci_failure_email.md From 5021b13d5efc4fd43ca5f5a0a327432b8b0349b2 Mon Sep 17 00:00:00 2001 From: Leszek Manicki Date: Mon, 9 Dec 2024 22:30:50 +0100 Subject: [PATCH 3/5] Added github CI workflow that upload test coverage to Scrutinizer service --- .github/workflows/scrutinize.yaml | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 .github/workflows/scrutinize.yaml diff --git a/.github/workflows/scrutinize.yaml b/.github/workflows/scrutinize.yaml new file mode 100644 index 0000000..bd9f68e --- /dev/null +++ b/.github/workflows/scrutinize.yaml @@ -0,0 +1,31 @@ +name: Generate and upload test coverage +on: + workflow_run: + workflows: ['Lint and Test'] + types: + - completed + +jobs: + scrutinize: + runs-on: ubuntu-latest + if: ${{ github.event.workflow_run.conclusion == 'success' }} + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 2 + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: '8.0' + coverage: xdebug + - name: Cache Composer packages + uses: actions/cache@v4 + with: + path: vendor + key: ${{ runner.os }}-${{ hashFiles('**/composer.lock') }} + - name: Generate PHP tests coverage + run: vendor/bin/phpunit --coverage-clover coverage.clover + - name: Upload Scrutinizer coverage + uses: sudo-bot/action-scrutinizer@latest + with: + cli-args: "--repository g/wmde/Number --format=php-clover ./coverage.clover" From ad3899e8107fe7f5e9c38516303db11ab49ef674 Mon Sep 17 00:00:00 2001 From: Leszek Manicki Date: Mon, 9 Dec 2024 22:37:16 +0100 Subject: [PATCH 4/5] Replace Travis CI with github action builds --- .gitattributes | 1 - .travis.yml | 23 ----------------------- README.md | 2 +- 3 files changed, 1 insertion(+), 25 deletions(-) delete mode 100644 .travis.yml diff --git a/.gitattributes b/.gitattributes index c6bcc52..3390408 100644 --- a/.gitattributes +++ b/.gitattributes @@ -2,7 +2,6 @@ .github/ export-ignore .gitignore export-ignore .scrutinizer.yml export-ignore -.travis.yml export-ignore composer.json export-ignore phpcs.xml export-ignore phpunit.xml.dist export-ignore diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index fcb2b0e..0000000 --- a/.travis.yml +++ /dev/null @@ -1,23 +0,0 @@ -language: php - -dist: bionic - -php: - - 7.4 - - 8.0 - -install: travis_retry composer install - -script: - - composer test - -after_success: - - if [[ "`phpenv version-name`" != "8.0" ]]; then exit 0; fi - - vendor/bin/phpunit --coverage-clover coverage.clover - - wget https://scrutinizer-ci.com/ocular.phar - - php ocular.phar code-coverage:upload --format=php-clover coverage.clover - - -cache: - directories: - - $HOME/.composer/cache diff --git a/README.md b/README.md index ad40c33..e7bb0e6 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ into such value objects, and formatters to turn them back into user consumable r It is part of the [DataValues set of libraries](https://github.com/DataValues). -[![Build Status](https://secure.travis-ci.org/wmde/Number.png?branch=master)](http://travis-ci.org/wmde/Number) +[![Build Status](https://github.com/wmde/Number/actions/workflows/lint-and-test.yaml/badge.svg?branch=master)](https://github.com/wmde/Number/actions/workflows/lint-and-test.yaml) [![Code Coverage](https://scrutinizer-ci.com/g/wmde/Number/badges/coverage.png?s=a62dd85d05eaf0c5505deed4e2bd53d34e50d158)](https://scrutinizer-ci.com/g/wmde/Number/) [![Scrutinizer Quality Score](https://scrutinizer-ci.com/g/wmde/Number/badges/quality-score.png?s=03279530fa55439de3ce094b985f861959ee7162)](https://scrutinizer-ci.com/g/wmde/Number/) From 96ec181871602f899337d3ba9cf2c7eff721a527 Mon Sep 17 00:00:00 2001 From: Leszek Manicki Date: Mon, 9 Dec 2024 22:41:55 +0100 Subject: [PATCH 5/5] Test on all actively supported PHP versions --- .github/workflows/lint-and-test.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/lint-and-test.yaml b/.github/workflows/lint-and-test.yaml index 2350ac8..99dece1 100644 --- a/.github/workflows/lint-and-test.yaml +++ b/.github/workflows/lint-and-test.yaml @@ -7,7 +7,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - php_version: [ '7.4', '8.0' ] + php_version: [ '7.4', '8.0', '8.1', '8.2', '8.3', '8.4' ] steps: - uses: actions/checkout@v4 - name: Setup PHP