-
Notifications
You must be signed in to change notification settings - Fork 74
Remove Travis CI and replace with GitHub Actions #226
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
Merged
Merged
Changes from 5 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
999622e
Initial plan
Copilot 8d86bc7
Replace Travis CI with GitHub Actions for PHPUnit tests
Copilot a4e5dfa
Remove remaining Travis CI references from ignore files
Copilot dc5dd2a
Address code review feedback for PHPUnit workflow
Copilot a26cabe
Add explicit permissions to PHPUnit workflow for security
Copilot b1a1e73
Update .github/workflows/phpunit-ci.yml
JJJ 3c72a4f
Update CONTRIBUTING.md
JJJ 821b987
Set minimum PHP version to 7.4 in PHPUnit workflow
Copilot File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,7 +4,6 @@ | |
| .git | ||
| .gitignore | ||
| .gitattributes | ||
| .travis.yml | ||
| .DS_Store | ||
| .wordpress-org | ||
| .github | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,112 @@ | ||
| name: PHPUnit Tests | ||
|
|
||
| on: | ||
| push: | ||
| branches: | ||
| - master | ||
| - release/* | ||
| pull_request: | ||
|
|
||
| jobs: | ||
| test: | ||
| name: PHP ${{ matrix.php }} - WP ${{ matrix.wp }} | ||
| runs-on: ubuntu-latest | ||
|
|
||
| permissions: | ||
| contents: read | ||
|
|
||
| strategy: | ||
| fail-fast: false | ||
| matrix: | ||
| php: ['7.2', '7.3', '7.4', '8.0', '8.1', '8.2'] | ||
| wp: ['latest'] | ||
| experimental: [false] | ||
| include: | ||
| # Test with older WordPress version | ||
| - php: '7.2' | ||
| wp: '4.9' | ||
| experimental: false | ||
| - php: '8.0' | ||
| wp: '4.9' | ||
| experimental: false | ||
| # Test with WordPress trunk/master (allow failures) | ||
| - php: '8.2' | ||
| wp: 'trunk' | ||
| experimental: true | ||
|
|
||
| continue-on-error: ${{ matrix.experimental }} | ||
|
|
||
| services: | ||
| mysql: | ||
| image: mysql:5.7 | ||
| env: | ||
| MYSQL_ALLOW_EMPTY_PASSWORD: yes | ||
| MYSQL_DATABASE: wordpress_tests | ||
| ports: | ||
| - 3306:3306 | ||
| options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3 | ||
|
|
||
| steps: | ||
| - name: Checkout | ||
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Setup PHP | ||
| uses: shivammathur/setup-php@v2 | ||
| with: | ||
| php-version: ${{ matrix.php }} | ||
| extensions: mysqli | ||
| coverage: none | ||
| tools: composer | ||
|
|
||
| - name: Get Composer cache directory | ||
| id: composer-cache | ||
| run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT | ||
|
|
||
| - name: Setup Composer cache | ||
| uses: actions/cache@v4 | ||
| with: | ||
| path: ${{ steps.composer-cache.outputs.dir }} | ||
| key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} | ||
| restore-keys: | | ||
| ${{ runner.os }}-composer- | ||
|
|
||
| - name: Install Composer dependencies | ||
| run: composer install --prefer-dist --no-progress --no-interaction | ||
|
|
||
| - name: PHP Lint | ||
| run: find -L . -path ./vendor -prune -o -name '*.php' -not -name 'class-wp-ms-network-command.php' -print0 | xargs -0 -n 1 -P 4 php -l | ||
|
|
||
| - name: Setup WordPress test environment | ||
| env: | ||
| WP_VERSION: ${{ matrix.wp }} | ||
| run: | | ||
| if [[ "$WP_VERSION" == "latest" ]]; then | ||
| WP_VERSION=$(curl -s http://api.wordpress.org/core/version-check/1.7/ | grep -o '"version":"[^"]*' | sed 's/"version":"//' | head -1) | ||
| fi | ||
| if [[ "$WP_VERSION" == "trunk" ]]; then | ||
| WP_VERSION="master" | ||
| fi | ||
|
|
||
| # Get plugin slug from repository name | ||
| PLUGIN_SLUG=$(basename "$GITHUB_WORKSPACE") | ||
|
|
||
| # Clone WordPress | ||
| git clone --depth=1 --branch="$WP_VERSION" https://github.com/WordPress/wordpress-develop.git /tmp/wordpress | ||
|
|
||
| # Setup plugin directory | ||
| mkdir -p /tmp/wordpress/src/wp-content/mu-plugins | ||
| cp -r "$GITHUB_WORKSPACE" "/tmp/wordpress/src/wp-content/mu-plugins/$PLUGIN_SLUG" | ||
|
|
||
| # Configure tests | ||
| cd /tmp/wordpress | ||
| cp wp-tests-config-sample.php wp-tests-config.php | ||
| sed -i "s/youremptytestdbnamehere/wordpress_tests/" wp-tests-config.php | ||
| sed -i "s/yourusernamehere/root/" wp-tests-config.php | ||
| sed -i "s/yourpasswordhere//" wp-tests-config.php | ||
| sed -i "s/localhost/127.0.0.1:3306/" wp-tests-config.php | ||
|
|
||
| - name: Run PHPUnit tests | ||
| run: | | ||
| PLUGIN_SLUG=$(basename "$GITHUB_WORKSPACE") | ||
| cd "/tmp/wordpress/src/wp-content/mu-plugins/$PLUGIN_SLUG" | ||
| vendor/bin/phpunit -c phpunit.xml.dist | ||
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.