Skip to content

Commit

Permalink
Merge pull request #1 from mpkelly/trunk
Browse files Browse the repository at this point in the history
Add code checks and unit tests + workflow script
  • Loading branch information
mpkelly authored Mar 1, 2024
2 parents d5652dc + 89c1e21 commit 995898e
Show file tree
Hide file tree
Showing 10 changed files with 1,817 additions and 1 deletion.
25 changes: 25 additions & 0 deletions .github/workflows/wpcom.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Publish Website

on:
push:
branches:
- trunk
workflow_dispatch:
jobs:
Build-Artifact-Action:
name: Build-Artifact-Action
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- uses: php-actions/composer@v6
- uses: php-actions/composer@v6
with:
command: check-code
- uses: php-actions/composer@v6
with:
command: test
- name: Upload the artifact
uses: actions/upload-artifact@v4
with:
name: wpcom
path: .
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/vendor/
8 changes: 8 additions & 0 deletions .idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 9 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,10 @@
# githubdeployments-phpunit-phpcs-example
An example plugin repository with a workflow script that runs PHP CodeSniffer and PHPUnit
An example plugin repository with a workflow script that runs PHP CodeSniffer and PHPUnit.

The [workflow](.github/workflows/wpcom.yml) does the following:

- Checkout the repository
- Runs the composer action which executes the default command, `composter install`.
- Runs the composer action again with a custom command that runs PHPCodeSniffer
- Runs the composer action again with a custom command that runs PHPUnit
- 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
7 changes: 7 additions & 0 deletions adder.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?php

namespace Adder;

function add( $a, $b ) {
return $a + $b;
}
10 changes: 10 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"require-dev": {
"squizlabs/php_codesniffer": "*",
"phpunit/phpunit": "^11.0"
},
"scripts": {
"check-code": "phpcs -s ./index.php",
"test": "phpunit ./tests"
}
}
Loading

0 comments on commit 995898e

Please sign in to comment.