Skip to content

Commit 0618eb0

Browse files
committed
Update file(s) from wp-cli/.github
1 parent f8f340e commit 0618eb0

File tree

4 files changed

+371
-0
lines changed

4 files changed

+371
-0
lines changed

.actrc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Configuration file for nektos/act.
2+
# See https://github.com/nektos/act#configuration
3+
-P ubuntu-latest=shivammathur/node:latest

.github/workflows/code-quality.yml

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
name: Code Quality Checks
2+
3+
on:
4+
pull_request:
5+
push:
6+
branches:
7+
- main
8+
- master
9+
10+
# Cancels all previous workflow runs for the same branch that have not yet completed.
11+
concurrency:
12+
# The concurrency group contains the workflow name and the branch name.
13+
group: ${{ github.workflow }}-${{ github.ref }}
14+
cancel-in-progress: true
15+
16+
jobs:
17+
18+
lint: #-----------------------------------------------------------------------
19+
name: Lint PHP files
20+
runs-on: ubuntu-latest
21+
steps:
22+
- name: Check out source code
23+
uses: actions/checkout@v2
24+
25+
- name: Check existence of composer.json file
26+
id: check_composer_file
27+
uses: andstor/file-existence-action@v1
28+
with:
29+
files: "composer.json"
30+
31+
- name: Set up PHP environment
32+
if: steps.check_composer_file.outputs.files_exists == 'true'
33+
uses: shivammathur/setup-php@v2
34+
with:
35+
php-version: '7.4'
36+
tools: cs2pr
37+
env:
38+
COMPOSER_TOKEN: ${{ secrets.GITHUB_TOKEN }}
39+
40+
- name: Install Composer dependencies & cache dependencies
41+
if: steps.check_composer_file.outputs.files_exists == 'true'
42+
uses: "ramsey/composer-install@v2"
43+
env:
44+
COMPOSER_ROOT_VERSION: dev-${{ github.event.repository.default_branch }}
45+
46+
- name: Check existence of vendor/bin/parallel-lint file
47+
id: check_linter_file
48+
uses: andstor/file-existence-action@v1
49+
with:
50+
files: "vendor/bin/parallel-lint"
51+
52+
- name: Run Linter
53+
if: steps.check_linter_file.outputs.files_exists == 'true'
54+
run: vendor/bin/parallel-lint -j 10 . --exclude vendor --checkstyle | cs2pr
55+
56+
phpcs: #----------------------------------------------------------------------
57+
name: PHPCS
58+
runs-on: ubuntu-latest
59+
60+
steps:
61+
- name: Check out source code
62+
uses: actions/checkout@v2
63+
64+
- name: Check existence of composer.json & phpcs.xml.dist files
65+
id: check_files
66+
uses: andstor/file-existence-action@v1
67+
with:
68+
files: "composer.json, phpcs.xml.dist"
69+
70+
- name: Set up PHP environment
71+
if: steps.check_files.outputs.files_exists == 'true'
72+
uses: shivammathur/setup-php@v2
73+
with:
74+
php-version: '7.4'
75+
tools: cs2pr
76+
env:
77+
COMPOSER_TOKEN: ${{ secrets.GITHUB_TOKEN }}
78+
79+
- name: Install Composer dependencies & cache dependencies
80+
if: steps.check_files.outputs.files_exists == 'true'
81+
uses: "ramsey/composer-install@v2"
82+
env:
83+
COMPOSER_ROOT_VERSION: dev-${{ github.event.repository.default_branch }}
84+
85+
- name: Check existence of vendor/bin/phpcs file
86+
id: check_phpcs_binary_file
87+
uses: andstor/file-existence-action@v1
88+
with:
89+
files: "vendor/bin/phpcs"
90+
91+
- name: Run PHPCS
92+
if: steps.check_phpcs_binary_file.outputs.files_exists == 'true'
93+
run: vendor/bin/phpcs -q --report=checkstyle | cs2pr
Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
name: Regenerate README file
2+
3+
on:
4+
workflow_dispatch:
5+
push:
6+
branches:
7+
- main
8+
- master
9+
paths-ignore:
10+
- 'features/**'
11+
- 'README.md'
12+
13+
# Cancels all previous workflow runs for the same branch that have not yet completed.
14+
concurrency:
15+
# The concurrency group contains the workflow name and the branch name.
16+
group: ${{ github.workflow }}-${{ github.ref }}
17+
cancel-in-progress: true
18+
19+
20+
jobs:
21+
22+
regenerate-readme: #----------------------------------------------------------
23+
name: Regenerate README.md file
24+
runs-on: ubuntu-latest
25+
if: ${{ github.repository_owner == 'wp-cli' && ! contains(fromJson('[".github", "wp-cli", "wp-cli-bundle", "wp-super-cache-cli", "php-cli-tools", "wp-config-transformer"]'), github.event.repository.name) }}
26+
steps:
27+
- name: Check out source code
28+
uses: actions/checkout@v2
29+
30+
- name: Set up PHP envirnoment
31+
uses: shivammathur/setup-php@v2
32+
with:
33+
php-version: '7.4'
34+
env:
35+
COMPOSER_TOKEN: ${{ secrets.GITHUB_TOKEN }}
36+
37+
- name: Check existence of composer.json file
38+
id: check_composer_file
39+
uses: andstor/file-existence-action@v1
40+
with:
41+
files: "composer.json"
42+
43+
- name: Install Composer dependencies & cache dependencies
44+
if: steps.check_composer_file.outputs.files_exists == 'true'
45+
uses: "ramsey/composer-install@v2"
46+
env:
47+
COMPOSER_ROOT_VERSION: dev-${{ github.event.repository.default_branch }}
48+
49+
- name: Configure git user
50+
run: |
51+
git config --global user.email "[email protected]"
52+
git config --global user.name "Alain Schlesser"
53+
54+
- name: Check if remote branch exists
55+
id: remote-branch
56+
run: echo ::set-output name=exists::$([[ -z $(git ls-remote --heads origin regenerate-readme) ]] && echo "0" || echo "1")
57+
58+
- name: Create branch to base pull request on
59+
if: steps.remote-branch.outputs.exists == 0
60+
run: |
61+
git checkout -b regenerate-readme
62+
63+
- name: Fetch existing branch to add commits to
64+
if: steps.remote-branch.outputs.exists == 1
65+
run: |
66+
git fetch --all --prune
67+
git checkout regenerate-readme
68+
git pull --no-rebase
69+
70+
- name: Install WP-CLI
71+
run: |
72+
curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli-nightly.phar
73+
sudo mv wp-cli-nightly.phar /usr/local/bin/wp
74+
sudo chmod +x /usr/local/bin/wp
75+
76+
- name: Regenerate README.md file
77+
run: |
78+
wp package install "wp-cli/scaffold-package-command:^2"
79+
wp scaffold package-readme --force .
80+
81+
- name: Check if there are changes
82+
id: changes
83+
run: echo ::set-output name=changed::$([[ -z $(git status --porcelain) ]] && echo "0" || echo "1")
84+
85+
- name: Commit changes
86+
if: steps.changes.outputs.changed == 1
87+
run: |
88+
git add README.md
89+
git commit -m "Regenerate README file - $(date +'%Y-%m-%d')"
90+
git push origin regenerate-readme
91+
92+
- name: Create pull request
93+
if: |
94+
steps.changes.outputs.changed == 1 &&
95+
steps.remote-branch.outputs.exists == 0
96+
uses: repo-sync/pull-request@v2
97+
with:
98+
source_branch: regenerate-readme
99+
destination_branch: ${{ github.event.repository.default_branch }}
100+
github_token: ${{ secrets.GITHUB_TOKEN }}
101+
pr_title: Regenerate README file
102+
pr_body: "**This is an automated pull-request**\n\nRefreshes the `README.md` file with the latest changes to the docblocks in the source code."
103+
pr_reviewer: schlessera
104+
pr_label: scope:documentation

.github/workflows/testing.yml

Lines changed: 171 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,171 @@
1+
name: Testing
2+
3+
on:
4+
pull_request:
5+
push:
6+
branches:
7+
- main
8+
- master
9+
10+
# Cancels all previous workflow runs for the same branch that have not yet completed.
11+
concurrency:
12+
# The concurrency group contains the workflow name and the branch name.
13+
group: ${{ github.workflow }}-${{ github.ref }}
14+
cancel-in-progress: true
15+
16+
jobs:
17+
18+
unit: #-----------------------------------------------------------------------
19+
name: Unit test / PHP ${{ matrix.php }}
20+
strategy:
21+
fail-fast: false
22+
matrix:
23+
php: ['5.6', '7.0', '7.1', '7.2', '7.3', '7.4', '8.0', '8.1']
24+
runs-on: ubuntu-20.04
25+
26+
steps:
27+
- name: Check out source code
28+
uses: actions/checkout@v2
29+
30+
- name: Check existence of composer.json file
31+
id: check_files
32+
uses: andstor/file-existence-action@v1
33+
with:
34+
files: "composer.json, phpunit.xml.dist"
35+
36+
- name: Set up PHP environment
37+
if: steps.check_files.outputs.files_exists == 'true'
38+
uses: shivammathur/setup-php@v2
39+
with:
40+
php-version: '${{ matrix.php }}'
41+
coverage: none
42+
tools: composer,cs2pr
43+
env:
44+
COMPOSER_TOKEN: ${{ secrets.GITHUB_TOKEN }}
45+
46+
- name: Install Composer dependencies & cache dependencies
47+
if: steps.check_files.outputs.files_exists == 'true'
48+
uses: "ramsey/composer-install@v2"
49+
env:
50+
COMPOSER_ROOT_VERSION: dev-${{ github.event.repository.default_branch }}
51+
52+
- name: Setup problem matcher to provide annotations for PHPUnit
53+
if: steps.check_files.outputs.files_exists == 'true'
54+
run: echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"
55+
56+
- name: Run PHPUnit
57+
if: steps.check_files.outputs.files_exists == 'true'
58+
run: composer phpunit
59+
60+
functional: #----------------------------------------------------------------------
61+
name: Functional - WP ${{ matrix.wp }} on PHP ${{ matrix.php }} with MySQL ${{ matrix.mysql }}
62+
strategy:
63+
fail-fast: false
64+
matrix:
65+
php: ['5.6', '7.0', '7.1', '7.2', '7.3', '7.4', '8.0', '8.1']
66+
wp: ['latest']
67+
mysql: ['8.0']
68+
include:
69+
- php: '5.6'
70+
wp: 'trunk'
71+
mysql: '8.0'
72+
- php: '5.6'
73+
wp: 'trunk'
74+
mysql: '5.7'
75+
- php: '5.6'
76+
wp: 'trunk'
77+
mysql: '5.6'
78+
- php: '7.4'
79+
wp: 'trunk'
80+
mysql: '8.0'
81+
- php: '8.0'
82+
wp: 'trunk'
83+
mysql: '8.0'
84+
- php: '8.0'
85+
wp: 'trunk'
86+
mysql: '5.7'
87+
- php: '8.0'
88+
wp: 'trunk'
89+
mysql: '5.6'
90+
- php: '8.1'
91+
wp: 'trunk'
92+
mysql: '8.0'
93+
- php: '5.6'
94+
wp: '3.7'
95+
mysql: '5.6'
96+
runs-on: ubuntu-20.04
97+
98+
services:
99+
mysql:
100+
image: mysql:${{ matrix.mysql }}
101+
ports:
102+
- 3306
103+
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3 -e MYSQL_ROOT_PASSWORD=root -e MYSQL_DATABASE=wp_cli_test --entrypoint sh mysql:${{ matrix.mysql }} -c "exec docker-entrypoint.sh mysqld --default-authentication-plugin=mysql_native_password"
104+
105+
steps:
106+
- name: Check out source code
107+
uses: actions/checkout@v2
108+
109+
- name: Check existence of composer.json & behat.yml files
110+
id: check_files
111+
uses: andstor/file-existence-action@v1
112+
with:
113+
files: "composer.json, behat.yml"
114+
115+
- name: Install Ghostscript
116+
if: steps.check_files.outputs.files_exists == 'true'
117+
run: |
118+
sudo apt-get update
119+
sudo apt-get install ghostscript -y
120+
121+
- name: Set up PHP envirnoment
122+
if: steps.check_files.outputs.files_exists == 'true'
123+
uses: shivammathur/setup-php@v2
124+
with:
125+
php-version: '${{ matrix.php }}'
126+
extensions: gd, imagick, mysql, zip
127+
coverage: none
128+
tools: composer
129+
env:
130+
COMPOSER_TOKEN: ${{ secrets.GITHUB_TOKEN }}
131+
132+
- name: Change ImageMagick policy to allow pdf->png conversion.
133+
if: steps.check_files.outputs.files_exists == 'true'
134+
run: |
135+
sudo sed -i 's/^.*policy.*coder.*none.*PDF.*//' /etc/ImageMagick-6/policy.xml
136+
137+
- name: Install Composer dependencies & cache dependencies
138+
if: steps.check_files.outputs.files_exists == 'true'
139+
uses: "ramsey/composer-install@v2"
140+
env:
141+
COMPOSER_ROOT_VERSION: dev-${{ github.event.repository.default_branch }}
142+
143+
- name: Start MySQL server
144+
if: steps.check_files.outputs.files_exists == 'true'
145+
run: sudo systemctl start mysql
146+
147+
- name: Configure DB environment
148+
if: steps.check_files.outputs.files_exists == 'true'
149+
run: |
150+
echo "MYSQL_HOST=127.0.0.1" >> $GITHUB_ENV
151+
echo "MYSQL_TCP_PORT=${{ job.services.mysql.ports['3306'] }}" >> $GITHUB_ENV
152+
echo "WP_CLI_TEST_DBROOTUSER=root" >> $GITHUB_ENV
153+
echo "WP_CLI_TEST_DBROOTPASS=root" >> $GITHUB_ENV
154+
echo "WP_CLI_TEST_DBNAME=wp_cli_test" >> $GITHUB_ENV
155+
echo "WP_CLI_TEST_DBUSER=wp_cli_test" >> $GITHUB_ENV
156+
echo "WP_CLI_TEST_DBPASS=password1" >> $GITHUB_ENV
157+
echo "WP_CLI_TEST_DBHOST=127.0.0.1:${{ job.services.mysql.ports['3306'] }}" >> $GITHUB_ENV
158+
159+
- name: Prepare test database
160+
if: steps.check_files.outputs.files_exists == 'true'
161+
run: composer prepare-tests
162+
163+
- name: Check Behat environment
164+
if: steps.check_files.outputs.files_exists == 'true'
165+
run: WP_CLI_TEST_DEBUG_BEHAT_ENV=1 composer behat
166+
167+
- name: Run Behat
168+
if: steps.check_files.outputs.files_exists == 'true'
169+
env:
170+
WP_VERSION: '${{ matrix.wp }}'
171+
run: composer behat || composer behat-rerun

0 commit comments

Comments
 (0)