Skip to content

Commit 33290b1

Browse files
authored
Merge pull request #130 from rollbar/master
Backport changes from master to v2 branch
2 parents 0374649 + f59fe4c commit 33290b1

File tree

2,026 files changed

+59130
-117357
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

2,026 files changed

+59130
-117357
lines changed

.github/pull_request_template.md

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,23 @@
11
## Description of the change
22

3-
> Description here
3+
> Please include a summary of the change and which issues are fixed.
4+
> Please also include relevant motivation and context.
5+
46
## Type of change
7+
58
- [ ] Bug fix (non-breaking change that fixes an issue)
69
- [ ] New feature (non-breaking change that adds functionality)
710
- [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)
11+
- [ ] Maintenance
12+
- [ ] New release
813

914
## Related issues
1015

11-
> Fix [#1]()
16+
> Shortcut stories and GitHub issues (delete irrelevant)
17+
18+
- Fix [SC-]
19+
- Fix #1
20+
1221
## Checklists
1322

1423
### Development
@@ -17,9 +26,9 @@
1726
- [ ] The code changed/added as part of this pull request has been covered with tests
1827
- [ ] All tests related to the changed code pass in development
1928

20-
### Code review
29+
### Code review
2130

22-
- [ ] This pull request has a descriptive title and information useful to a reviewer. There may be a screenshot or screencast attached
23-
- [ ] "Ready for review" label attached to the PR and reviewers mentioned in a comment
31+
- [ ] This pull request has a descriptive title and information useful to a reviewer. There may be a screenshot or screencast attached
32+
- [ ] "Ready for review" label attached to the PR and reviewers assigned
33+
- [ ] Issue from task tracker has a link to this pull request
2434
- [ ] Changes have been reviewed by at least one other engineer
25-
- [ ] Issue from task tracker has a link to this pull request

.github/workflows/php_unit.yml

Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
name: Unit Tests
2+
3+
# Since Unit Tests are required to pass for each PR,
4+
# we cannot disable them for documentation-only changes.
5+
on:
6+
pull_request:
7+
push:
8+
# Allow manually triggering the workflow.
9+
workflow_dispatch:
10+
11+
# Cancels all previous workflow runs for pull requests that have not completed.
12+
concurrency:
13+
# The concurrency group contains the workflow name and the branch name for pull requests
14+
# or the commit hash for any other events.
15+
group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.head_ref || github.sha }}
16+
cancel-in-progress: true
17+
18+
jobs:
19+
compute-previous-wordpress-version:
20+
name: Compute previous WordPress version
21+
runs-on: ubuntu-latest
22+
outputs:
23+
previous-wordpress-version: ${{ steps.get-previous-wordpress-version.outputs.previous-wordpress-version }}
24+
latest-wordpress-version: ${{ steps.get-latest-wordpress-version.outputs.latest-wordpress-version }}
25+
26+
steps:
27+
- name: Get latest WordPress version
28+
id: get-latest-wordpress-version
29+
run: |
30+
curl \
31+
-H "Accept: application/json" \
32+
-o versions.json \
33+
"http://api.wordpress.org/core/stable-check/1.0/"
34+
LATEST_WP_VERSION=$(jq --raw-output 'with_entries(select(.value=="latest"))|keys[]' versions.json)
35+
echo "latest-wordpress-version=${LATEST_WP_VERSION}" >> $GITHUB_OUTPUT
36+
rm versions.json
37+
- name: Get previous WordPress version
38+
id: get-previous-wordpress-version
39+
run: |
40+
curl \
41+
-H "Accept: application/json" \
42+
-o versions.json \
43+
"http://api.wordpress.org/core/stable-check/1.0/"
44+
LATEST_WP_VERSION=$(jq --raw-output 'with_entries(select(.value=="latest"))|keys[]' versions.json)
45+
IFS='.' read LATEST_WP_MAJOR LATEST_WP_MINOR LATEST_WP_PATCH <<< "${LATEST_WP_VERSION}"
46+
if [[ ${LATEST_WP_MINOR} == "0" ]]; then
47+
PREVIOUS_WP_SERIES="$((LATEST_WP_MAJOR - 1)).9"
48+
else
49+
PREVIOUS_WP_SERIES="${LATEST_WP_MAJOR}.$((LATEST_WP_MINOR - 1))"
50+
fi
51+
PREVIOUS_WP_VERSION=$(jq --raw-output --arg series "${PREVIOUS_WP_SERIES}" 'with_entries(select(.key|startswith($series)))|keys[-1]' versions.json)
52+
echo "previous-wordpress-version=${PREVIOUS_WP_VERSION}" >> $GITHUB_OUTPUT
53+
rm versions.json
54+
55+
test-php:
56+
name: PHP ${{ matrix.php }}${{ matrix.wordpress != '' && format( ' (WP {0}) ', matrix.wordpress ) || '' }} on ubuntu-latest
57+
needs: compute-previous-wordpress-version
58+
runs-on: ubuntu-latest
59+
timeout-minutes: 20
60+
strategy:
61+
fail-fast: false
62+
matrix:
63+
php:
64+
- '7.0'
65+
- '7.1'
66+
- '7.2'
67+
- '7.3'
68+
- '7.4'
69+
- '8.0'
70+
- '8.1'
71+
- '8.2'
72+
wordpress: ["${{needs.compute-previous-wordpress-version.outputs.latest-wordpress-version}}" ] # Latest WordPress version.
73+
include:
74+
# Test with the previous WP version.
75+
- php: '7.0'
76+
wordpress: ${{ needs.compute-previous-wordpress-version.outputs.previous-wordpress-version }}
77+
- php: '7.4'
78+
wordpress: ${{ needs.compute-previous-wordpress-version.outputs.previous-wordpress-version }}
79+
- php: '8.2'
80+
wordpress: ${{ needs.compute-previous-wordpress-version.outputs.previous-wordpress-version }}
81+
# Test with the upcoming WP version.
82+
- php: '7.0'
83+
wordpress: ''
84+
- php: '7.4'
85+
wordpress: ''
86+
- php: '8.2'
87+
wordpress: ''
88+
89+
env:
90+
WP_ENV_PHP_VERSION: ${{ matrix.php }}
91+
WP_ENV_CORE: ${{ matrix.wordpress == '' && 'WordPress/WordPress' || format( 'https://wordpress.org/wordpress-{0}.zip', matrix.wordpress ) }}
92+
93+
steps:
94+
- uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3
95+
96+
- name: Install Dependencies
97+
run: npm ci
98+
99+
- name: Docker debug information
100+
run: |
101+
docker -v
102+
docker-compose -v
103+
104+
- name: General debug information
105+
run: |
106+
npm --version
107+
node --version
108+
curl --version
109+
git --version
110+
locale -a
111+
echo "PHP version: ${WP_ENV_PHP_VERSION}"
112+
echo "WordPress version: ${WP_ENV_CORE}"
113+
114+
- name: Start Docker environment
115+
run: npm run wp-env start
116+
117+
- name: Log running Docker containers
118+
run: docker ps -a
119+
120+
- name: Running unit tests
121+
run: |
122+
set -o pipefail
123+
npm run test:php

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ dwsync.xml
3333
# PHPUnit
3434
phpunit.xml
3535
phpunit.env
36+
.phpunit.result.cache
3637

3738
# PHPCS
3839
phpcs.xml
@@ -47,4 +48,5 @@ composer.lock
4748
intermediate
4849
.idea
4950
cache
50-
deploy.sh
51+
deploy.sh
52+
node_modules

.wp-env.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"core": "WordPress/WordPress",
3+
"plugins": [ "." ],
4+
"env": {
5+
"tests": {
6+
"mappings": {
7+
"wp-content/plugins/rollbar": "."
8+
}
9+
}
10+
}
11+
}

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,11 +75,11 @@ The original author of this package is [@flowdee](https://twitter.com/flowdee/).
7575

7676
## Testing
7777

78-
The following is Mac/Linux only - Windows is not supported.
78+
In order to run the tests, you will need to install the dependencies for [@wordpress/env](https://www.npmjs.com/package/@wordpress/env) including Node.js, git, and docker.
7979

80-
Before you run tests, provide test database credentials in `phpunit.env` (you can copy `phpunit.env.dist`, removing the comment in the first line). Then start your `mysqld` service.
81-
82-
Tests are in `tests`; to run them, do `composer test`. To fix code style issues, do `composer fix`.
80+
1. npm install
81+
2. npm run test
82+
You can set the `WP_ENV_PHP_VERSION` enviormental variable to test with different versions of PHP. If you are changing the version, you can do so by running `WP_ENV_PHP_VERSION="8.2" npm run wp-env start -- --update` and setting the enviornmental variable based on
8383

8484
## Tagging
8585

bin/install-wp-tests.sh

Lines changed: 0 additions & 127 deletions
This file was deleted.

bin/update-composer-dependencies.sh

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#!/usr/bin/env bash
2+
3+
# Print Commands
4+
set -x
5+
6+
# Exit on error
7+
set -e
8+
9+
# Change to the parent directory of this script
10+
cd "$(dirname "$(dirname "$(readlink -fm "$0")")")"
11+
12+
# restart the container in PHP 7
13+
WP_ENV_PHP_VERSION="7.0" npm run wp-env start -- --update
14+
15+
# install composer dependencies
16+
WP_ENV_PHP_VERSION="7.0" npm run wp-env -- run --env-cwd='wp-content/plugins/rollbar-php-wordpress/php7' tests-cli composer update
17+
18+
# restart the container in PHP 8.0
19+
WP_ENV_PHP_VERSION="8.0" npm run wp-env start -- --update
20+
21+
# install composer dependencies
22+
WP_ENV_PHP_VERSION="8.0" npm run wp-env -- run --env-cwd='wp-content/plugins/rollbar-php-wordpress/php8' tests-cli composer update

0 commit comments

Comments
 (0)