Skip to content

Commit 06bbefd

Browse files
authored
Merge pull request #155 from Automattic/release/0.6.0
2 parents 288edf2 + 93e3d37 commit 06bbefd

Some content is hidden

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

48 files changed

+3293
-5489
lines changed

.gitattributes

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Exclude these files from release archives.
2+
3+
# This will also make them unavailable when using Composer with `--prefer-dist`.
4+
5+
# If you develop for this package using Composer, use `--prefer-source`.
6+
# https://www.reddit.com/r/PHP/comments/2jzp6k/i_dont_need_your_tests_in_my_production
7+
# https://blog.madewithlove.be/post/gitattributes/
8+
9+
# They are also used when pushing to WordPress.org SVN using the
10+
# https://github.com/10up/action-wordpress-plugin-deploy GitHub Action.
11+
12+
# Directories
13+
/.github export-ignore
14+
/.wordpress-org export-ignore
15+
/bin export-ignore
16+
/tests export-ignore
17+
18+
# Files
19+
/.editorconfig export-ignore
20+
/.gitattributes export-ignore
21+
/.gitignore export-ignore
22+
/.phpcs.xml.dist export-ignore
23+
/CHANGELOG.md export-ignore
24+
/composer.json export-ignore
25+
/phpunit.xml.dist export-ignore

.github/dependabot.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# To get started with Dependabot version updates, you'll need to specify which
2+
# package ecosystems to update and where the package manifests are located.
3+
# Please see the documentation for all configuration options:
4+
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
5+
6+
version: 2
7+
updates:
8+
9+
# Maintain dependencies for GitHub Actions
10+
- package-ecosystem: "github-actions"
11+
directory: "/"
12+
schedule:
13+
interval: "daily"
14+
15+
# Maintain dependencies for Composer
16+
- package-ecosystem: "composer"
17+
directory: "/"
18+
schedule:
19+
interval: "daily"

.github/workflows/changelog.js

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
// Replaces the `<!-- changelog -->` comment in the README.md with the release notes from GitHub.
2+
// Usage locally:
3+
// TOKEN=... GITHUB_REPOSITORY='Automattic/ad-code-manager' node .github/workflows/changelog.js
4+
// Where TOKEN is a personal GitHub token that has access to the repo: https://github.com/settings/tokens
5+
// In a GitHub Workflow, TOKEN can be passed the special ${{ secrets.GITHUB_TOKEN }} token.
6+
7+
const github = require('@actions/github');
8+
const semver = require('semver');
9+
const replace = require('replace-in-file');
10+
11+
const filename = process.argv[2] || 'README.md';
12+
const myToken = process.env.TOKEN;
13+
14+
async function run() {
15+
const api = new github.GitHub(myToken);
16+
17+
const { data: releases } = await api.repos.listReleases( github.context.repo );
18+
19+
let published = releases.filter( release =>
20+
! release.draft && ! release.prerelease
21+
);
22+
23+
let sorted = published.sort( ( a, b ) =>
24+
semver.rcompare( semver.coerce( a.tag_name ), semver.coerce( b.tag_name ) )
25+
);
26+
27+
let changelog = sorted.reduce( ( changelog, release ) =>
28+
`${changelog}
29+
30+
### ${release.tag_name}
31+
32+
${release.body}`
33+
, '## Changelog' );
34+
35+
try {
36+
const results = await replace( {
37+
files: filename,
38+
from: '<!-- changelog -->',
39+
to: changelog,
40+
} );
41+
42+
if ( results.filter( result => ! result.hasChanged ).length ) {
43+
console.error( 'No replacements made' );
44+
process.exitCode = 1;
45+
}
46+
} catch( exception ) {
47+
console.error( exception );
48+
process.exitCode = 1;
49+
}
50+
}
51+
52+
run();

.github/workflows/cs-lint.yml

Lines changed: 28 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: CS & Lint
1+
name: Lint PHP & XML
22

33
on:
44
# Run on all pushes and on all pull requests.
@@ -7,22 +7,34 @@ on:
77
paths-ignore:
88
- "**.md"
99
pull_request:
10+
1011
# Allow manually triggering the workflow.
1112
workflow_dispatch:
1213

1314
jobs:
1415
checkcs:
15-
name: "Basic CS and QA checks"
16+
name: Lint checks for PHP ${{ matrix.php }}
1617
runs-on: ubuntu-latest
1718

1819
env:
1920
XMLLINT_INDENT: " "
2021

22+
strategy:
23+
matrix:
24+
php: ['7.1', '8.1']
25+
experimental: [false]
26+
include:
27+
- php: '8.2'
28+
experimental: true
29+
fail-fast: false
30+
31+
continue-on-error: ${{ matrix.experimental }}
32+
2133
steps:
22-
- name: Setup PHP
34+
- name: Setup PHP ${{ matrix.php }}
2335
uses: shivammathur/setup-php@v2
2436
with:
25-
php-version: "7.4"
37+
php-version: ${{ matrix.php }}
2638
coverage: none
2739
tools: cs2pr
2840

@@ -37,34 +49,29 @@ jobs:
3749
uses: korelstar/xmllint-problem-matcher@v1
3850

3951
- name: Checkout code
40-
uses: actions/checkout@v2
41-
42-
# Validate the composer.json file.
43-
# @link https://getcomposer.org/doc/03-cli.md#validate
44-
- name: Validate Composer installation
45-
run: composer validate --no-check-all
52+
uses: actions/checkout@v3
4653

4754
# Install dependencies and handle caching in one go.
48-
# @link https://github.com/marketplace/actions/install-composer-dependencies
55+
# @link https://github.com/marketplace/actions/install-php-dependencies-with-composer
4956
- name: Install Composer dependencies
50-
uses: ramsey/composer-install@v1
57+
if: ${{ matrix.php < 8.2 }}
58+
uses: ramsey/composer-install@v2
59+
60+
- name: Install Composer dependencies for PHP >= 8.2
61+
if: ${{ matrix.php >= 8.2 }}
62+
uses: ramsey/composer-install@v2
63+
with:
64+
composer-options: --ignore-platform-reqs
5165

5266
# Lint PHP.
5367
- name: Lint PHP against parse errors
54-
run: composer lint-ci | cs2pr
68+
run: composer lint-ci --no-interaction | cs2pr
5569

5670
# Needed as runs-on: system doesn't have xml-lint by default.
5771
# @link https://github.com/marketplace/actions/xml-lint
5872
- name: Lint phpunit.xml.dist
73+
if: ${{ matrix.php >= 7.3 }}
5974
uses: ChristophWurst/xmllint-action@v1
6075
with:
6176
xml-file: ./phpunit.xml.dist
6277
xml-schema-file: ./vendor/phpunit/phpunit/phpunit.xsd
63-
64-
# Check the code-style consistency of the PHP files.
65-
# - name: Check PHP code style
66-
# continue-on-error: true
67-
# run: vendor/bin/phpcs --report-full --report-checkstyle=./phpcs-report.xml
68-
69-
# - name: Show PHPCS results in PR
70-
# run: cs2pr ./phpcs-report.xml

.github/workflows/deploy.yml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: Deploy to WordPress.org
2+
on:
3+
release:
4+
types: [released]
5+
jobs:
6+
tag:
7+
name: New tag
8+
runs-on: ubuntu-20.04
9+
steps:
10+
- name: Checkout repository
11+
uses: actions/checkout@v3
12+
13+
- name: Configure NPM cache
14+
uses: c-hive/gha-npm-cache@v1
15+
16+
- name: Install Dependencies
17+
run: npm install
18+
19+
- name: Populate Changelog
20+
run: node .github/workflows/changelog.js
21+
env:
22+
TOKEN: ${{ secrets.GITHUB_TOKEN }}
23+
24+
- name: WordPress Plugin Deploy
25+
uses: 10up/action-wordpress-plugin-deploy@stable
26+
env:
27+
SVN_PASSWORD: ${{ secrets.SVN_PASSWORD }}
28+
SVN_USERNAME: ${{ secrets.SVN_USERNAME }}
29+
SLUG: ad-code-manager

.github/workflows/integrations.yml

Lines changed: 36 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -7,79 +7,77 @@ on:
77
paths-ignore:
88
- "**.md"
99
pull_request:
10+
1011
# Allow manually triggering the workflow.
1112
workflow_dispatch:
1213

1314
jobs:
1415
test:
1516
name: WP ${{ matrix.wordpress }} on PHP ${{ matrix.php }}
16-
# Ubuntu-20.x includes MySQL 8.0, which causes `caching_sha2_password` issues with PHP < 7.4
17-
# https://www.php.net/manual/en/mysqli.requirements.php
18-
# TODO: change to ubuntu-latest when we no longer support PHP < 7.4
19-
runs-on: ubuntu-18.04
17+
runs-on: ubuntu-20.04
2018

2119
env:
2220
WP_VERSION: ${{ matrix.wordpress }}
2321

2422
strategy:
23+
# PHP 7.1 uses PHPUnit 7.5.20
24+
# PHP 7.2 uses PHPUnit 8.5.21
25+
# PHP 7.3 uses PHPUnit 9.5.10
26+
# PHP 7.4 uses PHPUnit 9.5.10
27+
# PHP 8.0 uses PHPUnit 9.5.10
28+
# PHP 8.1 uses PHPUnit 9.5.10
29+
# PHP 8.2 uses PHPUnit 9.5.10
30+
# Key:
31+
# - coverage: Whether to run the tests with code coverage.
32+
# - experimental: Whether the build is "allowed to fail".
2533
matrix:
26-
wordpress: ["5.5", "5.6", "5.7"]
27-
php: ["5.6", "7.0", "7.1", "7.2", "7.3", "7.4"]
34+
php: ['7.2', '7.3', '7.4', '8.0', '8.1']
35+
wordpress: ['5.5', '5.6', '5.7', '5.8', '5.9']
36+
experimental: [false]
37+
coverage: [none]
2838
include:
29-
- php: "8.0"
30-
# Ignore platform requirements, so that PHPUnit 7.5 can be installed on PHP 8.0 (and above).
31-
composer-options: "--ignore-platform-reqs"
32-
extensions: pcov
33-
ini-values: pcov.directory=., "pcov.exclude=\"~(vendor|tests)~\""
34-
coverage: pcov
35-
exclude:
36-
- php: "8.0"
37-
wordpress: "5.5"
39+
- php: '7.1'
40+
wordpress: '5.8.3'
41+
experimental: false
42+
coverage: none
3843
fail-fast: false
39-
44+
continue-on-error: ${{ matrix.experimental }}
4045
steps:
4146
- name: Checkout code
42-
uses: actions/checkout@v2
47+
uses: actions/checkout@v3
4348

4449
- name: Setup PHP ${{ matrix.php }}
4550
uses: shivammathur/setup-php@v2
4651
with:
4752
php-version: ${{ matrix.php }}
4853
extensions: ${{ matrix.extensions }}
49-
ini-values: ${{ matrix.ini-values }}
5054
coverage: ${{ matrix.coverage }}
5155

5256
- name: Setup problem matchers for PHP
5357
run: echo "::add-matcher::${{ runner.tool_cache }}/php.json"
5458

55-
# Setup PCOV since we're using PHPUnit < 8 which has it integrated. Requires PHP 7.1.
56-
# Ignore platform reqs to make it install on PHP 8.
57-
# https://github.com/krakjoe/pcov-clobber
58-
- name: Setup PCOV
59-
if: ${{ matrix.php == 8.0 }}
60-
run: |
61-
composer require pcov/clobber --ignore-platform-reqs
62-
vendor/bin/pcov clobber
63-
6459
- name: Setup Problem Matchers for PHPUnit
6560
run: echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"
6661

6762
- name: Install Composer dependencies
68-
uses: ramsey/composer-install@v1
63+
if: ${{ matrix.php < 8.2 }}
64+
uses: ramsey/composer-install@v2
65+
66+
- name: Install Composer dependencies for PHP >= 8.2
67+
if: ${{ matrix.php >= 8.2 }}
68+
uses: ramsey/composer-install@v2
6969
with:
70-
composer-options: "${{ matrix.composer-options }}"
70+
composer-options: --ignore-platform-reqs
7171

7272
- name: Start MySQL Service
7373
run: sudo systemctl start mysql.service
7474

75+
- name: Setting mysql_native_password for PHP <= 7.3
76+
if: ${{ matrix.php <= 7.3 }}
77+
run: mysql -u root -proot -e "ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'root';"
78+
7579
- name: Prepare environment for integration tests
76-
run: composer prepare-ci
80+
run: composer prepare-ci --no-interaction
7781

78-
- name: Run integration tests (single site)
79-
if: ${{ matrix.php != 8.0 }}
80-
run: composer test
81-
- name: Run integration tests (single site with code coverage)
82-
if: ${{ matrix.php == 8.0 }}
83-
run: composer coverage-ci
84-
- name: Run integration tests (multisite)
85-
run: composer test-ms
82+
- name: Run integration tests
83+
run: composer test --no-interaction

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
1-
composer.lock
1+
/.phpunit.result.cache
2+
/composer.lock
3+
/package-lock.json
24
/vendor

.phpcs.xml.dist

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
<rule ref="PHPCompatibilityWP"/>
3131
<!-- For help in understanding this testVersion:
3232
https://github.com/PHPCompatibility/PHPCompatibility#sniffing-your-code-for-compatibility-with-specific-php-versions -->
33-
<config name="testVersion" value="5.6-"/>
33+
<config name="testVersion" value="7.1-"/>
3434

3535
<!-- Rules: WordPress Coding Standards - see
3636
https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards -->
@@ -49,6 +49,8 @@
4949
<properties>
5050
<property name="prefixes" type="array">
5151
<element value="ad_code_manager"/>
52+
<element value="acm"/>
53+
<element value="Automattic\AdCodeManager"/>
5254
</property>
5355
</properties>
5456
</rule>
@@ -67,4 +69,8 @@
6769
</properties>
6870
</rule>
6971

72+
<rule ref="WordPress.Files.FileName">
73+
<exclude-pattern>tests/</exclude-pattern>
74+
</rule>
75+
7076
</ruleset>

.wordpress-org/banner-772x250.png

31.2 KB
Loading

.wordpress-org/screenshot-1.jpg

-51 KB
Binary file not shown.

0 commit comments

Comments
 (0)