Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove Travis CI and add GitHub workflows CI #167

Merged
merged 41 commits into from
Sep 16, 2022

Conversation

unfulvio-godaddy
Copy link
Member

@unfulvio-godaddy unfulvio-godaddy commented Sep 14, 2022

Description of the Change

Replace Travis with a new CI workflow using GitHub actions.
Having tests run again on each PR should give any contributor more confidence when opening a pull request.

I had to bump min php 7.3 to avoid issues with composer. We should version composer.lock after this.

Have also added an action that generates a coverage badge based on PHPUnit test coverage output. This is a static badge and not one dynamically generated with a third party service like Coveralls, CodeCov, etc. To use Coveralls as a GitHub action looks like we would need additional setup since lcov is not a coverage format that phpunit supports. Having a static badge should be good enough though, in the future we could have it automatically updated to README.md as part of a release bump.

How to test the Change

  • Tests should run on GitHub CI and pass.
  • Test coverage should be output in the same workflow
  • A badge will be appended and updated as GitHub comment with the current coverage %

This change is ignoring Behat at the moment. Need discussion to understand if we still need it or could limit test coverage to unit tests only. Behat could still be run by appending vendor/bin/behat right after phpunit in the corresponding action step.

Suggested list of follow up improvements:

  • Commit composer.lock to GitHub (currently ignored)
  • Set PHP standards to use and introduce PHPCS in workflow
  • Perhaps later we can also add PHPStan

Changelog Entry

  • Require PHP 7.3 (from 7.1)
  • Dropped travis.yml
  • Added .github/workflows/ci.yml
  • Tweaked phpunit.xml
  • Adds @covers tags to tests (now a requirement)
  • Updates .gitignore

@unfulvio-godaddy unfulvio-godaddy self-assigned this Sep 14, 2022
@unfulvio-godaddy unfulvio-godaddy requested a review from a team September 14, 2022 09:59
@unfulvio-godaddy unfulvio-godaddy marked this pull request as ready for review September 14, 2022 10:01
@unfulvio-godaddy unfulvio-godaddy changed the title Remove travis and add ci.yml Remove Travis CI and add GitHub workflows CI Sep 14, 2022
Copy link
Contributor

@agibson-godaddy agibson-godaddy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, just left a question.

composer.json Outdated
Comment on lines 26 to 27
"config": {
"platform-check": false
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why was this added?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sorry what I really meant was this: 82d4ec6
thanks for reminding me

Copy link
Contributor

@agibson-godaddy agibson-godaddy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Comment on lines +4 to +15
# OSX
**/.DS_Store

# IDEs
.project/
.settings/
.idea/
*.code-workspace
*.sublime-project
*.sublime-workspace
*.iml
.vscode/
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would argue that the repo should not contain development environment specific ignores. Contributors can/should set their own local global ignores.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you're definitely technically correct on that one. But with an open source repo that may have any number of contributors (including those that haven't configured their global ignore), maybe this just makes things easier?

Copy link
Member Author

@unfulvio-godaddy unfulvio-godaddy Sep 15, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes my thinking was the same as @agibson-godaddy -- I would prefer we maintain this as is, wouldn't bother anyone.

sudo update-alternatives --set phar /usr/bin/phar$PHP_VERSION
sudo update-alternatives --set phar.phar /usr/bin/phar.phar$PHP_VERSION
sudo update-alternatives --set phpize /usr/bin/phpize$PHP_VERSION
sudo update-alternatives --set php-config /usr/bin/php-config$PHP_VERSION
Copy link

@llessa-godaddy llessa-godaddy Sep 14, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we could use https://github.com/marketplace/actions/setup-php-action to make this setup cleaner, including the pcov piece below.

Copy link
Member Author

@unfulvio-godaddy unfulvio-godaddy Sep 15, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as discussed with @llessa-godaddy we don't need to refactor that now, however we added a code coverage badge which may be handy

@10up 10up deleted a comment from github-actions bot Sep 15, 2022
Copy link
Contributor

@nmolham-godaddy nmolham-godaddy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@github-actions
Copy link

Code Coverage

#- name: Upload coverage results to Coveralls
# if: ${{ env.PHP_VERSION == '8.1' }}
# run: |
# vendor/bin/php-coveralls --coverage_clover="./clover.xml" --json_path="./coveralls-upload.json" -v
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Coveralls won't work currently because it needs some envs set up - PHPUnit Code coverage and a badge output is currently working from this PR on the other hand

@unfulvio-godaddy unfulvio-godaddy merged commit a45bd3e into trunk Sep 16, 2022
@unfulvio-godaddy unfulvio-godaddy deleted the implement-new-ci-workflow branch September 16, 2022 01:38
agibson-godaddy added a commit that referenced this pull request Sep 16, 2022
### Description of the Change

It's advantageous that `composer.lock` is commited to the repository.
This introduces more consistency when dependencies are installed by
individuals for projects depending on WP_Mock.

If someone wants to learn more about why this is important (if you have
a better article, please post in comment!):

*
https://www.amitmerchant.com/why-you-should-always-commit-the-composer-lock-file/
*
https://www.codementor.io/@decodeweb/importance-of-composer-lock-in-git-14v9ujxn9z
* https://m.dotdev.co/why-the-composer-lock-file-matters-c8d1e1488be7

One notable update since #167 is maybe bumping PhpUnit to the `^9.5`
constraint -- however the previous constraint `>=7.0` made it so that
`9.5.x` could have been installed too.

I've also removed `sebastian/comparator` from dev dependencies. Not sure
what this is used for since I couldn't find any reference to it. Maybe
it was required in older phpunit versions?

As for `behat` and `php-coveralls` we might still use those later on.

Closes #153

### How to test the Change

- [x] Review composer.json and composer.lock changes
- [x] Unit tests pass

### Changelog Entry

- `composer.lock` is commited to git

### Checklist:
- [x] I agree to follow this project's [**Code of
Conduct**](https://github.com/10up/.github/blob/trunk/CODE_OF_CONDUCT.md).
- [ ] I have updated the documentation accordingly. _n/a_
- [ ] I have added tests to cover my change. _n/a_
- [x] All new and existing tests pass.
@jeffpaul jeffpaul added this to the 0.5.0 milestone Sep 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants