Skip to content

Commit 995898e

Browse files
authored
Merge pull request #1 from mpkelly/trunk
Add code checks and unit tests + workflow script
2 parents d5652dc + 89c1e21 commit 995898e

File tree

10 files changed

+1817
-1
lines changed

10 files changed

+1817
-1
lines changed

.github/workflows/wpcom.yml

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: Publish Website
2+
3+
on:
4+
push:
5+
branches:
6+
- trunk
7+
workflow_dispatch:
8+
jobs:
9+
Build-Artifact-Action:
10+
name: Build-Artifact-Action
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/checkout@master
14+
- uses: php-actions/composer@v6
15+
- uses: php-actions/composer@v6
16+
with:
17+
command: check-code
18+
- uses: php-actions/composer@v6
19+
with:
20+
command: test
21+
- name: Upload the artifact
22+
uses: actions/upload-artifact@v4
23+
with:
24+
name: wpcom
25+
path: .

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/vendor/

.idea/.gitignore

+8
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

README.md

+9-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,10 @@
11
# githubdeployments-phpunit-phpcs-example
2-
An example plugin repository with a workflow script that runs PHP CodeSniffer and PHPUnit
2+
An example plugin repository with a workflow script that runs PHP CodeSniffer and PHPUnit.
3+
4+
The [workflow](.github/workflows/wpcom.yml) does the following:
5+
6+
- Checkout the repository
7+
- Runs the composer action which executes the default command, `composter install`.
8+
- Runs the composer action again with a custom command that runs PHPCodeSniffer
9+
- Runs the composer action again with a custom command that runs PHPUnit
10+
- If all previous actions completely withotu error, it creates a build artifact with name "wpcom" which is required for WordPress.com's GitHub Deployment feature

adder.php

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<?php
2+
3+
namespace Adder;
4+
5+
function add( $a, $b ) {
6+
return $a + $b;
7+
}

composer.json

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"require-dev": {
3+
"squizlabs/php_codesniffer": "*",
4+
"phpunit/phpunit": "^11.0"
5+
},
6+
"scripts": {
7+
"check-code": "phpcs -s ./index.php",
8+
"test": "phpunit ./tests"
9+
}
10+
}

0 commit comments

Comments
 (0)