Skip to content

Commit

Permalink
add PHPCS and Stylelint environment, test in CI, ignore from deployment
Browse files Browse the repository at this point in the history
Verify compliance to coding standards in GH action.
The necessary environment files should not be deployed, so the deployment
action explicitly uses the .distignore file to exclude them.
  • Loading branch information
stklcode committed Feb 9, 2023
1 parent ea9da0e commit 082cfa3
Show file tree
Hide file tree
Showing 10 changed files with 4,586 additions and 5 deletions.
12 changes: 12 additions & 0 deletions .distignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/.git
/.github
/node_modules
/vendor
/.distignore
/.gitignore
/.stylelintrc.json
/composer.json
/composer.lock
/package.json
/package-lock.json
/phpcs.xml
12 changes: 7 additions & 5 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,16 @@ jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
# Compile CSS
- name: Compile style CSS
uses: gha-utilities/sass-build@v0.4.11
uses: gha-utilities/sass-build@v0.5.1
with:
source: assets/scss/style.scss
destination: style.css
outputStyle: expanded
- name: Compile style CSS compressed
uses: gha-utilities/sass-build@v0.4.11
uses: gha-utilities/sass-build@v0.5.1
with:
source: assets/scss/style.scss
destination: style.min.css
Expand All @@ -28,5 +28,7 @@ jobs:
key: ${{ secrets.SSH_PRIVATE_KEY }}
known_hosts: ${{ secrets.KNOWN_HOSTS }}
# Transfer file to remote server
- run: ssh ${{ secrets.REMOTE_USER }}@${{ secrets.REMOTE_HOST }} "mkdir -p ${{ secrets.REMOTE_PATH_BASE }}"
- run: rsync -ahv * ${{ secrets.REMOTE_USER }}@${{ secrets.REMOTE_HOST }}:${{ secrets.REMOTE_PATH_BASE }}
- name: Deploy
run: |
ssh ${{ secrets.REMOTE_USER }}@${{ secrets.REMOTE_HOST }} "mkdir -p ${{ secrets.REMOTE_PATH_BASE }}"
rsync -ahv --exclude-from="$GITHUB_WORKSPACE/.distignore" --delete-excluded "$GITHUB_WORKSPACE/" ${{ secrets.REMOTE_USER }}@${{ secrets.REMOTE_HOST }}:${{ secrets.REMOTE_PATH_BASE }}
24 changes: 24 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Tests
on: [push, pull_request]
jobs:
quality:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.2'
tools: composer
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: '18'
- name: Code style checks for PHP
run:
composer install
composer lint-php
- name: Code style checks for SCSS
run: |
npm ci
npm run lint-scss
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/.idea
/*.css
/node_modules
/vendor
8 changes: 8 additions & 0 deletions .stylelintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"extends": "@wordpress/stylelint-config/scss",
"rules": {
"max-line-length": null,
"no-descending-specificity": null,
"value-keyword-case": null
}
}
44 changes: 44 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
{
"name": "pluginkollektiv/lovelace",
"type": "wordpress-theme",
"license": "GPL-2.0+",
"description": "Atomic Blocks child theme for pluginkollektiv.org",
"homepage": "https://pluginkollektiv.org/",
"authors": [
{
"name": "pluginkollektiv",
"homepage": "https://github.com/pluginkollektiv"
}
],
"keywords": [
"wordpress", "wordpress-theme"
],
"support": {
"issues": "https://github.com/pluginkollektiv/lovelace",
"forum": "https://wordpress.org/support/plugin/lovelace"
},
"require": {
"php": ">=5.6.0",
"composer/installers": "^v2.2.0"
},
"require-dev": {
"dealerdirect/phpcodesniffer-composer-installer": "^v1.0.0",
"squizlabs/php_codesniffer": "^3.7.2",
"phpcompatibility/phpcompatibility-wp": "^2.1.4",
"wp-coding-standards/wpcs": "^3.0.1"
},
"scripts": {
"lint-css": [
"npx stylelint assets/scss"
],
"lint-php": [
"phpcs --standard=phpcs.xml -s"
]
},
"config": {
"allow-plugins": {
"composer/installers": true,
"dealerdirect/phpcodesniffer-composer-installer": true
}
}
}
Loading

0 comments on commit 082cfa3

Please sign in to comment.