Skip to content

Commit 859831a

Browse files
authored
Merge pull request #93 from BeAPI/feat/cicd
feat(root) Add tools and workflows
2 parents f2a90c8 + dc2f8fc commit 859831a

File tree

12 files changed

+4101
-4
lines changed

12 files changed

+4101
-4
lines changed

.distignore

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
/.git
2+
/.github
3+
/.wordpress-org
4+
/node_modules
5+
/src
6+
7+
.distignore
8+
.gitattributes
9+
.gitignore
10+
.nvmrc
11+
.plugin-data
12+
.wp-env.json
13+
CHANGELOG.md
14+
composer.json
15+
composer.lock
16+
grumphp.yml
17+
LICENSE.md
18+
package.json
19+
package-lock.json
20+
phpcs.xml.dist
21+
phpunit.xml.dist
22+
phpcs.xml
23+
phpunit.xml
24+
psalm.xml
25+
README.md

.gitattributes

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
/.git export-ignore
2+
/.github export-ignore
3+
/vendor/ export-ignore -diff
4+
/node_modules export-ignore
5+
6+
/.distignore export-ignore
7+
/.gitattributes export-ignore
8+
/.gitignore export-ignore
9+
/.plugin-data export-ignore
10+
/composer.json export-ignore
11+
/composer.lock export-ignore -diff
12+
/package.json export-ignore
13+
/package-lock.json export-ignore -diff
14+
/webpack.config.js export-ignore
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: "Check plugin version and tags"
2+
on:
3+
pull_request:
4+
branches:
5+
- master
6+
7+
jobs:
8+
version-check:
9+
name: "Check version doesn't not already exists."
10+
runs-on: ubuntu-latest
11+
steps:
12+
- name: Checkout code
13+
uses: actions/checkout@v3
14+
with:
15+
fetch-depth: 0
16+
17+
- id: set-vars
18+
name: "Set variables from .plugin-data file"
19+
run: |
20+
# Get all data from .plugin-data file
21+
content=`cat ./.plugin-data`
22+
# the following lines are only required for multi line json
23+
content="${content//'%'/'%25'}"
24+
content="${content//$'\n'/'%0A'}"
25+
content="${content//$'\r'/'%0D'}"
26+
# end of optional handling for multi line json
27+
echo "::set-output name=pluginData::$content"
28+
29+
- id: version-check
30+
name: "Check version in .plugin-data is not existing"
31+
run: |
32+
# Check version from .plugin-data
33+
VERSION=${{fromJson(steps.set-vars.outputs.pluginData).version}}
34+
35+
if git rev-parse "$VERSION" >/dev/null 2>&1; then
36+
echo "Tag aleady exists please update the .plugin-data file to good version";
37+
exit 1;
38+
fi

.github/workflows/quality-js.yml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: Javascript Quality Checks
2+
3+
on:
4+
pull_request:
5+
push:
6+
branches:
7+
- master
8+
9+
# Cancels all previous workflow runs for pull requests that have not completed.
10+
concurrency:
11+
# The concurrency group contains the workflow name and the branch name for pull requests
12+
# or the commit hash for any other events.
13+
group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.head_ref || github.sha }}
14+
cancel-in-progress: true
15+
16+
jobs:
17+
checks:
18+
name: Lint JS
19+
runs-on: ubuntu-latest
20+
21+
steps:
22+
- name: Checkout project
23+
uses: actions/checkout@v3
24+
25+
- name: Setup NodeJS
26+
uses: actions/setup-node@v3
27+
with:
28+
node-version-file: '.nvmrc'
29+
30+
- name: Install npm dependencies
31+
run: npm install
32+
33+
- name: Run wp-script lint:js on src folder
34+
run: npm run lint:js src

.github/workflows/quality-php.yml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: PHP Quality Checks
2+
3+
on:
4+
pull_request:
5+
push:
6+
branches:
7+
- master
8+
9+
# Cancels all previous workflow runs for pull requests that have not completed.
10+
concurrency:
11+
# The concurrency group contains the workflow name and the branch name for pull requests
12+
# or the commit hash for any other events.
13+
group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.head_ref || github.sha }}
14+
cancel-in-progress: true
15+
16+
jobs:
17+
checks:
18+
name: Codesniffer
19+
runs-on: ubuntu-latest
20+
21+
steps:
22+
- name: Checkout project
23+
uses: actions/checkout@v3
24+
25+
- name: Setup PHP
26+
uses: shivammathur/setup-php@v2
27+
with:
28+
php-version: 5.6
29+
extensions: mbstring, intl
30+
31+
- name: Validate composer file
32+
run: composer validate
33+
34+
- name: Install composer dependencies
35+
run: composer install
36+
37+
- name: Run codesniffer
38+
run: composer cs
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: "Publish New Release on WordPress.org"
2+
on:
3+
release:
4+
types: [ published ]
5+
6+
jobs:
7+
wordpress-release:
8+
name: "New release on WordPress.org"
9+
runs-on: ubuntu-latest
10+
steps:
11+
- name: Checkout code
12+
uses: actions/checkout@v3
13+
14+
- id: set-vars
15+
name: "Set variables from .plugin-data file"
16+
run: |
17+
# Get all data from .plugin-data file
18+
content=`cat ./.plugin-data`
19+
# the following lines are only required for multi line json
20+
content="${content//'%'/'%25'}"
21+
content="${content//$'\n'/'%0A'}"
22+
content="${content//$'\r'/'%0D'}"
23+
# end of optional handling for multi line json
24+
echo "::set-output name=pluginData::$content"
25+
26+
- id: deploy
27+
name: "WordPress.org Plugin Deploy"
28+
if: "! github.event.release.prerelease"
29+
uses: 10up/action-wordpress-plugin-deploy@stable
30+
env:
31+
SVN_USERNAME: ${{ secrets.SVN_USERNAME }}
32+
SVN_PASSWORD: ${{ secrets.SVN_PASSWORD }}
33+
SLUG: ${{fromJson(steps.set-vars.outputs.pluginData).slug}}

.plugin-data

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"version": "2.1.3",
3+
"slug": "bea-media-analytics"
4+
}

composer.json

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,5 +25,33 @@
2525
"require":{
2626
"php":">=5.6.0",
2727
"julien731/wp-dismissible-notices-handler":"1.0"
28+
},
29+
"require-dev": {
30+
"dealerdirect/phpcodesniffer-composer-installer": "^1.0",
31+
"humanmade/psalm-plugin-wordpress": "^2.2",
32+
"overtrue/phplint": "^9.0",
33+
"php-parallel-lint/php-parallel-lint": "^1.3",
34+
"phpcompatibility/php-compatibility": "^9.3",
35+
"phpro/grumphp-shim": "^2.0",
36+
"vimeo/psalm": "^4.30",
37+
"wp-coding-standards/wpcs": "^3.0"
38+
},
39+
"config": {
40+
"allow-plugins": {
41+
"dealerdirect/phpcodesniffer-composer-installer": true,
42+
"phpro/grumphp-shim": true
43+
}
44+
},
45+
"scripts": {
46+
"cs": "./vendor/bin/phpcs",
47+
"cb": "./vendor/bin/phpcbf",
48+
"psalm": "./vendor/bin/psalm"
49+
},
50+
"scripts-descriptions": {
51+
"cs": "Run PHP CodeSniffer on codebase using custom ruleset.",
52+
"cb": "Run PHP Code Beautifier and Fixer on codebase using custom ruleset.",
53+
"psalm": "Run psalm on codebase using custom ruleset.",
54+
"phpunit": "Run PHP unit tests."
2855
}
56+
2957
}

0 commit comments

Comments
 (0)